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);
}
}
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();
}
}
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);
}
});
}
});
}
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));
}
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);
}
Aggregations