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);
pluginUnderTestMetadataTask.setGroup(PLUGIN_DEVELOPMENT_GROUP);
pluginUnderTestMetadataTask.setDescription(PLUGIN_UNDER_TEST_METADATA_TASK_DESCRIPTION);
final Configuration gradlePluginConfiguration = project.getConfigurations().detachedConfiguration(project.getDependencies().gradleApi());
ConventionMapping conventionMapping = new DslObject(pluginUnderTestMetadataTask).getConventionMapping();
conventionMapping.map("pluginClasspath", new Callable<Object>() {
public Object call() {
FileCollection gradleApi = gradlePluginConfiguration.getIncoming().getFiles();
return extension.getPluginSourceSet().getRuntimeClasspath().minus(gradleApi);
}
});
conventionMapping.map("outputDirectory", new Callable<Object>() {
public Object call() {
return new File(project.getBuildDir(), pluginUnderTestMetadataTask.getName());
}
});
return pluginUnderTestMetadataTask;
}
use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.
the class JavaBasePlugin method configureSourceSetDefaults.
private BridgedBinaries configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
final Project project = pluginConvention.getProject();
final List<ClassDirectoryBinarySpecInternal> binaries = Lists.newArrayList();
pluginConvention.getSourceSets().all(new Action<SourceSet>() {
public void execute(final SourceSet sourceSet) {
ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();
ConfigurationContainer configurations = project.getConfigurations();
defineConfigurationsForSourceSet(sourceSet, configurations);
definePathsForSourceSet(sourceSet, outputConventionMapping, project);
createProcessResourcesTaskForBinary(sourceSet, sourceSet.getResources(), project);
createCompileJavaTaskForBinary(sourceSet, sourceSet.getJava(), project);
createBinaryLifecycleTask(sourceSet, project);
DefaultComponentSpecIdentifier binaryId = new DefaultComponentSpecIdentifier(project.getPath(), sourceSet.getName());
ClassDirectoryBinarySpecInternal binary = instantiator.newInstance(DefaultClassDirectoryBinarySpec.class, binaryId, sourceSet, javaToolChain, DefaultJavaPlatform.current(), instantiator, taskFactory);
Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, binaryId.child("java"), sourceSet.getJava(), compileClasspath);
JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, binaryId.child("resources"), sourceSet.getResources());
binary.addSourceSet(javaSourceSet);
binary.addSourceSet(resourceSet);
attachTasksToBinary(binary, sourceSet, project);
binaries.add(binary);
}
});
return new BridgedBinaries(binaries);
}
use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.
the class OsgiPluginConvention method createDefaultOsgiManifest.
private OsgiManifest createDefaultOsgiManifest() {
OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
final OsgiHelper osgiHelper = new OsgiHelper();
mapping.map("version", new Callable<Object>() {
public Object call() throws Exception {
return osgiHelper.getVersion(project.getVersion().toString());
}
});
mapping.map("name", new Callable<Object>() {
public Object call() throws Exception {
return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
}
});
mapping.map("symbolicName", new Callable<Object>() {
public Object call() throws Exception {
return osgiHelper.getBundleSymbolicName(project);
}
});
return osgiManifest;
}
use of org.gradle.api.internal.ConventionMapping 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.ConventionMapping 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();
}
});
}
});
}
Aggregations