private void writeDependencies(OptionalAttributeXmlWriter xmlWriter) throws IOException { xmlWriter.startElement("dependencies"); for (IvyDependencyInternal dependency : dependencies) { xmlWriter.startElement("dependency") .attribute("org", dependency.getOrganisation()) .attribute("name", dependency.getModule()) .attribute("rev", dependency.getRevision()) .attribute("conf", dependency.getConfMapping()); if (!dependency.isTransitive()) { xmlWriter.attribute("transitive", "false"); } for (DependencyArtifact dependencyArtifact : dependency.getArtifacts()) { printDependencyArtifact(dependencyArtifact, xmlWriter); } for(ExcludeRule excludeRule : dependency.getExcludeRules()) { writeDependencyExclude(excludeRule, xmlWriter); } xmlWriter.endElement(); } xmlWriter.endElement(); }
/** * Add dependencies to the POM * * Adds all dependencies from the provided configuration with the provided scope to the POM and to the set of * existing dependencies. Dependencies are only added if they are not contained in the set of existing dependencies. * * @param dependencies Element to add dependencies to * @param configuration Configuration whose provides depencencies to add * @param scope Scope to use for added depencencies */ protected void addDependencies(Element dependencies, Configuration configuration, String scope) { for (@NonNull Dependency dependency : configuration.getDependencies()) { if (dependency instanceof ModuleDependency) { ModuleDependency moduleDependency = (ModuleDependency) dependency; if (moduleDependency.getArtifacts().isEmpty()) { addDependency(dependencies, moduleDependency, moduleDependency.getName(), null, "jar", scope); } else { for (DependencyArtifact artifact : moduleDependency.getArtifacts()) { addDependency(dependencies, moduleDependency, artifact.getName(), artifact.getClassifier(), artifact.getType(), scope); } } } } }
private void writeDependencies(OptionalAttributeXmlWriter xmlWriter) throws IOException { xmlWriter.startElement("dependencies"); for (IvyDependencyInternal dependency : dependencies) { xmlWriter.startElement("dependency") .attribute("org", dependency.getOrganisation()) .attribute("name", dependency.getModule()) .attribute("rev", dependency.getRevision()) .attribute("conf", dependency.getConfMapping()); for (DependencyArtifact dependencyArtifact : dependency.getArtifacts()) { printDependencyArtifact(dependencyArtifact, xmlWriter); } xmlWriter.endElement(); } xmlWriter.endElement(); }
private void addDependency(MavenDependencyInternal mavenDependency, String scope) { if (mavenDependency.getArtifacts().size() == 0) { addDependency(mavenDependency, mavenDependency.getArtifactId(), scope, null, null); } else { for (DependencyArtifact artifact : mavenDependency.getArtifacts()) { addDependency(mavenDependency, artifact.getName(), scope, artifact.getType(), artifact.getClassifier()); } } }
protected Set<IvyArtifactName> convertArtifacts(Set<DependencyArtifact> dependencyArtifacts) { return CollectionUtils.collect(dependencyArtifacts, new Transformer<IvyArtifactName, DependencyArtifact>() { @Override public IvyArtifactName transform(DependencyArtifact dependencyArtifact) { return new DefaultIvyArtifactName(dependencyArtifact.getName(), dependencyArtifact.getType(), getExtension(dependencyArtifact), dependencyArtifact.getClassifier()); } }); }
private boolean usesClassifier() { for (IvyArtifact artifact : artifacts) { if (artifact.getClassifier() != null) { return true; } } for (IvyDependencyInternal dependency : this.dependencies) { for (DependencyArtifact dependencyArtifact : dependency.getArtifacts()) { if (dependencyArtifact.getClassifier() != null) { return true; } } } return false; }
private void printDependencyArtifact(DependencyArtifact dependencyArtifact, OptionalAttributeXmlWriter xmlWriter) throws IOException { // TODO Use IvyArtifact here xmlWriter.startElement("artifact") .attribute("name", dependencyArtifact.getName()) .attribute("type", dependencyArtifact.getType()) .attribute("ext", dependencyArtifact.getExtension()) .attribute("m:classifier", dependencyArtifact.getClassifier()) .endElement(); }
public static void addExplicitArtifactsIfDefined(ExternalDependency moduleDependency, String artifactType, String classifier) { String actualArtifactType = artifactType; if (actualArtifactType == null) { if (classifier != null) { actualArtifactType = DependencyArtifact.DEFAULT_TYPE; } } else { moduleDependency.setTransitive(false); } if (actualArtifactType != null) { moduleDependency.addArtifact(new DefaultDependencyArtifact(moduleDependency.getName(), actualArtifactType, actualArtifactType, classifier, null)); } }
public DefaultMavenDependency(String groupId, String artifactId, String version, Collection<DependencyArtifact> artifacts) { this(groupId, artifactId, version); this.artifacts.addAll(artifacts); }
public DefaultMavenDependency(String groupId, String artifactId, String version, Collection<DependencyArtifact> artifacts, Collection<ExcludeRule> excludeRules) { this(groupId, artifactId, version, artifacts); this.excludeRules.addAll(excludeRules); }
public Collection<DependencyArtifact> getArtifacts() { return artifacts; }
private String getExtension(DependencyArtifact artifact) { return artifact.getExtension() != null ? artifact.getExtension() : artifact.getType(); }
private void addProjectDependency(ProjectDependency dependency, String confMapping) { ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(dependency); ivyDependencies.add(new DefaultIvyDependency( identifier.getGroup(), identifier.getName(), identifier.getVersion(), confMapping, dependency.isTransitive(), Collections.<DependencyArtifact>emptyList(), dependency.getExcludeRules())); }
public DefaultIvyDependency(String organisation, String module, String revision, String confMapping, boolean transitive, Collection<DependencyArtifact> artifacts) { this(organisation, module, revision, confMapping, transitive); this.artifacts.addAll(artifacts); }
public DefaultIvyDependency(String organisation, String module, String revision, String confMapping, boolean transitive, Collection<DependencyArtifact> artifacts, Collection<ExcludeRule> excludeRules) { this(organisation, module, revision, confMapping, transitive, artifacts); this.excludeRules.addAll(excludeRules); }
public Iterable<DependencyArtifact> getArtifacts() { return artifacts; }
public Set<DependencyArtifact> getArtifacts() { return artifacts; }
public void setArtifacts(Set<DependencyArtifact> artifacts) { this.artifacts = artifacts; }
public AbstractModuleDependency addArtifact(DependencyArtifact artifact) { artifacts.add(artifact); return this; }
public DependencyArtifact artifact(Closure configureClosure) { return artifact(ClosureBackedAction.of(configureClosure)); }
protected void copyTo(AbstractModuleDependency target) { super.copyTo(target); target.setArtifacts(new HashSet<DependencyArtifact>(getArtifacts())); target.setExcludeRuleContainer(new DefaultExcludeRuleContainer(getExcludeRules())); target.setTransitive(isTransitive()); }
public DefaultIvyDependency(String organisation, String module, String revision, String confMapping, Collection<DependencyArtifact> artifacts) { this(organisation, module, revision, confMapping); this.artifacts.addAll(artifacts); }