我的项目结构如下:
┌project
│
├── build.gradle
├── module 1
│ │
│ ├── build.gradle
│ ├── module 1.1
│ └── module 1.2
│
└── module 2
│
├── build.gradle
├── module 2.1
└── module 2.2
我的问题是我有为项目,模块1和模块2创建的构建。但我不需要它们,我只需要模块1.1,1.2,2.1和2.2的构建。
在子模块build.gradle中:
project(":modules 1") {
ext.buildables = [
project(':modules-1:modules.1.1'),
project(':modules-1:modules.1.2')]
}
project(":modules-1:modules.1.1") {
dependencies {
...
}
}
在root build.gradle中:
subprojects {
apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
对此有何想法?
编辑:
运行gradle build之后,会有以下目录结构:
┌project
│
├── build.gradle
├── build (not wanted)
├── module 1
│ │
│ ├── build (not wanted)
│ ├── build.gradle
│ ├── module 1.1
| | |
│ | └── build
│ └── module 1.2
| |
│ └── build
│
└── module 2
│
├── build (not wanted)
├── build.gradle
├── module 2.1
| |
| └── build
└── module 2.2
|
└── build
如何摆脱这些不想要的文件夹,它们都有大小为1kb的罐子。
答案 0 :(得分:4)
感谢@Opal,
在allprojects中添加以下内容,跳过空罐子。
jar {
onlyIf { !sourceSets.main.allSource.files.isEmpty() }
}
http://forums.gradle.org/gradle/topics/how_to_skip_jar_when_empty_manifest_only