Java Code Examples for org.gradle.api.file.FileCollection

The following examples show how to use org.gradle.api.file.FileCollection. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public MinimalJavaCompileOptions(final CompileOptions compileOptions) {
    FileCollection sourcepath = compileOptions.getSourcepath();
    this.sourcepath = sourcepath == null ? null : ImmutableList.copyOf(sourcepath.getFiles());
    this.compilerArgs = Lists.newArrayList(compileOptions.getAllCompilerArgs());
    this.encoding = compileOptions.getEncoding();
    this.bootClasspath = DeprecationLogger.whileDisabled(new Factory<String>() {
        @Nullable
        @Override
        @SuppressWarnings("deprecation")
        public String create() {
            return compileOptions.getBootClasspath();
        }
    });
    this.extensionDirs = compileOptions.getExtensionDirs();
    this.forkOptions = compileOptions.getForkOptions();
    this.debugOptions = compileOptions.getDebugOptions();
    this.debug = compileOptions.isDebug();
    this.deprecation = compileOptions.isDeprecation();
    this.failOnError = compileOptions.isFailOnError();
    this.listFiles = compileOptions.isListFiles();
    this.verbose = compileOptions.isVerbose();
    this.warnings = compileOptions.isWarnings();
    this.annotationProcessorGeneratedSourcesDirectory = compileOptions.getAnnotationProcessorGeneratedSourcesDirectory();
}
 
Example 2
Source Project: atlas   Source File: AtlasDexMerger.java    License: Apache License 2.0 6 votes vote down vote up
public AtlasDexMerger(DexingType dexingType, FileCollection mainDexListFile, ErrorReporter errorReporter, DexMergerTool dexMerger, int minSdkVersion, boolean isDebuggable, AppVariantOutputContext appVariantOutputContext) {
    this.dexingType = dexingType;
    this.mainDexListFile = mainDexListFile;
    this.dexMerger = dexMerger;
    this.minSdkVersion = minSdkVersion;
    this.isDebuggable = isDebuggable;
    this.logger= LoggerWrapper.getLogger(getClass());
    Preconditions.checkState(
            (dexingType == DexingType.LEGACY_MULTIDEX) == (mainDexListFile != null),
            "Main dex list must only be set when in legacy multidex");
    this.errorReporter = errorReporter;
    this.variantOutputContext = appVariantOutputContext;
     outputHandler =
            new ParsingProcessOutputHandler(
                    new ToolOutputParser(new DexParser(), Message.Kind.ERROR, logger),
                    new ToolOutputParser(new DexParser(), logger),
                    errorReporter);

}
 
Example 3
public void convertInto(Object element, Collection<? super MinimalFileCollection> result, FileResolver resolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsMinimalFileCollections());
    } else if (element instanceof MinimalFileCollection) {
        MinimalFileCollection collection = (MinimalFileCollection) element;
        result.add(collection);
    } else if (element instanceof FileCollection) {
        throw new UnsupportedOperationException(String.format("Cannot convert instance of %s to MinimalFileCollection", element.getClass().getSimpleName()));
    } else if (element instanceof TaskDependency) {
        // Ignore
        return;
    } else {
        result.add(new ListBackedFileSet(resolver.resolve(element)));
    }
}
 
Example 4
private Object prepareValue(Object value) {
    while (true) {
        if (value instanceof Callable) {
            Callable callable = (Callable) value;
            try {
                value = callable.call();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        } else if (value instanceof Closure) {
            Closure closure = (Closure) value;
            value = closure.call();
        } else if (value instanceof FileCollection) {
            FileCollection fileCollection = (FileCollection) value;
            return fileCollection.getFiles();
        } else {
            return avoidGString(value);
        }
    }
}
 
Example 5
Source Project: gradle-modules-plugin   Source File: MergeClassesHelper.java    License: MIT License 5 votes vote down vote up
public FileCollection getMergeAdjustedClasspath(FileCollection classpath) {
    if (!isMergeRequired()) {
        return classpath;
    }

    Set<File> files = new HashSet<>(classpath.getFiles());
    allCompileTaskStream().map(AbstractCompile::getDestinationDir).forEach(files::remove);
    files.add(helper().getMergedDir());
    return project.files(files.toArray());
}
 
Example 6
/**
 * Returns the set of binary test results to include in the report.
 */
@InputFiles @SkipWhenEmpty
public FileCollection getTestResultDirs() {
    UnionFileCollection dirs = new UnionFileCollection();
    for (Object result : results) {
        addTo(result, dirs);
    }
    return dirs;
}
 
Example 7
public static NotationParser<Object, Dependency> parser(Instantiator instantiator, DefaultProjectDependencyFactory dependencyFactory, ClassPathRegistry classPathRegistry, FileLookup fileLookup) {
    return NotationParserBuilder
            .toType(Dependency.class)
            .fromCharSequence(new DependencyStringNotationParser<DefaultExternalModuleDependency>(instantiator, DefaultExternalModuleDependency.class))
            .parser(new DependencyMapNotationParser<DefaultExternalModuleDependency>(instantiator, DefaultExternalModuleDependency.class))
            .fromType(FileCollection.class, new DependencyFilesNotationParser(instantiator))
            .fromType(Project.class, new DependencyProjectNotationParser(dependencyFactory))
            .fromType(DependencyFactory.ClassPathNotation.class, new DependencyClassPathNotationParser(instantiator, classPathRegistry, fileLookup.getFileResolver()))
            .invalidNotationMessage("Comprehensive documentation on dependency notations is available in DSL reference for DependencyHandler type.")
            .toComposite();
}
 
Example 8
public SerializableCoffeeScriptCompileSpec(File coffeeScriptJs, File destinationDir, FileCollection source, CoffeeScriptCompileOptions options) {
    this.coffeeScriptJs = coffeeScriptJs;
    this.destinationDir = destinationDir;
    this.source = new LinkedList<RelativeFile>();
    this.options = options;

    toRelativeFiles(source, this.source);
}
 
Example 9
public FileCollection resolve() {
    try {
        walker.add(queue);
        return new UnionFileCollection(walker.findValues());
    } finally {
        queue.clear();
    }
}
 
Example 10
public Set<File> getFiles() {
    Set<File> files = new LinkedHashSet<File>();
    for (FileCollection collection : getSourceCollections()) {
        files.addAll(collection.getFiles());
    }
    return files;
}
 
Example 11
Source Project: app-gradle-plugin   Source File: StageAppYamlExtension.java    License: Apache License 2.0 5 votes vote down vote up
/** This method is purely for incremental build calculations. */
@Optional
@InputFiles
public FileCollection getExtraFilesDirectoriesAsInputFiles() {
  if (extraFilesDirectories == null) {
    return null;
  }
  FileCollection files = project.files();
  for (File directory : extraFilesDirectories) {
    files = files.plus(project.fileTree(directory));
  }
  return files;
}
 
Example 12
private void addSourceSet(FileCollection sources, Project project, String sourceSet) {
	JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
	SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet);
	sources.add(project.files(mainSourceSet.getOutput().getResourcesDir()))
		.plus(project.files(mainSourceSet.getOutput().getClassesDirs()))
		.plus(project.files(mainSourceSet.getAllSource().getSrcDirs()));
}
 
