Search in sources :

Example 1 with DefaultDistributionContainer

use of org.gradle.api.distribution.internal.DefaultDistributionContainer in project gradle by gradle.

the class JavaLibraryDistributionPlugin method apply.

@Override
public void apply(final ProjectInternal project) {
    this.project = project;
    project.getPluginManager().apply(JavaPlugin.class);
    project.getPluginManager().apply(DistributionPlugin.class);
    DefaultDistributionContainer defaultDistributionContainer = (DefaultDistributionContainer) project.getExtensions().findByName("distributions");
    CopySpec contentSpec = defaultDistributionContainer.getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME).getContents();
    Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
    CopySpec childSpec = project.copySpec();
    childSpec.from(jar);
    childSpec.from(project.file("src/dist"));
    CopySpec libSpec = project.copySpec();
    libSpec.into("lib");
    libSpec.from(project.getConfigurations().getByName("runtime"));
    childSpec.with(libSpec);
    contentSpec.with(childSpec);
}
Also used : CopySpec(org.gradle.api.file.CopySpec) Jar(org.gradle.api.tasks.bundling.Jar) DefaultDistributionContainer(org.gradle.api.distribution.internal.DefaultDistributionContainer)

Aggregations

DefaultDistributionContainer (org.gradle.api.distribution.internal.DefaultDistributionContainer)1 CopySpec (org.gradle.api.file.CopySpec)1 Jar (org.gradle.api.tasks.bundling.Jar)1