use of org.gradle.api.file.ConfigurableFileTree 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));
}
use of org.gradle.api.file.ConfigurableFileTree in project crnk-framework by crnk-project.
the class TSGeneratorPlugin method setupPackageTasks.
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().files(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);
}
use of org.gradle.api.file.ConfigurableFileTree in project atlas by alibaba.
the class AppVariantContext method getAwSourceOutputDir.
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)));
}
sourceSets.add(project.fileTree(getAwbMergeResourcesOutputDir(awbBundle)));
if (scope.getGlobalScope().getExtension().getDataBinding().isEnabled()) {
sourceSets.add(project.fileTree(getAwbClassOutputForDataBinding(awbBundle)));
}
return sourceSets.build();
}
use of org.gradle.api.file.ConfigurableFileTree in project gradle by gradle.
the class JettyRun method validateConfiguration.
public void validateConfiguration() {
// check the location of the static content/jsps etc
try {
if ((getWebAppSourceDirectory() == null) || !getWebAppSourceDirectory().exists()) {
throw new InvalidUserDataException("Webapp source directory " + (getWebAppSourceDirectory() == null ? "null" : getWebAppSourceDirectory().getCanonicalPath()) + " does not exist");
} else {
LOGGER.info("Webapp source directory = " + getWebAppSourceDirectory().getCanonicalPath());
}
} catch (IOException e) {
throw new InvalidUserDataException("Webapp source directory does not exist", e);
}
// check reload mechanic
if (!"automatic".equalsIgnoreCase(reload) && !"manual".equalsIgnoreCase(reload)) {
throw new InvalidUserDataException("invalid reload mechanic specified, must be 'automatic' or 'manual'");
} else {
LOGGER.info("Reload Mechanic: " + reload);
}
// get the web.xml file if one has been provided, otherwise assume it is in the webapp src directory
if (getWebXml() == null) {
setWebXml(new File(new File(getWebAppSourceDirectory(), "WEB-INF"), "web.xml"));
}
LOGGER.info("web.xml file = " + getWebXml());
//check if a jetty-env.xml location has been provided, if so, it must exist
if (getJettyEnvXml() != null) {
setJettyEnvXmlFile(jettyEnvXml);
try {
if (!getJettyEnvXmlFile().exists()) {
throw new InvalidUserDataException("jetty-env.xml file does not exist at location " + jettyEnvXml);
} else {
LOGGER.info(" jetty-env.xml = " + getJettyEnvXmlFile().getCanonicalPath());
}
} catch (IOException e) {
throw new InvalidUserDataException("jetty-env.xml does not exist");
}
}
setExtraScanTargets(new ArrayList<File>());
if (scanTargets != null) {
for (File scanTarget : scanTargets) {
LOGGER.info("Added extra scan target:" + scanTarget);
getExtraScanTargets().add(scanTarget);
}
}
if (scanTargetPatterns != null) {
for (ScanTargetPattern scanTargetPattern : scanTargetPatterns) {
ConfigurableFileTree files = getProject().fileTree(scanTargetPattern.getDirectory());
files.include(scanTargetPattern.getIncludes());
files.exclude(scanTargetPattern.getExcludes());
Set<File> currentTargets = getExtraScanTargets();
if (currentTargets != null && !currentTargets.isEmpty()) {
currentTargets.addAll(files.getFiles());
} else {
setExtraScanTargets(files.getFiles());
}
}
}
}
use of org.gradle.api.file.ConfigurableFileTree in project gradle by gradle.
the class GradleBuildDocumentationPlugin method applyConventions.
private void applyConventions(Project project, TaskContainer tasks, ObjectFactory objects, ProjectLayout layout, GradleDocumentationExtension extension) {
TaskProvider<Sync> stageDocs = tasks.register("stageDocs", Sync.class, task -> {
// release notes goes in the root of the docs
task.from(extension.getReleaseNotes().getRenderedDocumentation());
// DSL reference goes into dsl/
task.from(extension.getDslReference().getRenderedDocumentation(), sub -> sub.into("dsl"));
// Javadocs reference goes into javadoc/
task.from(extension.getJavadocs().getRenderedDocumentation(), sub -> sub.into("javadoc"));
// User manual goes into userguide/ (for historical reasons)
task.from(extension.getUserManual().getRenderedDocumentation(), sub -> sub.into("userguide"));
task.into(extension.getDocumentationRenderedRoot());
});
extension.getSourceRoot().convention(layout.getProjectDirectory().dir("src/docs"));
extension.getDocumentationRenderedRoot().convention(layout.getBuildDirectory().dir("docs"));
extension.getStagingRoot().convention(layout.getBuildDirectory().dir("working"));
ConfigurableFileTree css = objects.fileTree();
css.from(extension.getSourceRoot().dir("css"));
css.include("*.css");
extension.getCssFiles().from(css);
extension.getRenderedDocumentation().from(stageDocs);
Configuration runtimeClasspath = project.getConfigurations().getByName("runtimeClasspath");
Configuration sourcesPath = project.getConfigurations().create("sourcesPath");
sourcesPath.attributes(a -> {
a.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.class, Usage.JAVA_RUNTIME));
a.attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.class, Category.DOCUMENTATION));
a.attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.class, "gradle-source-folders"));
});
sourcesPath.setCanBeConsumed(false);
sourcesPath.setCanBeResolved(true);
sourcesPath.setVisible(false);
sourcesPath.extendsFrom(runtimeClasspath);
extension.getClasspath().from(runtimeClasspath);
extension.getDocumentedSource().from(sourcesPath.getIncoming().artifactView(v -> v.lenient(true)).getFiles().getAsFileTree().matching(f -> {
// Filter out any non-public APIs
f.include(PublicApi.INSTANCE.getIncludes());
f.exclude(PublicApi.INSTANCE.getExcludes());
}));
}
Aggregations