问题
I have a multi-module-project. The structure is as follows.
root-project
------------
├── project-A
│ └── src
│ └── main
│ └── resources
│ └── myFile.xml
├── project-B
│ └── src
│ └── main
│ └── resources
│ └── myFile.xml
└── project-shared
└── src
└── main
└── resources
└── myFile.xml
(':project-A') is depends on (':project-shared') and (':project-B')
My issue is when I build (':project-A')
I have a filtertocken (to replace version number) in myFile.xml. So I need myFile.xml under project-A to be in project-A.jar file. But unfortunately project-A.jar contains myFile.xml from project-shared. I tried removing myFile.xml from project-shared and then while building project-A , the project-A jar contains myFile.xml from project-B.
I need myFile.xml file in project-A.jar whenever I build it. Is there any way ?
code is as follows:
processResources() {
java.lang.String version = project.version
filter(ReplaceTokens, tokens: ['VERSION': version])
}
dependencies {
compile project(':project-shared')
compile project(':project-B')
...
...
}
//Tried different ideas..
tasks['compileJava'].dependsOn += [processResources]
tasks['installHost'].dependsOn += [processResources]
tasks['jar'].dependsOn += [processResources]
Is there any way to exclude the following files while building project-A ?
1. project-B/src/main/resources/myFile.xml
2. project-shared/src/main/resources/myFile.xml
Or Only keep project-A/src/main/resources/myFile.xml always in project-A.jar
来源:https://stackoverflow.com/questions/33014820/gradle-exclude-file-creating-jar-in-a-subproject