Example 13
Source Project: pygradle   Source File: DependencyOrder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a set of configuration files in the tree post-order,
 * or sorted, or in the original insert order.
 *
 * Attempt to collect dependency tree post-order and fall back to
 * sorted or insert order.
 * If sorted is false, it will always return the original insert order.
 */
public static Collection<File> getConfigurationFiles(FileCollection files, boolean sorted) {
    if (sorted && (files instanceof Configuration)) {
        try {
            return DependencyOrder.configurationPostOrderFiles((Configuration) files);
        } catch (Throwable e) {
            // Log and fall back to old style installation order as before.
            logger.lifecycle("***** WARNING: ${ e.message } *****");
        }
    }
    return sorted
        ? files.getFiles().stream().sorted().collect(Collectors.toSet())
        : files.getFiles();
}
 
Example 14
Source Project: pushfish-android   Source File: JsHint.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@InputFiles
public FileCollection getRhinoClasspath() {
    return getProject().files(rhinoClasspath);
}
 
Example 15
Source Project: playframework   Source File: PlayApplicationPlugin.java    License: Apache License 2.0 4 votes vote down vote up
FileCollection getChangingArtifacts() {
    return new FilterByProjectComponentTypeFileCollection(configuration, true);
}
 
Example 16
protected FileCollection createFileCollection(File file, String fileDescription) {
    return new FileCollectionAdapter(new ValidatingFileSet(file, getComponent().getName(), fileDescription));
}
 
Example 17
Source Project: pushfish-android   Source File: JsHint.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@InputFiles
public FileCollection getJsHint() {
    return getProject().files(jsHint);
}
 
Example 18
Source Project: Pushjet-Android   Source File: JettyRun.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Returns the classpath for the web application.
 */
@InputFiles
public FileCollection getClasspath() {
    return classpath;
}
 
Example 19
Source Project: japicmp-gradle-plugin   Source File: JapicmpTask.java    License: Apache License 2.0 4 votes vote down vote up
@CompileClasspath
public FileCollection getNewClasspath() {
    return newClasspath;
}
 
Example 20
Source Project: pushfish-android   Source File: JavaExec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@InputFiles
public FileCollection getClasspath() {
    return javaExecHandleBuilder.getClasspath();
}
 
Example 21
public FileCollection getSource() {
    return source;
}
 
Example 22
public FileCollection getSource() {
    return source;
}
 
Example 23
public FileCollection getDirs() {
    return dirs;
}
 
Example 24
public FileCollection getRuntimeFiles() {
    return empty();
}
 
Example 25
public FileCollection getLinkFiles() {
    return createFileCollection(getStaticLibraryFile(), "Static library file");
}
 
Example 26
public FileCollection getBootstrapClasspath() {
    return bootstrapClasspath;
}
 
Example 27
Source Project: Pushjet-Android   Source File: Compile.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected void compile() {
    FileTree source = getSource();
    FileCollection classpath = getClasspath();

    performCompilation(source, classpath, cleaningCompiler);
}
 
Example 28
public void setDescriptorFile(FileCollection descriptorFile) {
    this.descriptorFile = descriptorFile;
}
 
Example 29
@InputFiles
public FileCollection getRhinoClasspath() {
    return getProject().files(rhinoClasspath);
}
 
Example 30
Source Project: Pushjet-Android   Source File: JavaExec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@InputFiles
public FileCollection getBootstrapClasspath() {
    return javaExecHandleBuilder.getBootstrapClasspath();
}