【问题标题】:Gradle copy method not working when $buildDir.parent is used使用 $buildDir.parent 时 Gradle 复制方法不起作用
【发布时间】:2017-03-25 02:16:22
【问题描述】:

我需要在集成测试之前执行复制任务,这就是我的做法。

    println "project dir is" +  "${buildDir.parent}"//this line prints the path of the directory fine when i run the script

    //here is my copy method which needs to run before the test task
    test.doFirst {
        copy {
            from '${buildDir.parent}/test/xx.xml'

            into '${buildDir.parent}/build/classes/test'

             }
        }

下面是我运行 gradle test 时控制台上的输出:

输出:项目目录为C:\Users\xxx\git\xyz\xyz\xxx

但是,当我运行测试任务时,文件没有被复制

请帮忙!

【问题讨论】:

  • 您在谈论文件,但您只是想复制一个文件 xx.xml。对吗?
  • doFirst中有很多copy方法,但都是类似的copy方法,所以为了方便阅读,我只贴了其中一种方法。
  • @SanDroid 已更正!

标签: gradle build.gradle


【解决方案1】:

解决了!我使用的是不支持字符串插值的单引号。

参考:彼得·尼德维瑟Gradle Single vs Double Quotes

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多