Java Examples for org.gradle.api.file.ConfigurableFileCollection

The following java examples will help you to understand the usage of org.gradle.api.file.ConfigurableFileCollection. These source code samples are taken from different open source projects.

Example 1
Project: gradle-master  File: JacocoMerge.java View source code
/**
     * Adds execution data generated by a task to the list of those to merge. Only tasks with a {@link JacocoTaskExtension} will be included; all others will be ignored.
     *
     * @param tasks one or more tasks to merge
     */
public void executionData(Task... tasks) {
    for (Task task : tasks) {
        JacocoTaskExtension extension = task.getExtensions().findByType(JacocoTaskExtension.class);
        if (extension != null) {
            ConfigurableFileCollection files = getProject().files(extension.getDestinationFile());
            files.builtBy(task);
            executionData(files);
        }
    }
}
Example 2
Project: spaghetti-master  File: ModuleBundleLookup.java View source code
private static void addFiles(Project project, Object from, Set<File> directFiles, Set<File> transitiveFiles) throws IOException {
    if (from == null) {
        return;
    }
    if (from instanceof Configuration) {
        Configuration config = (Configuration) from;
        Set<ResolvedDependency> firstLevelDependencies = config.getResolvedConfiguration().getFirstLevelModuleDependencies();
        addAllFilesFrom(firstLevelDependencies, directFiles);
        addAllFilesFromChildren(firstLevelDependencies, transitiveFiles);
    } else if (from instanceof ConfigurableFileCollection) {
        for (Object child : ((ConfigurableFileCollection) from).getFrom()) {
            addFiles(project, child, directFiles, transitiveFiles);
        }
    } else if (from instanceof FileCollection) {
        directFiles.addAll(((FileCollection) from).getFiles());
    } else if (from instanceof Collection) {
        for (Object child : ((Collection<?>) from)) {
            addFiles(project, child, directFiles, transitiveFiles);
        }
    } else if (from.getClass().isArray()) {
        for (int i = 0; i < Array.getLength(from); i++) {
            addFiles(project, Array.get(from, i), directFiles, transitiveFiles);
        }
    } else if (from instanceof Callable) {
        try {
            addFiles(project, ((Callable) from).call(), directFiles, transitiveFiles);
        } catch (Exception e) {
            throw Throwables.propagate(e);
        }
    } else if (from instanceof File) {
        directFiles.add((File) from);
    } else {
        for (File file : project.files(from)) {
            directFiles.add(file);
        }
    }
}
Example 3
Project: liferay-portal-master  File: JspCPlugin.java View source code
private void _addDependenciesJspC(Project project) {
    DependencyHandler dependencyHandler = project.getDependencies();
    Jar jar = (Jar) GradleUtil.getTask(project, JavaPlugin.JAR_TASK_NAME);
    ConfigurableFileCollection configurableFileCollection = project.files(jar);
    configurableFileCollection.builtBy(jar);
    dependencyHandler.add(CONFIGURATION_NAME, configurableFileCollection);
    SourceSet sourceSet = GradleUtil.getSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME);
    dependencyHandler.add(CONFIGURATION_NAME, sourceSet.getCompileClasspath());
}
Example 4
Project: android-platform-tools-base-master  File: TaskManager.java View source code
@Override
public ConfigurableFileCollection call() throws Exception {
    Iterable<File> filteredBootClasspath = Iterables.filter(androidBuilder.getBootClasspath(), new Predicate<File>() {

        @Override
        public boolean apply(@Nullable File file) {
            return file != null && !SdkConstants.FN_FRAMEWORK_LIBRARY.equals(file.getName());
        }
    });
    return project.files(testCompileTask.getClasspath(), testCompileTask.getOutputs().getFiles(), variantData.processJavaResourcesTask.getOutputs(), testedVariantData.processJavaResourcesTask.getOutputs(), filteredBootClasspath, // withdependencies.
    createMockableJar.getOutputFile());
}
Example 5
Project: ForgeGradle-master  File: UserBasePlugin.java View source code
@Override
protected void afterEvaluate() {
    // to guard against stupid programmers
    if (!madeDecompTasks) {
        throw new RuntimeException("THE DECOMP TASKS HAVENT BEEN MADE!! STUPID FORGEGRADLE DEVELOPER!!!! :(");
    }
    // verify runDir is set
    if (Strings.isNullOrEmpty(getExtension().getRunDir())) {
        throw new GradleConfigurationException("RunDir is not set!");
    }
    super.afterEvaluate();
    // add replacements for run configs and gradle start
    T ext = getExtension();
    replacer.putReplacement(REPLACE_CLIENT_TWEAKER, getClientTweaker(ext));
    replacer.putReplacement(REPLACE_SERVER_TWEAKER, getServerTweaker(ext));
    replacer.putReplacement(REPLACE_CLIENT_MAIN, getClientRunClass(ext));
    replacer.putReplacement(REPLACE_SERVER_MAIN, getServerRunClass(ext));
    // map configurations (only if the maven or maven publish plugins exist)
    mapConfigurations();
    // configure source replacement.
    project.getTasks().withType(TaskSourceCopy.class, new Action<TaskSourceCopy>() {

        @Override
        public void execute(TaskSourceCopy t) {
            t.replace(getExtension().getReplacements());
            t.include(getExtension().getIncludes());
        }
    });
    // add access transformers to deobf tasks
    addAtsToDeobf();
    if (ext.getMakeObfSourceJar()) {
        project.getTasks().getByName("assemble").dependsOn(TASK_SRC_JAR);
    }
    // add task depends for reobf
    if (project.getPlugins().hasPlugin("maven")) {
        project.getTasks().getByName("uploadArchives").dependsOn(TASK_REOBF);
        if (ext.getMakeObfSourceJar()) {
            project.getTasks().getByName("uploadArchives").dependsOn(TASK_SRC_JAR);
            project.getArtifacts().add("archives", project.getTasks().getByName(TASK_SRC_JAR));
        }
    }
    // add GradleStart dep
    {
        ConfigurableFileCollection col = project.files(getStartDir());
        col.builtBy(TASK_MAKE_START);
        project.getDependencies().add(CONFIG_START, col);
    }
    // TODO: do some GradleStart stuff based on the MC version?
    // run task stuff
    // Add the mod and stuff to the classpath of the exec tasks.
    final Jar jarTask = (Jar) project.getTasks().getByName("jar");
    if (this.hasClientRun()) {
        JavaExec exec = (JavaExec) project.getTasks().getByName("runClient");
        exec.classpath(project.getConfigurations().getByName("runtime"));
        exec.classpath(project.getConfigurations().getByName(CONFIG_MC));
        exec.classpath(project.getConfigurations().getByName(CONFIG_MC_DEPS));
        exec.classpath(project.getConfigurations().getByName(CONFIG_START));
        exec.classpath(jarTask.getArchivePath());
        exec.dependsOn(jarTask);
        exec.jvmArgs(getClientJvmArgs(getExtension()));
        exec.args(getClientRunArgs(getExtension()));
    }
    if (this.hasServerRun()) {
        JavaExec exec = (JavaExec) project.getTasks().getByName("runServer");
        exec.classpath(project.getConfigurations().getByName("runtime"));
        exec.classpath(project.getConfigurations().getByName(CONFIG_MC));
        exec.classpath(project.getConfigurations().getByName(CONFIG_MC_DEPS));
        exec.classpath(project.getConfigurations().getByName(CONFIG_START));
        exec.classpath(jarTask.getArchivePath());
        exec.dependsOn(jarTask);
        exec.jvmArgs(getServerJvmArgs(getExtension()));
        exec.jvmArgs(getServerRunArgs(getExtension()));
    }
    // complain about version number
    // blame cazzar if this regex doesnt work
    Pattern pattern = Pattern.compile("(?:(?:mc)?((?:\\d+)(?:.\\d+)+)-)?((?:0|[1-9][0-9]*)(?:\\.(?:0|[1-9][0-9]*))+)(?:-([\\da-z\\-]+(?:\\.[\\da-z\\-]+)*))?(?:\\+([\\da-z\\-]+(?:\\.[\\da-z\\-]+)*))?", Pattern.CASE_INSENSITIVE);
    if (!pattern.matcher(project.getVersion().toString()).matches()) {
        project.getLogger().warn("Version string '" + project.getVersion() + "' does not match SemVer specification ");
        project.getLogger().warn("You should try SemVer : http://semver.org/");
    }
}
Example 6
Project: gwt-gradle-plugin-master  File: GwtBasePlugin.java View source code
ConfigurableFileCollection getAllGwtConfigurations() {
    return allGwtConfigurations;
}