我是Gradle的新手,我有一个项目,其结构类似于:
src
├── packageA
│ └── subPackageA
│ └── projectA
│ ├── constants
│ │ └── *.java
│ ├── database
│ │ └── *.java
│ ├── remotes
│ │ └── *.java
│ ├── rest
│ │ └── *.java
│ └── service
│ └── *.java
├── META-INF
│ └── *.xml
└── packageB
└── *.java
这是我到目前为止所学的内容所生成的构建文件:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
sourceCompatibility = 1.8
version = '1.0'
dependencies {
compile "org.hibernate:hibernate-core:5.3.7.Final"
compile "com.fasterxml.jackson.core:jackson-annotations:2.9.7"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.7"
compile "com.fasterxml.jackson.core:jackson-core:2.9.7"
compile "mysql:mysql-connector-java:5.1.47"
compile "javax.ejb:javax.ejb-api:3.2"
compile "javax.ws.rs:javax.ws.rs-api:2.0"
}
repositories {
mavenCentral()
}
//something similar I found here in stackoverflow
sourceSets.main.java {
srcDirs = ["$buildDir/mergedSources"]
}
task mergeSources() {
from "src/com/global/"
from "src/model/"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // (see https://docs.gradle.org/current/javadoc/org/gradle/api/file/DuplicatesStrategy.html#EXCLUDE)
into "$buildDir/mergedSources"
}
compileJava.dependsOn mergeSources
如何将多个软件包导入或添加到需要构建的源中?像来自packageA和packageB的.java类文件(不包括META-INF文件)一样吗?