我是靠谱客的博主 简单大地,最近开发中收集的这篇文章主要介绍file模拟tree java_Java Project.fileTree方法代码示例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

import org.gradle.api.Project; //导入方法依赖的package包/类

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() {

@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);

}

最后

以上就是简单大地为你收集整理的file模拟tree java_Java Project.fileTree方法代码示例的全部内容,希望文章能够帮你解决file模拟tree java_Java Project.fileTree方法代码示例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部