use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.
the class AbstractCodeQualityPlugin method configureExtensionRule.
private void configureExtensionRule() {
final ConventionMapping extensionMapping = conventionMappingOf(extension);
extensionMapping.map("sourceSets", Callables.returning(new ArrayList()));
extensionMapping.map("reportsDir", new Callable<File>() {
@Override
public File call() {
return project.getExtensions().getByType(ReportingExtension.class).file(getReportName());
}
});
withBasePlugin(new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
extensionMapping.map("sourceSets", new Callable<SourceSetContainer>() {
@Override
public SourceSetContainer call() {
return getJavaPluginConvention().getSourceSets();
}
});
}
});
}
use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.
the class CodeNarcPlugin method configureTaskConventionMapping.
private void configureTaskConventionMapping(Configuration configuration, CodeNarc task) {
ConventionMapping taskMapping = task.getConventionMapping();
taskMapping.map("codenarcClasspath", Callables.returning(configuration));
taskMapping.map("config", new Callable<TextResource>() {
@Override
public TextResource call() {
return extension.getConfig();
}
});
taskMapping.map("maxPriority1Violations", new Callable<Integer>() {
@Override
public Integer call() {
return extension.getMaxPriority1Violations();
}
});
taskMapping.map("maxPriority2Violations", new Callable<Integer>() {
@Override
public Integer call() {
return extension.getMaxPriority2Violations();
}
});
taskMapping.map("maxPriority3Violations", new Callable<Integer>() {
@Override
public Integer call() {
return extension.getMaxPriority3Violations();
}
});
taskMapping.map("ignoreFailures", new Callable<Boolean>() {
@Override
public Boolean call() {
return extension.isIgnoreFailures();
}
});
}
use of org.gradle.api.internal.ConventionMapping 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");
}
});
}
});
}
use of org.gradle.api.internal.ConventionMapping 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.ConventionMapping in project gradle by gradle.
the class CheckstylePlugin method configureTaskConventionMapping.
private void configureTaskConventionMapping(Configuration configuration, Checkstyle task) {
ConventionMapping taskMapping = task.getConventionMapping();
taskMapping.map("checkstyleClasspath", Callables.returning(configuration));
taskMapping.map("config", new Callable<TextResource>() {
@Override
public TextResource call() {
return extension.getConfig();
}
});
taskMapping.map("configProperties", new Callable<Map<String, Object>>() {
@Override
public Map<String, Object> call() {
return extension.getConfigProperties();
}
});
taskMapping.map("ignoreFailures", new Callable<Boolean>() {
@Override
public Boolean call() {
return extension.isIgnoreFailures();
}
});
taskMapping.map("showViolations", new Callable<Boolean>() {
@Override
public Boolean call() {
return extension.isShowViolations();
}
});
taskMapping.map("maxErrors", new Callable<Integer>() {
@Override
public Integer call() {
return extension.getMaxErrors();
}
});
taskMapping.map("maxWarnings", new Callable<Integer>() {
@Override
public Integer call() {
return extension.getMaxWarnings();
}
});
task.setConfigDir(project.provider(new Callable<File>() {
@Override
public File call() {
return extension.getConfigDir();
}
}));
}
Aggregations