public List<ConfigurableFileTree> getAwSourceOutputDir(AwbBundle awbBundle) { Project project = scope.getGlobalScope().getProject(); // Build the list of source folders. ImmutableList.Builder<ConfigurableFileTree> sourceSets = ImmutableList.builder(); // then all the generated src folders. if (getAwbRClassSourceOutputDir(awbBundle) != null) { sourceSets.add(project.fileTree(getAwbRClassSourceOutputDir(awbBundle))); } if (scope.getGlobalScope().getExtension().getDataBinding().isEnabled()) { sourceSets.add(project.fileTree(getAwbClassOutputForDataBinding(awbBundle))); } return sourceSets.build(); }
private Integer findBukkitBuildToRun() throws IOException { final ConfigurableFileTree bukkitFiles = getProject().fileTree(new File(getProject().getBuildDir(), "bukkit")); bukkitFiles.include("bukkit-*.jar"); int currentLatestBuildNum = -1; for (final File bukkitFile : bukkitFiles) { final String fileName = bukkitFile.getName(); int buildNum = Integer.parseInt(fileName.substring(fileName.indexOf("-") + 1, fileName.indexOf("."))); if (buildNum > currentLatestBuildNum) { currentLatestBuildNum = buildNum; } } return currentLatestBuildNum; }
@Override protected void validate(String propertyName, Object value, Collection<String> messages) { File fileValue = (value instanceof ConfigurableFileTree) ? ((ConfigurableFileTree) value).getDir() : (File) value; if (!fileValue.exists()) { messages.add(String.format("Directory '%s' specified for property '%s' does not exist.", fileValue, propertyName)); } else if (!fileValue.isDirectory()) { messages.add(String.format("Directory '%s' specified for property '%s' is not a directory.", fileValue, propertyName)); } }
@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)); }
private FileCollection filesFor(final Algorithm algo) { return getProject().fileTree(getOutputDir(), new Action<ConfigurableFileTree>() { @Override public void execute(ConfigurableFileTree files) { files.include("**/*." + algo.toString().toLowerCase()); } }); }
/** * Create a new parser object which will loop through the lines of the file * looking for copyright notices and (potentially) update them * * @param project The Gradle project * @param extension The plugin extension with the options */ public Parser(Project project, CopyrightrPluginExtension extension) { this.logger = project.getLogger(); this.copyrightHolder = extension.getCopyrightHolder(); this.includes = extension.getIncludes(); this.excludes = extension.getExcludes(); this.dryRun = extension.getDryRun(); this.onlyReplaceFirst = extension.getOnlyReplaceFirst(); this.yearSeparator = extension.getYearSeparator(); this.failOnMissing = extension.getFailOnMissing(); // compile the patterns to ensure that they work for (String pattern : PATTERNS) { String patternFormat = String.format("%s%s%s%s", pattern, ".*", Pattern.quote(copyrightHolder), ".*$"); compiledPatterns.add(Pattern.compile(patternFormat)); logger.debug("Compiled pattern:" + Pattern.compile(patternFormat).pattern()); } String absoluteProjectPath = project.getProjectDir().getAbsolutePath(); Map<String, Object> map = new HashMap<String, Object>(); map.put(KEY_DIR, absoluteProjectPath); map.put(KEY_INCLUDES, includes); map.put(KEY_EXCLUDES, excludes); ConfigurableFileTree fileTree = project.fileTree(map); asFileTree = fileTree.getAsFileTree(); }
FileCollection getSassFiles() { if(getSrcDir().exists() == false) throw new RuntimeException("srcDir doesn't exists"); if(getSrcDir().isDirectory() == false) throw new RuntimeException("srcDir isn't directory"); ConfigurableFileTree fileTree = getProject().fileTree(getSrcDir()); if(getInclude() != null) fileTree.include(getInclude()); if(getExclude() != null) fileTree.exclude(getExclude()); return fileTree; }
@InputFiles FileCollection getInputFiles() { if(getSrcDir().exists() == false) throw new RuntimeException("srcDir doesn't exists"); if(getSrcDir().isDirectory() == false) throw new RuntimeException("srcDir isn't directory"); ConfigurableFileTree fileTree = getProject().fileTree(getSrcDir()); return fileTree; }
public void validate(String propertyName, Object value, Collection<String> messages) { File fileValue = (value instanceof ConfigurableFileTree) ? ((ConfigurableFileTree) value).getDir() : (File) value; if (!fileValue.exists()) { messages.add(String.format("Directory '%s' specified for property '%s' does not exist.", fileValue, propertyName)); } else if (!fileValue.isDirectory()) { messages.add(String.format("Directory '%s' specified for property '%s' is not a directory.", fileValue, propertyName)); } }
public ConfigurableFileTree fileTree(Object baseDir) { return getFileOperations().fileTree(baseDir); }
public ConfigurableFileTree fileTree(Object baseDir, Closure closure) { return ConfigureUtil.configure(closure, getFileOperations().fileTree(baseDir)); }
public ConfigurableFileTree fileTree(Map<String, ?> args) { return getFileOperations().fileTree(args); }
public ConfigurableFileTree builtBy(Object... tasks) { buildDependency.add(tasks); return this; }
public ConfigurableFileTree setBuiltBy(Iterable<?> tasks) { buildDependency.setValues(tasks); return this; }
@Override public ConfigurableFileTree fileTree(Object baseDir) { return fileOperations.fileTree(baseDir); }
@Override public ConfigurableFileTree fileTree(Map<String, ?> args) { return fileOperations.fileTree(args); }
@Override public ConfigurableFileTree fileTree(Object baseDir, Closure configureClosure) { return ConfigureUtil.configure(configureClosure, fileOperations.fileTree(baseDir)); }
void setupPackageTasks(Project project, Task generateTask) { final File buildDir = new File(project.getBuildDir(), "npm_compile"); final File distDir = getNpmOutputDir(project); project.getTasks().create(PublishTypescriptStubsTask.NAME, PublishTypescriptStubsTask.class); TSGeneratorConfig config = project.getExtensions().getByType(TSGeneratorConfig.class); Copy copySources = project.getTasks().create("processTypescript", Copy.class); copySources.from(config.getGenDir()); copySources.into(buildDir); copySources.dependsOn(generateTask); // copy .npmrc file from root to working directory if available final File npmrcFile = new File(project.getProjectDir(), ".npmrc"); if (npmrcFile.exists()) { copySources.getInputs().file(npmrcFile); copySources.doFirst(new Action<Task>() { @Override public void execute(Task task) { File targetFile = new File(buildDir, ".npmrc"); buildDir.mkdirs(); TypescriptUtils.copyFile(npmrcFile, targetFile); } }); } CompileTypescriptStubsTask compileTypescriptTask = project.getTasks().create(CompileTypescriptStubsTask.NAME, CompileTypescriptStubsTask.class); try { NpmInstallTask npmInstall = (NpmInstallTask) project.getTasks().getByName("npmInstall"); npmInstall.setWorkingDir(buildDir); npmInstall.dependsOn(copySources); npmInstall.getInputs().file(new File(buildDir, "package.json")); npmInstall.getOutputs().dir(new File(buildDir, "node_modules")); compileTypescriptTask.dependsOn(npmInstall); } catch (UnknownTaskException e) { LOGGER.warn("task not found, ok in testing", e); } ConfigurableFileTree fileTree = project.fileTree(buildDir); fileTree.include("package.json"); fileTree.include(".npmrc"); fileTree.include("**/*.ts"); fileTree.exclude("**/*.d.ts"); compileTypescriptTask.getInputs().files(fileTree); compileTypescriptTask.setWorkingDir(buildDir); compileTypescriptTask.getOutputs().dir(buildDir); ConfigurableFileTree assembleFileTree = project.fileTree(new File(buildDir, "src")); assembleFileTree.include("**/*.ts"); assembleFileTree.include("**/*.js"); assembleFileTree.include("**/*.js.map"); Copy assembleSources = project.getTasks().create("assembleTypescript", Copy.class); assembleSources.from(assembleFileTree); assembleSources.from(new File(buildDir, "package.json")); assembleSources.into(distDir); assembleSources.dependsOn(compileTypescriptTask); }
public ConfigurableFileTree fileTree(Object baseDir) { return fileOperations.fileTree(baseDir); }
public ConfigurableFileTree fileTree(Map<String, ?> args) { return fileOperations.fileTree(args); }
public ConfigurableFileTree fileTree(Object baseDir, Closure configureClosure) { return ConfigureUtil.configure(configureClosure, fileOperations.fileTree(baseDir)); }
public ConfigurableFileTree fileTree(Object baseDir, Closure closure) { return fileOperations.fileTree(baseDir, closure); }
public ConfigurableFileTree fileTree(Closure closure) { DeprecationLogger.nagUserOfDeprecated("fileTree(Closure)", "Use fileTree((Object){ baseDir }) to have the closure used as the file tree base directory"); return fileOperations.fileTree(closure); }
@Deprecated ConfigurableFileTree fileTree(Closure closure);
public ConfigurableFileTree fileTree(Closure closure) { DeprecationLogger.nagUserOfDeprecated("fileTree(Closure)", "Use fileTree((Object){ baseDir }) to have the closure used as the file tree base directory"); //noinspection deprecation return fileOperations.fileTree(closure); }
public ConfigurableFileTree fileTree(Object baseDir, Closure configureClosure) { return fileOperations.fileTree(baseDir, configureClosure); }
private static List<String> filesToPluginIds(ConfigurableFileTree filesTree) { return stream(filesTree).map(ExtBintrayPlugin::filenameNoExtension).collect(Collectors.<String>toList()); }
private static ConfigurableFileTree gradlePluginPropertyFiles(Project project) { val filetreeProps = new HashMap<String, String>(); filetreeProps.put("dir", "src/main/resources/META-INF/gradle-plugins"); filetreeProps.put("include", "*.properties"); return project.fileTree(filetreeProps); }