0

Gradle 2.13 修订版:3b427b1481e46232107303c90be7b05079b05b1c 操作系统:Linux 3.10.0-327.36.3.el7.x86_64 amd64

在 linux 中调用 clean 任务时,buildDir 路径的内容不会被删除,而在 Windows 中同样会删除 buildDir 的内容(预期行为)。什么原因 ?

代码示例

apply plugin : 'java'
ant.importBuild 'build.xml'
sourceCompatibility = 1.8
def projVersion = ant.properties['version']
def projName = "xyz"
def buildPath = "/home/test/build"
def dependencyPath = "/home/test/dependency"
buildDir = new File("$buildPath","$projName")
def serviceDirBin = new File(buildDir , 'bin')
def serviceDirConf = new File(buildDir , 'conf')
def serviceDirThirdparty = new File(buildDir , 'thirdparty')

repositories    {
        flatDir {
            dirs file("$dependencyPath"),
        }
    }


sourceSets{
    main{
        java{
            srcDir 'src'
            }
        output.classesDir 'classes'
        }
    test{
        java {
            srcDir  'src/test'
              }
        }
}

dependencies {
    /*Some compile dependencies*/
}

jar{
    destinationDir = new File(serviceDirThirdparty, 'lib')
    baseName='xyz'
    manifest {

        'Build-Timestamp': new Date().format('yyyy-dd-MM HH:mm:ss'),
        'Specification-Version': '1.0',
        'Implementation-Version': "$projVersion"
    }
}

task xyzpackager << {

    copy{
            from ("$buildPath/sf/distribution/bin")
            into file(serviceDirBin)
        }
    copy{
            from ('conf')
            into file(serviceDirConf)
        }
    copy{
            from configurations.compile
            from configurations.runtime
            into new File(serviceDirThirdparty,'lib')
        }

}


test {
    reports {
        html.enabled = false
        junitXml.enabled = true


        junitXml.destination = file("TestReport/xml")
            }
}

jar.doLast {

            delete "$buildDir/tmp","$buildDir/dependency-cache","$buildDir/classes","$buildDir/libs"
        }
compileTestJava.doLast{
delete "TestReport"
}

jar 被复制到第三方文件夹,bin/conf 文件夹还有一些其他文件。所以基本上我想在每次新构建之前删除 buildDir

4

0 回答 0