Search in sources :

Example 6 with ArchivePublishArtifact

use of org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact in project gradle by gradle.

the class DistributionPlugin method configureArchiveTask.

private <T extends AbstractArchiveTask> Task configureArchiveTask(Project project, String taskName, final Distribution distribution, Class<T> type) {
    final T archiveTask = project.getTasks().create(taskName, type);
    archiveTask.setDescription("Bundles the project as a distribution.");
    archiveTask.setGroup(DISTRIBUTION_GROUP);
    archiveTask.getConventionMapping().map("baseName", new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            if (distribution.getBaseName() == null || distribution.getBaseName().equals("")) {
                throw new GradleException("Distribution baseName must not be null or empty! Check your configuration of the distribution plugin.");
            }
            return distribution.getBaseName();
        }
    });
    Callable<String> baseDir = new Callable<String>() {

        @Override
        public String call() throws Exception {
            return TextUtil.minus(archiveTask.getArchiveName(), "." + archiveTask.getExtension());
        }
    };
    CopySpec childSpec = project.copySpec();
    childSpec.into(baseDir);
    childSpec.with(distribution.getContents());
    archiveTask.with(childSpec);
    ArchivePublishArtifact archiveArtifact = new ArchivePublishArtifact(archiveTask);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(archiveArtifact);
    return archiveTask;
}
Also used : CopySpec(org.gradle.api.file.CopySpec) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) GradleException(org.gradle.api.GradleException) GradleException(org.gradle.api.GradleException) Callable(java.util.concurrent.Callable)

Aggregations

ArchivePublishArtifact (org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)6 DefaultArtifactPublicationSet (org.gradle.api.internal.plugins.DefaultArtifactPublicationSet)4 Callable (java.util.concurrent.Callable)3 Configuration (org.gradle.api.artifacts.Configuration)3 War (org.gradle.api.tasks.bundling.War)2 GradleException (org.gradle.api.GradleException)1 CopySpec (org.gradle.api.file.CopySpec)1 FileCollection (org.gradle.api.file.FileCollection)1 JavaLibrary (org.gradle.api.internal.java.JavaLibrary)1 AbstractArchiveTask (org.gradle.api.tasks.bundling.AbstractArchiveTask)1 Jar (org.gradle.api.tasks.bundling.Jar)1 Tar (org.gradle.api.tasks.bundling.Tar)1 Zip (org.gradle.api.tasks.bundling.Zip)1 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)1 Jar (org.gradle.jvm.tasks.Jar)1 ProcessResources (org.gradle.language.jvm.tasks.ProcessResources)1 Ear (org.gradle.plugins.ear.Ear)1 DeploymentDescriptor (org.gradle.plugins.ear.descriptor.DeploymentDescriptor)1