use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class BuildDependenciesOnlyFileCollectionResolveContext method add.
@Override
public FileCollectionResolveContext add(Object element) {
// TODO - need to sync with DefaultFileCollectionResolveContext
if (element instanceof FileCollection) {
taskContext.add(element);
} else if (element instanceof MinimalFileCollection && element instanceof Buildable) {
taskContext.add(element);
} else if (element instanceof Task) {
Task task = (Task) element;
taskContext.add(task);
} else if (element instanceof TaskOutputs) {
TaskOutputs outputs = (TaskOutputs) element;
taskContext.add(outputs.getFiles());
} else if (element instanceof Closure) {
Closure closure = (Closure) element;
Object closureResult = closure.call();
if (closureResult != null) {
add(closureResult);
}
} else if (element instanceof Callable) {
Callable callable = (Callable) element;
Object callableResult = uncheckedCall(callable);
if (callableResult != null) {
add(callableResult);
}
} else if (element instanceof Iterable) {
Iterable<?> iterable = (Iterable) element;
for (Object value : iterable) {
add(value);
}
} else if (element instanceof Object[]) {
Object[] array = (Object[]) element;
for (Object value : array) {
add(value);
}
}
// Everything else assume has no dependencies
return this;
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class CompositeFileCollection method getAsFileTrees.
@Override
protected Collection<DirectoryFileTree> getAsFileTrees() {
List<DirectoryFileTree> fileTree = new ArrayList<DirectoryFileTree>();
for (FileCollection source : getSourceCollections()) {
AbstractFileCollection collection = (AbstractFileCollection) source;
fileTree.addAll(collection.getAsFileTrees());
}
return fileTree;
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class DefaultConfiguration method registerWatchPoints.
@Override
public void registerWatchPoints(FileSystemSubset.Builder builder) {
for (Dependency dependency : allDependencies) {
if (dependency instanceof FileCollectionDependency) {
FileCollection files = ((FileCollectionDependency) dependency).getFiles();
((FileCollectionInternal) files).registerWatchPoints(builder);
}
}
super.registerWatchPoints(builder);
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class JavaCompilerArgumentsBuilder method addMainOptions.
private void addMainOptions() {
if (!includeMainOptions) {
return;
}
CompileOptions compileOptions = spec.getCompileOptions();
List<String> compilerArgs = compileOptions.getCompilerArgs();
if (!releaseOptionIsSet(compilerArgs)) {
String sourceCompatibility = spec.getSourceCompatibility();
if (sourceCompatibility != null) {
args.add("-source");
args.add(sourceCompatibility);
}
String targetCompatibility = spec.getTargetCompatibility();
if (targetCompatibility != null) {
args.add("-target");
args.add(targetCompatibility);
}
}
File destinationDir = spec.getDestinationDir();
if (destinationDir != null) {
args.add("-d");
args.add(destinationDir.getPath());
}
if (compileOptions.isVerbose()) {
args.add("-verbose");
}
if (compileOptions.isDeprecation()) {
args.add("-deprecation");
}
if (!compileOptions.isWarnings()) {
args.add("-nowarn");
}
if (compileOptions.getEncoding() != null) {
args.add("-encoding");
args.add(compileOptions.getEncoding());
}
if (compileOptions.getBootClasspath() != null) {
//TODO: move bootclasspath to platform
args.add("-bootclasspath");
args.add(compileOptions.getBootClasspath());
}
if (compileOptions.getExtensionDirs() != null) {
args.add("-extdirs");
args.add(compileOptions.getExtensionDirs());
}
if (compileOptions.isDebug()) {
if (compileOptions.getDebugOptions().getDebugLevel() != null) {
args.add("-g:" + compileOptions.getDebugOptions().getDebugLevel().trim());
} else {
args.add("-g");
}
} else {
args.add("-g:none");
}
FileCollection sourcepath = compileOptions.getSourcepath();
if (!noEmptySourcePath || sourcepath != null && sourcepath.isEmpty()) {
args.add("-sourcepath");
args.add(sourcepath == null ? "" : sourcepath.getAsPath());
}
if (spec.getSourceCompatibility() == null || JavaVersion.toVersion(spec.getSourceCompatibility()).compareTo(JavaVersion.VERSION_1_6) >= 0) {
List<File> annotationProcessorPath = spec.getAnnotationProcessorPath();
if (annotationProcessorPath == null || annotationProcessorPath.isEmpty()) {
args.add("-proc:none");
} else {
args.add("-processorpath");
args.add(Joiner.on(File.pathSeparator).join(annotationProcessorPath));
}
}
/*This is an internal option, it's used in com.sun.tools.javac.util.Names#createTable(Options options). The -XD backdoor switch is used to set it, as described in a comment
in com.sun.tools.javac.main.RecognizedOptions#getAll(OptionHelper helper). This option was introduced in JDK 7 and controls if compiler's name tables should be reused.
Without this option being set they are stored in a static list using soft references which can lead to memory pressure and performance deterioration
when using the daemon, especially when using small heap and building a large project.
Due to a bug (https://builds.gradle.org/viewLog.html?buildId=284033&tab=buildResultsDiv&buildTypeId=Gradle_Master_Performance_PerformanceExperimentsLinux) no instances of
SharedNameTable are actually ever reused. It has been fixed for JDK9 and we should consider not using this option with JDK9 as not using it will quite probably improve the
performance of compilation.
Using this option leads to significant performance improvements when using daemon and compiling java sources with JDK7 and JDK8.*/
args.add(USE_UNSHARED_COMPILER_TABLE_OPTION);
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class CompileTaskConfig method configureCompileTaskCommon.
private void configureCompileTaskCommon(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
task.setToolChain(binary.getToolChain());
task.setTargetPlatform(binary.getTargetPlatform());
task.setPositionIndependentCode(binary instanceof SharedLibraryBinarySpec);
task.includes(((HeaderExportingSourceSet) sourceSet).getExportedHeaders().getSourceDirectories());
task.includes(new Callable<List<FileCollection>>() {
public List<FileCollection> call() {
Collection<NativeDependencySet> libs = binary.getLibs((DependentSourceSet) sourceSet);
return CollectionUtils.collect(libs, new Transformer<FileCollection, NativeDependencySet>() {
public FileCollection transform(NativeDependencySet original) {
return original.getIncludeRoots();
}
});
}
});
for (String toolName : languageTransform.getBinaryTools().keySet()) {
Tool tool = binary.getToolByName(toolName);
if (tool instanceof PreprocessingTool) {
task.setMacros(((PreprocessingTool) tool).getMacros());
}
task.setCompilerArgs(tool.getArgs());
}
}
Aggregations