Search in sources :

Example 1 with DependencyArtifact

use of org.gradle.api.artifacts.DependencyArtifact in project gradle by gradle.

the class AbstractModuleDependency method artifact.

@Override
public DependencyArtifact artifact(Action<? super DependencyArtifact> configureAction) {
    DependencyArtifact artifact = new DefaultDependencyArtifact();
    configureAction.execute(artifact);
    artifacts.add(artifact);
    return artifact;
}
Also used : DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact)

Example 2 with DependencyArtifact

use of org.gradle.api.artifacts.DependencyArtifact in project gradle by gradle.

the class DefaultMavenPublication method addProjectDependency.

private void addProjectDependency(ProjectDependency dependency, Set<MavenDependencyInternal> dependencies) {
    ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(ModuleVersionIdentifier.class, dependency);
    dependencies.add(new DefaultMavenDependency(identifier.getGroup(), identifier.getName(), identifier.getVersion(), Collections.<DependencyArtifact>emptyList(), getExcludeRules(dependency)));
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultModuleVersionIdentifier(org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier) DefaultMavenDependency(org.gradle.api.publish.maven.internal.dependencies.DefaultMavenDependency) DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact)

Example 3 with DependencyArtifact

use of org.gradle.api.artifacts.DependencyArtifact in project gradle by gradle.

the class ModuleMetadataSpecBuilder method dependenciesOf.

private List<ModuleMetadataSpec.Dependency> dependenciesOf(UsageContext variant) {
    if (variant.getDependencies().isEmpty()) {
        return emptyList();
    }
    ArrayList<ModuleMetadataSpec.Dependency> dependencies = new ArrayList<>();
    Set<ExcludeRule> additionalExcludes = variant.getGlobalExcludes();
    VariantVersionMappingStrategyInternal versionMappingStrategy = versionMappingStrategyFor(variant);
    for (ModuleDependency moduleDependency : variant.getDependencies()) {
        if (moduleDependency.getArtifacts().isEmpty()) {
            dependencies.add(dependencyFor(moduleDependency, additionalExcludes, versionMappingStrategy, null, variant.getName()));
        } else {
            for (DependencyArtifact dependencyArtifact : moduleDependency.getArtifacts()) {
                dependencies.add(dependencyFor(moduleDependency, additionalExcludes, versionMappingStrategy, dependencyArtifact, variant.getName()));
            }
        }
    }
    return dependencies;
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) VariantVersionMappingStrategyInternal(org.gradle.api.publish.internal.versionmapping.VariantVersionMappingStrategyInternal) DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact) ArrayList(java.util.ArrayList) ExternalDependency(org.gradle.api.artifacts.ExternalDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) DefaultExcludeRule(org.gradle.api.internal.artifacts.DefaultExcludeRule) ExcludeRule(org.gradle.api.artifacts.ExcludeRule)

Example 4 with DependencyArtifact

use of org.gradle.api.artifacts.DependencyArtifact in project gradle by gradle.

the class IvyDescriptorFileGenerator method writeDependencies.

private void writeDependencies(OptionalAttributeXmlWriter xmlWriter) throws IOException {
    xmlWriter.startElement("dependencies");
    for (IvyDependencyInternal dependency : dependencies) {
        String org = dependency.getOrganisation();
        String module = dependency.getModule();
        String projectPath = dependency.getProjectPath();
        ModuleVersionIdentifier resolvedVersion = versionMappingStrategy.findStrategyForVariant(dependency.getAttributes()).maybeResolveVersion(org, module, projectPath);
        if (resolvedVersion != null) {
            org = resolvedVersion.getGroup();
            module = resolvedVersion.getName();
        }
        xmlWriter.startElement("dependency").attribute("org", org).attribute("name", module).attribute("rev", resolvedVersion != null ? resolvedVersion.getVersion() : dependency.getRevision()).attribute("conf", dependency.getConfMapping());
        if (resolvedVersion != null && isDynamicVersion(dependency.getRevision())) {
            xmlWriter.attribute("revConstraint", dependency.getRevision());
        }
        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();
    }
    for (IvyExcludeRule excludeRule : globalExcludes) {
        writeGlobalExclude(excludeRule, xmlWriter);
    }
    xmlWriter.endElement();
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) IvyDependencyInternal(org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal) DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact) ExcludeRule(org.gradle.api.artifacts.ExcludeRule) IvyExcludeRule(org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule) IvyExcludeRule(org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule)

Example 5 with DependencyArtifact

use of org.gradle.api.artifacts.DependencyArtifact in project gradle by gradle.

the class DefaultDependencyArtifactTest method testInit.

@Test
public void testInit() {
    String testName = "name";
    String testType = "type";
    String testExtension = "ext";
    String testClassifier = "classifier";
    String testUrl = "url";
    DependencyArtifact artifact = new DefaultDependencyArtifact(testName, testType, testExtension, testClassifier, testUrl);
    assertEquals(testName, artifact.getName());
    assertEquals(testType, artifact.getType());
    assertEquals(testExtension, artifact.getExtension());
    assertEquals(testClassifier, artifact.getClassifier());
    assertEquals(testUrl, artifact.getUrl());
}
Also used : DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact) Test(org.junit.Test)

Aggregations

DependencyArtifact (org.gradle.api.artifacts.DependencyArtifact)6 ExcludeRule (org.gradle.api.artifacts.ExcludeRule)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 ExternalDependency (org.gradle.api.artifacts.ExternalDependency)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)1 DefaultExcludeRule (org.gradle.api.internal.artifacts.DefaultExcludeRule)1 DefaultModuleVersionIdentifier (org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier)1 VariantVersionMappingStrategyInternal (org.gradle.api.publish.internal.versionmapping.VariantVersionMappingStrategyInternal)1 IvyDependencyInternal (org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal)1 IvyExcludeRule (org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule)1 DefaultMavenDependency (org.gradle.api.publish.maven.internal.dependencies.DefaultMavenDependency)1 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)1 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)1 Test (org.junit.Test)1