use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.
the class FindBugsPlugin method configureTaskConventionMapping.
private void configureTaskConventionMapping(Configuration configuration, FindBugs task) {
ConventionMapping taskMapping = task.getConventionMapping();
taskMapping.map("findbugsClasspath", Callables.returning(configuration));
taskMapping.map("ignoreFailures", new Callable<Boolean>() {
@Override
public Boolean call() {
return extension.isIgnoreFailures();
}
});
taskMapping.map("effort", new Callable<String>() {
@Override
public String call() {
return extension.getEffort();
}
});
taskMapping.map("reportLevel", new Callable<String>() {
@Override
public String call() {
return extension.getReportLevel();
}
});
taskMapping.map("visitors", new Callable<Collection<String>>() {
@Override
public Collection<String> call() {
return extension.getVisitors();
}
});
taskMapping.map("omitVisitors", new Callable<Collection<String>>() {
@Override
public Collection<String> call() {
return extension.getOmitVisitors();
}
});
taskMapping.map("excludeFilterConfig", new Callable<TextResource>() {
@Override
public TextResource call() {
return extension.getExcludeFilterConfig();
}
});
taskMapping.map("includeFilterConfig", new Callable<TextResource>() {
@Override
public TextResource call() {
return extension.getIncludeFilterConfig();
}
});
taskMapping.map("excludeBugsFilterConfig", new Callable<TextResource>() {
@Override
public TextResource call() {
return extension.getExcludeBugsFilterConfig();
}
});
taskMapping.map("extraArgs", new Callable<Collection<String>>() {
@Override
public Collection<String> call() {
return extension.getExtraArgs();
}
});
}
use of org.gradle.api.internal.ConventionMapping 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.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 JavaGradlePluginPlugin method createAndConfigurePluginUnderTestMetadataTask.
private PluginUnderTestMetadata createAndConfigurePluginUnderTestMetadataTask(final Project project, final GradlePluginDevelopmentExtension extension) {
final PluginUnderTestMetadata pluginUnderTestMetadataTask = project.getTasks().create(PLUGIN_UNDER_TEST_METADATA_TASK_NAME, PluginUnderTestMetadata.class);
final Configuration gradlePluginConfiguration = project.getConfigurations().detachedConfiguration(project.getDependencies().gradleApi());
ConventionMapping conventionMapping = new DslObject(pluginUnderTestMetadataTask).getConventionMapping();
conventionMapping.map("pluginClasspath", new Callable<Object>() {
public Object call() throws Exception {
FileCollection gradleApi = gradlePluginConfiguration.getIncoming().getFiles();
return extension.getPluginSourceSet().getRuntimeClasspath().minus(gradleApi);
}
});
conventionMapping.map("outputDirectory", new Callable<Object>() {
public Object call() throws Exception {
return new File(project.getBuildDir(), pluginUnderTestMetadataTask.getName());
}
});
return pluginUnderTestMetadataTask;
}
use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.
the class PlayIdeaPlugin method configureIdeaModule.
@Mutate
public void configureIdeaModule(@Path("tasks.ideaModule") GenerateIdeaModule ideaModule, @Path("binaries.playBinary") final PlayApplicationBinarySpec playApplicationBinarySpec, @Path("buildDir") final File buildDir, ConfigurationContainer configurations, final FileResolver fileResolver) {
IdeaModule module = ideaModule.getModule();
module.setScopes(buildScopes(configurations));
ConventionMapping conventionMapping = conventionMappingFor(module);
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
// TODO: Assets should probably be a source set too
Set<File> sourceDirs = Sets.newHashSet(playApplicationBinarySpec.getAssets().getAssetDirs());
return CollectionUtils.inject(sourceDirs, playApplicationBinarySpec.getInputs(), new Action<CollectionUtils.InjectionStep<Set<File>, LanguageSourceSet>>() {
@Override
public void execute(CollectionUtils.InjectionStep<Set<File>, LanguageSourceSet> step) {
step.getTarget().addAll(step.getItem().getSource().getSrcDirs());
}
});
}
});
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
// TODO: This should be modeled as a source set
return Collections.singleton(fileResolver.resolve("test"));
}
});
conventionMapping.map("singleEntryLibraries", new Callable<Map<String, Iterable<File>>>() {
@Override
public Map<String, Iterable<File>> call() throws Exception {
return ImmutableMap.<String, Iterable<File>>builder().put("COMPILE", Collections.singleton(playApplicationBinarySpec.getClasses().getClassesDir())).put("RUNTIME", playApplicationBinarySpec.getClasses().getResourceDirs()).put("TEST", Collections.singleton(new File(buildDir, "playBinary/testClasses"))).build();
}
});
module.setScalaPlatform(playApplicationBinarySpec.getTargetPlatform().getScalaPlatform());
conventionMapping.map("targetBytecodeVersion", new Callable<JavaVersion>() {
@Override
public JavaVersion call() throws Exception {
return getTargetJavaVersion(playApplicationBinarySpec);
}
});
conventionMapping.map("languageLevel", new Callable<IdeaLanguageLevel>() {
@Override
public IdeaLanguageLevel call() throws Exception {
return new IdeaLanguageLevel(getTargetJavaVersion(playApplicationBinarySpec));
}
});
ideaModule.dependsOn(playApplicationBinarySpec.getInputs());
ideaModule.dependsOn(playApplicationBinarySpec.getAssets());
}
Aggregations