Search in sources :

Example 1 with JavaLibrary

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));
}
Also used : DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) Configuration(org.gradle.api.artifacts.Configuration) JavaLibrary(org.gradle.api.internal.java.JavaLibrary) ProcessResources(org.gradle.language.jvm.tasks.ProcessResources) Jar(org.gradle.api.tasks.bundling.Jar) JavaCompile(org.gradle.api.tasks.compile.JavaCompile)

Aggregations

Configuration (org.gradle.api.artifacts.Configuration)1 ArchivePublishArtifact (org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)1 JavaLibrary (org.gradle.api.internal.java.JavaLibrary)1 DefaultArtifactPublicationSet (org.gradle.api.internal.plugins.DefaultArtifactPublicationSet)1 Jar (org.gradle.api.tasks.bundling.Jar)1 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)1 ProcessResources (org.gradle.language.jvm.tasks.ProcessResources)1