Search in sources :

Example 1 with MavenDependencyInternal

use of org.gradle.api.publish.maven.internal.dependencies.MavenDependencyInternal in project gradle by gradle.

the class GenerateMavenPom method doGenerate.

@TaskAction
public void doGenerate() {
    MavenPomInternal pomInternal = (MavenPomInternal) getPom();
    MavenPomFileGenerator pomGenerator = new MavenPomFileGenerator(pomInternal.getProjectIdentity(), getVersionRangeMapper());
    pomGenerator.setPackaging(pomInternal.getPackaging());
    for (MavenDependencyInternal runtimeDependency : pomInternal.getApiDependencies()) {
        pomGenerator.addApiDependency(runtimeDependency);
    }
    for (MavenDependencyInternal runtimeDependency : pomInternal.getRuntimeDependencies()) {
        pomGenerator.addRuntimeDependency(runtimeDependency);
    }
    pomGenerator.withXml(pomInternal.getXmlAction());
    pomGenerator.writeTo(getDestination());
}
Also used : MavenPomInternal(org.gradle.api.publish.maven.internal.publication.MavenPomInternal) MavenPomFileGenerator(org.gradle.api.publish.maven.internal.tasks.MavenPomFileGenerator) MavenDependencyInternal(org.gradle.api.publish.maven.internal.dependencies.MavenDependencyInternal) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with MavenDependencyInternal

use of org.gradle.api.publish.maven.internal.dependencies.MavenDependencyInternal in project gradle by gradle.

the class DefaultMavenPublication method from.

public void from(SoftwareComponent component) {
    if (this.component != null) {
        throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
    }
    this.component = (SoftwareComponentInternal) component;
    Set<PublishArtifact> seenArtifacts = Sets.newHashSet();
    Set<ModuleDependency> seenDependencies = Sets.newHashSet();
    for (UsageContext usageContext : getSortedUsageContexts()) {
        // TODO Need a smarter way to map usage to artifact classifier
        for (PublishArtifact publishArtifact : usageContext.getArtifacts()) {
            if (seenArtifacts.add(publishArtifact)) {
                artifact(publishArtifact);
            }
        }
        Set<MavenDependencyInternal> dependencies = dependenciesFor(usageContext.getUsage());
        for (ModuleDependency dependency : usageContext.getDependencies()) {
            if (seenDependencies.add(dependency)) {
                if (dependency instanceof ProjectDependency) {
                    addProjectDependency((ProjectDependency) dependency, dependencies);
                } else {
                    addModuleDependency(dependency, dependencies);
                }
            }
        }
    }
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) UsageContext(org.gradle.api.internal.component.UsageContext) InvalidUserDataException(org.gradle.api.InvalidUserDataException) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) MavenDependencyInternal(org.gradle.api.publish.maven.internal.dependencies.MavenDependencyInternal)

Aggregations

MavenDependencyInternal (org.gradle.api.publish.maven.internal.dependencies.MavenDependencyInternal)2 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 UsageContext (org.gradle.api.internal.component.UsageContext)1 MavenPomInternal (org.gradle.api.publish.maven.internal.publication.MavenPomInternal)1 MavenPomFileGenerator (org.gradle.api.publish.maven.internal.tasks.MavenPomFileGenerator)1 TaskAction (org.gradle.api.tasks.TaskAction)1