use of org.gradle.api.file.FileCollection 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.file.FileCollection in project gradle by gradle.
the class OsgiPlugin method apply.
public void apply(final Project project) {
project.getPluginManager().apply(JavaBasePlugin.class);
final OsgiPluginConvention osgiConvention = new OsgiPluginConvention((ProjectInternal) project);
project.getConvention().getPlugins().put("osgi", osgiConvention);
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(JavaPlugin javaPlugin) {
// When creating the OSGi manifest, we must have a single view of all of the classes included in the jar.
Sync prepareOsgiClasses = project.getTasks().create("osgiClasses", Sync.class);
FileCollection classes = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main").getOutput().getClassesDirs();
File singleClassesDirectory = new File(project.getBuildDir(), "osgi-classes");
prepareOsgiClasses.setDescription("Prepares a single classes directory required for OSGi analysis.");
prepareOsgiClasses.from(classes);
prepareOsgiClasses.into(singleClassesDirectory);
Jar jarTask = (Jar) project.getTasks().getByName("jar");
jarTask.dependsOn(prepareOsgiClasses);
OsgiManifest osgiManifest = osgiConvention.osgiManifest();
osgiManifest.setClassesDir(singleClassesDirectory);
osgiManifest.setClasspath(project.getConfigurations().getByName("runtime"));
jarTask.setManifest(osgiManifest);
}
});
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class CompositeFileCollection method getFiles.
public Set<File> getFiles() {
// Gather each of the backing Sets first, so we can set the initial capacity of the LinkedHashSet
List<Set<File>> fileSets = new LinkedList<Set<File>>();
int fileCount = 0;
for (FileCollection collection : getSourceCollections()) {
Set<File> files = collection.getFiles();
fileCount += files.size();
fileSets.add(files);
}
Set<File> allFiles = new LinkedHashSet<File>(fileCount);
for (Set<File> fileSet : fileSets) {
allFiles.addAll(fileSet);
}
return allFiles;
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class GroovyBasePlugin method configureGroovydoc.
private void configureGroovydoc() {
project.getTasks().withType(Groovydoc.class, new Action<Groovydoc>() {
public void execute(final Groovydoc groovydoc) {
groovydoc.getConventionMapping().map("groovyClasspath", new Callable<Object>() {
public Object call() throws Exception {
FileCollection groovyClasspath = groovyRuntime.inferGroovyClasspath(groovydoc.getClasspath());
// Jansi is required to log errors when generating Groovydoc
ConfigurableFileCollection jansi = project.files(moduleRegistry.getExternalModule("jansi").getImplementationClasspath().getAsFiles());
return groovyClasspath.plus(jansi);
}
});
groovydoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
public Object call() throws Exception {
return new File(java(project.getConvention()).getDocsDir(), "groovydoc");
}
});
groovydoc.getConventionMapping().map("docTitle", new Callable<Object>() {
public Object call() throws Exception {
return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
}
});
groovydoc.getConventionMapping().map("windowTitle", new Callable<Object>() {
public Object call() throws Exception {
return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
}
});
}
});
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class CompositeFileCollectionTest method filterDelegatesToEachSet.
@Test
public void filterDelegatesToEachSet() {
final FileCollectionInternal filtered1 = context.mock(FileCollectionInternal.class);
final FileCollectionInternal filtered2 = context.mock(FileCollectionInternal.class);
@SuppressWarnings("unchecked") final Spec<File> spec = context.mock(Spec.class);
FileCollection filtered = collection.filter(spec);
assertThat(filtered, instanceOf(CompositeFileCollection.class));
context.checking(new Expectations() {
{
oneOf(source1).filter(spec);
will(returnValue(filtered1));
oneOf(source2).filter(spec);
will(returnValue(filtered2));
}
});
assertThat(((CompositeFileCollection) filtered).getSourceCollections(), equalTo((Iterable) toList(filtered1, filtered2)));
}
Aggregations