use of org.gradle.api.internal.java.JavaLibrary in project gradle by gradle.
the class JavaPlugin method configureArchivesAndComponent.
private void configureArchivesAndComponent(Project project, JavaPluginConvention pluginConvention) {
Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
jar.setDescription("Assembles a jar archive containing the main classes.");
jar.setGroup(BasePlugin.BUILD_GROUP);
jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());
ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
Configuration apiElementConfiguration = project.getConfigurations().getByName(API_ELEMENTS_CONFIGURATION_NAME);
Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);
Configuration runtimeElementsConfiguration = project.getConfigurations().getByName(RUNTIME_ELEMENTS_CONFIGURATION_NAME);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
JavaCompile javaCompile = (JavaCompile) project.getTasks().getByPath(COMPILE_JAVA_TASK_NAME);
ProcessResources processResources = (ProcessResources) project.getTasks().getByPath(PROCESS_RESOURCES_TASK_NAME);
addVariants(apiElementConfiguration, jarArtifact, javaCompile, processResources);
addVariants(runtimeConfiguration, jarArtifact, javaCompile, processResources);
addVariants(runtimeElementsConfiguration, jarArtifact, javaCompile, processResources);
project.getComponents().add(new JavaLibrary(project.getConfigurations(), jarArtifact));
}
Aggregations