How to reference the fileset from another subproje

2019-07-17 17:47发布

问题:

I would like something like this(notice the :sub is a reference to a subproject)

task deleteJars(type: Delete) {
    ext.collection = files { genLibDir.listFiles() }
    delete ext.collection
}
task copyJars(type: Copy) { 
    from(:sub.configurations.compile) {}
    from(fixedLibDir) {}
    into genLibDir
}
copyJars.dependsOn('deleteJars')
classes.dependsOn('copyJars')

This doesn't compile however. For playframework, I need to get the jars in that other projects configuration into my lib directory for playframework to startup. How can I fix the above code?

thanks, Dean

回答1:

Should it be something like:

project(":sub").configurations.compile

?



回答2:

Don't forget to put

evaluationDependsOn('sub')

at the beginning of your main script. Otherwise, you will get error such as

 Configuration with name 'compile' not found

The reason is that generally the main project is compiled before the subproject and the compiler have trouble to find the configuration'compile' of the subproject.



标签: gradle