eclipse执行Task提示成功但是并没有生成对应目录,请问是什么原因,谢谢?

来源:4-2 自定义任务

困惑的扎扎

2017-12-20 10:14

Eclipse使用的是 Oxygen.1a Release (4.7.1a)

Working Directory: E:\testScript
Gradle User Home: E:\gradle_cache
Gradle Distribution: Local installation at C:\gradle-4.4
Gradle Version: 4.4
Java Home: C:\Java\jdk1.8.0_152
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: makeJavaDir

:makeJavaDir
success

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed


以下是build.gradle中的代码:
apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'junit:junit:4.12'
}

def createDir={
    path->
        File dir=new File(path);
        if(!dir.exists()){
            dir.mkdirs();
        }
}

task makeJavaDir(){
    def paths=['src/main/resources','src/test/resources'];
    doFirst{
        paths.forEach(createDir);
        System.out.println("success");
        System.out.println("name:"+project.name);
    }
}

执行结果

Working Directory: E:\testScript
Gradle User Home: E:\gradle_cache
Gradle Distribution: Local installation at C:\gradle-4.4
Gradle Version: 4.4
Java Home: C:\Java\jdk1.8.0_152
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: makeJavaDir

:makeJavaDir
success

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed



写回答 关注

3回答

  • 慕码人5688569
    2018-03-24 09:50:07

    刷新一下

  • 困惑的扎扎
    2017-12-20 12:18:45

    多谢回复,已经贴出了代码

  • 贰拾叁筆劃
    2017-12-20 11:47:33

    最好贴出代码,而不只是执行结果

新一代构建工具gradle

gradle轻松入门教程,学习本课对gradle进行初步了解

39540 学习 · 98 问题

查看课程

相似问题