use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class RhinoPlugin method apply.
public void apply(Project project) {
project.getPluginManager().apply(JavaScriptBasePlugin.class);
JavaScriptExtension jsExtension = project.getExtensions().findByType(JavaScriptExtension.class);
final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().create(RhinoExtension.NAME, RhinoExtension.class);
final Configuration configuration = addClasspathConfiguration(project.getConfigurations());
configureDefaultRhinoDependency(configuration, project.getDependencies(), rhinoExtension);
ConventionMapping conventionMapping = ((IConventionAware) rhinoExtension).getConventionMapping();
conventionMapping.map("classpath", new Callable<Configuration>() {
public Configuration call() {
return configuration;
}
});
conventionMapping.map("version", new Callable<String>() {
public String call() {
return RhinoExtension.DEFAULT_RHINO_DEPENDENCY_VERSION;
}
});
project.getTasks().withType(RhinoShellExec.class, new Action<RhinoShellExec>() {
public void execute(RhinoShellExec task) {
task.getConventionMapping().map("classpath", new Callable<FileCollection>() {
public FileCollection call() {
return rhinoExtension.getClasspath();
}
});
task.getConventionMapping().map("main", new Callable<String>() {
public String call() {
return RhinoExtension.RHINO_SHELL_MAIN;
}
});
task.setClasspath(rhinoExtension.getClasspath());
}
});
}
use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class CoffeeScriptBasePlugin method apply.
public void apply(Project project) {
project.getPluginManager().apply(RhinoPlugin.class);
JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
ExtensionContainer extensionContainer = ((ExtensionAware) jsExtension).getExtensions();
final CoffeeScriptExtension csExtension = extensionContainer.create(CoffeeScriptExtension.NAME, CoffeeScriptExtension.class);
final Configuration jsConfiguration = addJsConfiguration(project.getConfigurations(), project.getDependencies(), csExtension);
ConventionMapping conventionMapping = ((IConventionAware) csExtension).getConventionMapping();
conventionMapping.map("js", new Callable<Configuration>() {
@Override
public Configuration call() {
return jsConfiguration;
}
});
conventionMapping.map("version", new Callable<String>() {
@Override
public String call() {
return CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_VERSION;
}
});
final RhinoExtension rhinoExtension = extensionContainer.getByType(RhinoExtension.class);
project.getTasks().withType(CoffeeScriptCompile.class, new Action<CoffeeScriptCompile>() {
@Override
public void execute(CoffeeScriptCompile task) {
task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {
public FileCollection call() {
return rhinoExtension.getClasspath();
}
});
task.getConventionMapping().map("coffeeScriptJs", new Callable<FileCollection>() {
public FileCollection call() {
return csExtension.getJs();
}
});
}
});
}
use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class JacocoPlugin method addDefaultReportTask.
private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) {
final JacocoReport reportTask = project.getTasks().create("jacoco" + StringUtils.capitalize(task.getName()) + "Report", JacocoReport.class);
reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
reportTask.setDescription(String.format("Generates code coverage report for the %s task.", task.getName()));
reportTask.executionData(task);
reportTask.sourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main"));
ConventionMapping taskMapping = ((IConventionAware) reportTask).getConventionMapping();
taskMapping.getConventionValue(reportTask.getReports(), "reports", false).all(new Action<Report>() {
@Override
public void execute(final Report report) {
ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
// reportMapping.map('enabled', Callables.returning(true));
if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
reportMapping.map("destination", new Callable<File>() {
@Override
public File call() {
return new File(extension.getReportsDir(), task.getName() + "/" + report.getName());
}
});
} else {
reportMapping.map("destination", new Callable<File>() {
@Override
public File call() {
return new File(extension.getReportsDir(), task.getName() + "/" + reportTask.getName() + "." + report.getName());
}
});
}
}
});
}
use of org.gradle.api.internal.IConventionAware 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