1

我有两个 gradle 模块(AB)。模块B依赖于模块A

模块A包含Copy来自相对路径的任务:

task copyStrings(type: Copy){
    from '../path/'
    into 'folder'
}

tasks.preBuild.dependsOn('copyStrings')

当我./gradlew assemble从模块A执行时,它工作得很好。

但是当我组装模块B时,gradle 找不到这样的目录,因为相对路径是从模块B目录创建的。

有没有办法为Copy任务设置工作目录?

4

1 回答 1

1

你能试试:

from project.file('../path/')

此外,不需要<<

task copyStrings(type: Copy) { 
   from '../path/' into 'folder' 
}

是你所需要的全部。在这里你可以找到一个小演示。

于 2016-12-16T12:10:44.137 回答