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();
}
});
}
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();
}
});
}
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);
}
Aggregations