use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class IdeaPlugin method configureIdeaModule.
private void configureIdeaModule(final Project project) {
final GenerateIdeaModule task = project.getTasks().create("ideaModule", GenerateIdeaModule.class);
task.setDescription("Generates IDEA module files (IML)");
IdeaModuleIml iml = new IdeaModuleIml(task.getXmlTransformer(), project.getProjectDir());
final IdeaModule module = instantiator.newInstance(IdeaModule.class, project, iml);
task.setModule(module);
ideaModel.setModule(module);
ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet();
}
});
conventionMapping.map("name", new Callable<String>() {
@Override
public String call() throws Exception {
return project.getName();
}
});
conventionMapping.map("contentRoot", new Callable<File>() {
@Override
public File call() throws Exception {
return project.getProjectDir();
}
});
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet();
}
});
conventionMapping.map("excludeDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet(project.getBuildDir(), project.file(".gradle"));
}
});
conventionMapping.map("pathFactory", new Callable<PathFactory>() {
@Override
public PathFactory call() throws Exception {
final PathFactory factory = new PathFactory();
factory.addPathVariable("MODULE_DIR", task.getOutputFile().getParentFile());
for (Map.Entry<String, File> entry : module.getPathVariables().entrySet()) {
factory.addPathVariable(entry.getKey(), entry.getValue());
}
return factory;
}
});
addWorker(task);
}
use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class CompareGradleBuildsPlugin method apply.
public void apply(Project project) {
project.getPluginManager().apply(ReportingBasePlugin.class);
final ReportingExtension reportingExtension = project.getExtensions().findByType(ReportingExtension.class);
project.getTasks().withType(CompareGradleBuilds.class, new Action<CompareGradleBuilds>() {
@Override
public void execute(final CompareGradleBuilds task) {
((IConventionAware) task).getConventionMapping().map("reportDir", new Callable<File>() {
@Override
public File call() throws Exception {
return reportingExtension.file(task.getName());
}
});
}
});
project.getTasks().create("compareGradleBuilds", CompareGradleBuilds.class);
}
use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class JacocoPlugin method configureTaskClasspathDefaults.
/**
* Configures the classpath for Jacoco tasks using the 'jacocoAnt' configuration. Uses the version information declared in 'toolVersion' of the Jacoco extension if no dependencies are explicitly
* declared.
*
* @param extension the JacocoPluginExtension
*/
private void configureTaskClasspathDefaults(final JacocoPluginExtension extension) {
final Configuration config = this.project.getConfigurations().getAt(ANT_CONFIGURATION_NAME);
project.getTasks().withType(JacocoBase.class, new Action<JacocoBase>() {
@Override
public void execute(JacocoBase task) {
((IConventionAware) task).getConventionMapping().map("jacocoClasspath", Callables.returning(config));
}
});
config.defaultDependencies(new Action<DependencySet>() {
@Override
public void execute(DependencySet dependencies) {
dependencies.add(project.getDependencies().create("org.jacoco:org.jacoco.ant:" + extension.getToolVersion()));
}
});
}
use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class EnvJsPlugin method apply.
public void apply(final Project project) {
project.getPluginManager().apply(RhinoPlugin.class);
project.getPluginManager().apply(ReportingBasePlugin.class);
JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
final EnvJsExtension envJsExtension = ((ExtensionAware) jsExtension).getExtensions().create(EnvJsExtension.NAME, EnvJsExtension.class);
final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), envJsExtension);
final ConventionMapping conventionMapping = ((IConventionAware) envJsExtension).getConventionMapping();
conventionMapping.map("js", new Callable<Configuration>() {
public Configuration call() {
return configuration;
}
});
conventionMapping.map("version", new Callable<String>() {
public String call() {
return EnvJsExtension.DEFAULT_DEPENDENCY_VERSION;
}
});
final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);
project.getTasks().withType(BrowserEvaluate.class, new Action<BrowserEvaluate>() {
public void execute(BrowserEvaluate task) {
((IConventionAware) task).getConventionMapping().map("evaluator", new Callable<EnvJsBrowserEvaluator>() {
public EnvJsBrowserEvaluator call() {
RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory);
File workDir = project.getProjectDir();
Factory<File> envJsFactory = new Factory<File>() {
public File create() {
return envJsExtension.getJs().getSingleFile();
}
};
return new EnvJsBrowserEvaluator(handleFactory, rhinoExtension.getClasspath(), envJsFactory, project.getGradle().getStartParameter().getLogLevel(), workDir);
}
});
}
});
}
use of org.gradle.api.internal.IConventionAware in project gradle by gradle.
the class JsHintPlugin method apply.
public void apply(Project project) {
project.getPluginManager().apply(RhinoPlugin.class);
project.getPluginManager().apply(ReportingBasePlugin.class);
JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
final JsHintExtension jsHintExtension = ((ExtensionAware) jsExtension).getExtensions().create(JsHintExtension.NAME, JsHintExtension.class);
final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), jsHintExtension);
ConventionMapping conventionMapping = ((IConventionAware) jsHintExtension).getConventionMapping();
conventionMapping.map("js", new Callable<Configuration>() {
public Configuration call() {
return configuration;
}
});
conventionMapping.map("version", new Callable<String>() {
public String call() {
return JsHintExtension.DEFAULT_DEPENDENCY_VERSION;
}
});
final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);
final ReportingExtension reportingExtension = project.getExtensions().getByType(ReportingExtension.class);
project.getTasks().withType(JsHint.class, new Action<JsHint>() {
public void execute(final JsHint task) {
task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {
public FileCollection call() {
return rhinoExtension.getClasspath();
}
});
task.getConventionMapping().map("jsHint", new Callable<FileCollection>() {
public FileCollection call() {
return jsHintExtension.getJs();
}
});
task.getConventionMapping().map("jsonReport", new Callable<File>() {
public File call() {
return reportingExtension.file(task.getName() + "/report.json");
}
});
}
});
}
Aggregations