Search in sources :

Example 6 with ConfigurationPublications

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

the class JavaPlugin method addVariants.

private void addVariants(Configuration configuration, ArchivePublishArtifact jarArtifact, final JavaCompile javaCompile, final ProcessResources processResources) {
    ConfigurationPublications publications = configuration.getOutgoing();
    // Configure an implicit variant
    publications.getArtifacts().add(jarArtifact);
    publications.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, JavaPlugin.JAR_TYPE);
    // Define some additional variants
    NamedDomainObjectContainer<ConfigurationVariant> runtimeVariants = publications.getVariants();
    createVariant(runtimeVariants, "classes", JavaPlugin.CLASS_DIRECTORY, new IntermediateJavaArtifact(JavaPlugin.CLASS_DIRECTORY, javaCompile) {

        @Override
        public File getFile() {
            return javaCompile.getDestinationDir();
        }
    });
    createVariant(runtimeVariants, "resources", JavaPlugin.RESOURCES_DIRECTORY, new IntermediateJavaArtifact(JavaPlugin.RESOURCES_DIRECTORY, processResources) {

        @Override
        public File getFile() {
            return processResources.getDestinationDir();
        }
    });
}
Also used : ConfigurationVariant(org.gradle.api.artifacts.ConfigurationVariant) ConfigurationPublications(org.gradle.api.artifacts.ConfigurationPublications) File(java.io.File)

Example 7 with ConfigurationPublications

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

the class JavaPlugin method addRuntimeVariants.

private void addRuntimeVariants(Configuration configuration, ArchivePublishArtifact jarArtifact, final JavaCompile javaCompile, final ProcessResources processResources) {
    ConfigurationPublications publications = configuration.getOutgoing();
    // Configure an implicit variant
    publications.getArtifacts().add(jarArtifact);
    publications.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.JAR_TYPE);
    // Define some additional variants
    NamedDomainObjectContainer<ConfigurationVariant> runtimeVariants = publications.getVariants();
    ConfigurationVariant classesVariant = runtimeVariants.create("classes");
    classesVariant.getAttributes().attribute(USAGE_ATTRIBUTE, objectFactory.named(Usage.class, Usage.JAVA_RUNTIME_CLASSES));
    classesVariant.artifact(new IntermediateJavaArtifact(ArtifactTypeDefinition.JVM_CLASS_DIRECTORY, javaCompile) {

        @Override
        public File getFile() {
            return javaCompile.getDestinationDir();
        }
    });
    ConfigurationVariant resourcesVariant = runtimeVariants.create("resources");
    resourcesVariant.getAttributes().attribute(USAGE_ATTRIBUTE, objectFactory.named(Usage.class, Usage.JAVA_RUNTIME_RESOURCES));
    resourcesVariant.artifact(new IntermediateJavaArtifact(ArtifactTypeDefinition.JVM_RESOURCES_DIRECTORY, processResources) {

        @Override
        public File getFile() {
            return processResources.getDestinationDir();
        }
    });
}
Also used : ConfigurationVariant(org.gradle.api.artifacts.ConfigurationVariant) Usage(org.gradle.api.attributes.Usage) ConfigurationPublications(org.gradle.api.artifacts.ConfigurationPublications) File(java.io.File)

Example 8 with ConfigurationPublications

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

the class JavaPlugin method addJar.

private void addJar(Configuration configuration, ArchivePublishArtifact jarArtifact) {
    ConfigurationPublications publications = configuration.getOutgoing();
    // Configure an implicit variant
    publications.getArtifacts().add(jarArtifact);
    publications.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.JAR_TYPE);
}
Also used : ConfigurationPublications(org.gradle.api.artifacts.ConfigurationPublications)

Aggregations

ConfigurationPublications (org.gradle.api.artifacts.ConfigurationPublications)8 File (java.io.File)5 ConfigurationVariant (org.gradle.api.artifacts.ConfigurationVariant)4 Usage (org.gradle.api.attributes.Usage)3 LibraryElements (org.gradle.api.attributes.LibraryElements)2 ConfigurationVariantInternal (org.gradle.api.internal.artifacts.ConfigurationVariantInternal)2 SourceSet (org.gradle.api.tasks.SourceSet)2 ImmutableList (com.google.common.collect.ImmutableList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 Configuration (org.gradle.api.artifacts.Configuration)1 DefaultSourceSetOutput (org.gradle.api.internal.tasks.DefaultSourceSetOutput)1 JvmPluginsHelper (org.gradle.api.plugins.internal.JvmPluginsHelper)1 TaskDependency (org.gradle.api.tasks.TaskDependency)1 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)1