Search in sources :

Example 1 with FileCollection

use of org.gradle.api.file.FileCollection in project atlas by alibaba.

the class AwbDataBindingExportBuildInfoConfigAction method execute.

@Override
public void execute(DataBindingExportBuildInfoTask task) {
    final BaseVariantData<? extends BaseVariantOutputData> variantData = appVariantContext.getScope().getVariantData();
    task.setXmlProcessor(AwbXmlProcessor.getLayoutXmlProcessor(appVariantContext, awbBundle, dataBindingBuilder));
    task.setSdkDir(appVariantContext.getScope().getGlobalScope().getSdkHandler().getSdkFolder());
    task.setXmlOutFolder(appVariantContext.getAwbLayoutInfoOutputForDataBinding(awbBundle));
    ConventionMappingHelper.map(task, "compilerClasspath", new Callable<FileCollection>() {

        @Override
        public FileCollection call() {
            return appVariantContext.getScope().getJavaClasspath();
        }
    });
    ConventionMappingHelper.map(task, "compilerSources", new Callable<Iterable<ConfigurableFileTree>>() {

        @Override
        public Iterable<ConfigurableFileTree> call() throws Exception {
            return Iterables.filter(appVariantContext.getAwSourceOutputDir(awbBundle), new Predicate<ConfigurableFileTree>() {

                @Override
                public boolean apply(ConfigurableFileTree input) {
                    File dataBindingOut = appVariantContext.getAwbClassOutputForDataBinding(awbBundle);
                    return !dataBindingOut.equals(input.getDir());
                }
            });
        }
    });
    task.setExportClassListTo(variantData.getType().isExportDataBindingClassList() ? new File(appVariantContext.getAwbLayoutFolderOutputForDataBinding(awbBundle), "_generated.txt") : null);
    task.setPrintMachineReadableErrors(printMachineReadableErrors);
    task.setDataBindingClassOutput(appVariantContext.getAwbClassOutputForDataBinding(awbBundle));
}
Also used : ConfigurableFileTree(org.gradle.api.file.ConfigurableFileTree) FileCollection(org.gradle.api.file.FileCollection) File(java.io.File) Predicate(com.google.common.base.Predicate)

Example 2 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class JvmOptions method getManagedJvmArgs.

/**
     * @return the list of jvm args we manage explicitly, for example, max heaps size or file encoding.
     * The result is a subset of options returned by {@link #getAllImmutableJvmArgs()}
     */
public List<String> getManagedJvmArgs() {
    List<String> args = new ArrayList<String>();
    if (minHeapSize != null) {
        args.add("-Xms" + minHeapSize);
    }
    if (maxHeapSize != null) {
        args.add("-Xmx" + maxHeapSize);
    }
    FileCollection bootstrapClasspath = getBootstrapClasspath();
    if (!bootstrapClasspath.isEmpty()) {
        args.add("-Xbootclasspath:" + bootstrapClasspath.getAsPath());
    }
    // These are implemented as a system property, but don't really function like one
    // So we include it in this “no system property” set.
    formatSystemProperties(immutableSystemProperties, args);
    if (assertionsEnabled) {
        args.add("-ea");
    }
    if (debug) {
        args.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005");
    }
    return args;
}
Also used : ArrayList(java.util.ArrayList) FileCollection(org.gradle.api.file.FileCollection) DefaultConfigurableFileCollection(org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection)

Example 3 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class PmdPlugin method configureForSourceSet.

@Override
protected void configureForSourceSet(final SourceSet sourceSet, final Pmd task) {
    task.setDescription("Run PMD analysis for " + sourceSet.getName() + " classes");
    task.setSource(sourceSet.getAllJava());
    ConventionMapping taskMapping = task.getConventionMapping();
    taskMapping.map("classpath", new Callable<FileCollection>() {

        @Override
        public FileCollection call() throws Exception {
            return sourceSet.getOutput().plus(sourceSet.getCompileClasspath());
        }
    });
}
Also used : FileCollection(org.gradle.api.file.FileCollection) ConventionMapping(org.gradle.api.internal.ConventionMapping)

Example 4 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class DependencyAutoWireTaskFactoryTest method addsDependencyOnInputFiles.

@Test
public void addsDependencyOnInputFiles() {
    final TaskInternal task = context.mock(TaskInternal.class);
    final TaskInputsInternal taskInputs = context.mock(TaskInputsInternal.class);
    final FileCollection inputFiles = context.mock(FileCollection.class);
    context.checking(new Expectations() {

        {
            one(delegate).createTask(map());
            will(returnValue(task));
            allowing(task).getInputs();
            will(returnValue(taskInputs));
            allowing(taskInputs).getFiles();
            will(returnValue(inputFiles));
            one(task).dependsOn(inputFiles);
        }
    });
    assertThat(factory.createTask(map()), sameInstance(task));
}
Also used : Expectations(org.jmock.Expectations) TaskInternal(org.gradle.api.internal.TaskInternal) TaskInputsInternal(org.gradle.api.internal.TaskInputsInternal) FileCollection(org.gradle.api.file.FileCollection) Test(org.junit.Test)

Example 5 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class DefaultConfigurableFileCollectionTest method resolveAddsEachSourceObjectAndBuildDependencies.

@Test
public void resolveAddsEachSourceObjectAndBuildDependencies() {
    final FileCollectionResolveContext resolveContext = context.mock(FileCollectionResolveContext.class);
    final FileCollectionResolveContext nestedContext = context.mock(FileCollectionResolveContext.class);
    final FileCollection fileCollectionMock = context.mock(FileCollection.class);
    collection.from("file");
    collection.from(fileCollectionMock);
    context.checking(new Expectations() {

        {
            oneOf(resolveContext).push(resolverMock);
            will(returnValue(nestedContext));
            oneOf(nestedContext).add(collection.getFrom());
        }
    });
    collection.visitContents(resolveContext);
}
Also used : Expectations(org.jmock.Expectations) FileCollection(org.gradle.api.file.FileCollection) Test(org.junit.Test)

Aggregations

FileCollection (org.gradle.api.file.FileCollection)32 File (java.io.File)16 Callable (java.util.concurrent.Callable)6 ArrayList (java.util.ArrayList)5 ConventionMapping (org.gradle.api.internal.ConventionMapping)5 SimpleFileCollection (org.gradle.api.internal.file.collections.SimpleFileCollection)4 Set (java.util.Set)3 CompileOptions (com.android.build.gradle.internal.CompileOptions)2 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)2 GroovyClassLoader (groovy.lang.GroovyClassLoader)2 List (java.util.List)2 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 Configuration (org.gradle.api.artifacts.Configuration)2 FileCollectionInternal (org.gradle.api.internal.file.FileCollectionInternal)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 Predicate (com.google.common.base.Predicate)1 Injector (com.google.inject.Injector)1 Closure (groovy.lang.Closure)1