Project structure:
The common.gradle is applied with different properties from the versions/*/gradle.properties files. The sourcesets are defined as
sourceSets {
main {
java {
srcDirs = ["${root}/src/main/java"] // root refers to the root directory due to the nested structure
}
resources {
srcDirs = ["${root}/src/main/resources"]
}
}
}
common.gradle also contains the following lines:
dependencies {
// ...
if (project.name == "1.16") {
implementation project(":compat:${project.name}")
include project(":compat:${project.name}")
}
}
This should make it so the compat sources are only added in the 1.16 jar.
compat/1.16/build.gradle
is a standard buildscript. The top-level buildscript simply includes the 1.15 and 1.16 buildscripts.
The problem here, is that for some reason the compat sources are included in both the 1.15 and 1.16 jars, but only if the compat/1.16/build.gradle
exists. Note that it compiles the sources directly rather than including it from the compat jar itself. If the compat build.gradle file doesn’t exist it works fine, except that the compat sources are required for the 1.16 build.
Similarly, I have tried to use this:
sourceSets {
main {
java {
if (project.name == "1.16") {
srcDirs = ["${root}/src/main/java", "${root}/compat/1.16/src/main/java"]
} else {
srcDirs = ["${root}/src/main/java"]
}
}
}
}
However this still made the files in the compat directory compile for version 1.15
The full setup can be found at https://dilaton.martmists.com/Martmists/YNet