Search in sources :

Example 1 with ArchivePublishArtifact

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

the class AndroidComponetCreator method createAndroidComponent.

public void createAndroidComponent(Zip bundleTask) {
    //增加一个components.android
    if (atlasExtension.getBundleConfig().isAwbBundle()) {
        Configuration compileConfiguration = project.getConfigurations().getByName(COMPILE_CONFIGURATION_NAME);
        ArchivePublishArtifact bundleArtifact = new ArchivePublishArtifact(bundleTask);
        compileConfiguration.getArtifacts().add(bundleArtifact);
    }
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)

Example 2 with ArchivePublishArtifact

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

the class PublishArtifactToFileBuildOutcomeTransformer method getTypeIdentifier.

private String getTypeIdentifier(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact;
        AbstractArchiveTask task = publishArtifact.getArchiveTask();
        if (task instanceof War) {
            return WAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Ear) {
            return EAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Jar) {
            return JAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Zip) {
            return ZIP_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Tar) {
            return TAR_ARTIFACT.getTypeIdentifier();
        } else {
            // we don't know about this kind of archive task
            return ARCHIVE_ARTIFACT.getTypeIdentifier();
        }
    } else {
        // The client may try to infer from the file extension.
        return UNKNOWN_ARTIFACT.getTypeIdentifier();
    }
}
Also used : Zip(org.gradle.api.tasks.bundling.Zip) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) Tar(org.gradle.api.tasks.bundling.Tar) AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) Ear(org.gradle.plugins.ear.Ear) War(org.gradle.api.tasks.bundling.War) Jar(org.gradle.jvm.tasks.Jar)

Example 3 with ArchivePublishArtifact

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

the class EarPlugin method setupEarTask.

private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));
    project.getTasks().withType(Ear.class, new Action<Ear>() {

        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {

                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {

                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
Also used : DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) DeploymentDescriptor(org.gradle.plugins.ear.descriptor.DeploymentDescriptor) Callable(java.util.concurrent.Callable)

Example 4 with ArchivePublishArtifact

use of org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact 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)

Example 5 with ArchivePublishArtifact

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

the class WarPlugin method apply.

public void apply(final Project project) {
    project.getPluginManager().apply(JavaPlugin.class);
    final WarPluginConvention pluginConvention = new WarPluginConvention(project);
    project.getConvention().getPlugins().put("war", pluginConvention);
    project.getTasks().withType(War.class, new Action<War>() {

        public void execute(War task) {
            task.from(new Callable() {

                public Object call() throws Exception {
                    return pluginConvention.getWebAppDir();
                }
            });
            task.dependsOn(new Callable() {

                public Object call() throws Exception {
                    return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                }
            });
            task.classpath(new Object[] { new Callable() {

                public Object call() throws Exception {
                    FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                    Configuration providedRuntime = project.getConfigurations().getByName(PROVIDED_RUNTIME_CONFIGURATION_NAME);
                    return runtimeClasspath.minus(providedRuntime);
                }
            } });
        }
    });
    War war = project.getTasks().create(WAR_TASK_NAME, War.class);
    war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
    war.setGroup(BasePlugin.BUILD_GROUP);
    ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
    configureConfigurations(project.getConfigurations());
    configureComponent(project, warArtifact);
}
Also used : DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) Configuration(org.gradle.api.artifacts.Configuration) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) War(org.gradle.api.tasks.bundling.War) FileCollection(org.gradle.api.file.FileCollection) 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