use of org.gradle.api.distribution.Distribution in project gradle by gradle.
the class ApplicationPlugin method apply.
@Override
public void apply(final Project project) {
this.project = project;
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(DistributionPlugin.class);
addPluginConvention();
addRunTask();
addCreateScriptsTask();
Distribution distribution = ((DistributionContainer) project.getExtensions().getByName("distributions")).getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME);
((IConventionAware) distribution).getConventionMapping().map("baseName", new Callable<Object>() {
@Override
public Object call() throws Exception {
return pluginConvention.getApplicationName();
}
});
configureDistSpec(distribution.getContents());
configureInstallTask(project.getTasks().getAt(TASK_INSTALL_NAME));
}
use of org.gradle.api.distribution.Distribution in project gradle by gradle.
the class DistributionPlugin method apply.
@Override
public void apply(final ProjectInternal project) {
project.getPluginManager().apply(BasePlugin.class);
DistributionContainer distributions = project.getExtensions().create(DistributionContainer.class, "distributions", DefaultDistributionContainer.class, Distribution.class, instantiator, fileOperations);
// TODO - refactor this action out so it can be unit tested
distributions.all(new Action<Distribution>() {
@Override
public void execute(final Distribution dist) {
((IConventionAware) dist).getConventionMapping().map("baseName", new Callable<Object>() {
@Override
public Object call() throws Exception {
return dist.getName().equals(MAIN_DISTRIBUTION_NAME) ? project.getName() : String.format("%s-%s", project.getName(), dist.getName());
}
});
dist.getContents().from("src/" + dist.getName() + "/dist");
String zipTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_ZIP_NAME : dist.getName() + "DistZip";
Task zipTask = configureArchiveTask(project, zipTaskName, dist, Zip.class);
String tarTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_TAR_NAME : dist.getName() + "DistTar";
Task tarTask = configureArchiveTask(project, tarTaskName, dist, Tar.class);
addAssembleTask(project, dist, zipTask, tarTask);
addInstallTask(project, dist);
}
});
distributions.create(MAIN_DISTRIBUTION_NAME);
}
Aggregations