diff --git a/build.gradle b/build.gradle index a207eaf5d..22edc45a4 100644 --- a/build.gradle +++ b/build.gradle @@ -18,8 +18,13 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } + withJavadocJar() + withSourcesJar() +} archivesBaseName = "quilt-loader" version = project.quilt_loader @@ -59,11 +64,6 @@ allprojects { } } } - java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - } - } } sourceSets { @@ -73,69 +73,35 @@ sourceSets { } configurations { - include { - transitive = false - } + include + development - implementation { - extendsFrom include - } - - development { - transitive = false - } - - api { - extendsFrom development - } + compileClasspath.extendsFrom localImplementation + runtimeClasspath.extendsFrom localImplementation + testImplementation.extendsFrom localImplementation + localImplementation.extendsFrom include } dependencies { - // Non-"include"d dependencies must be added to the LoaderLibrary class as well. - api "org.ow2.asm:asm:${project.asm}" - api "org.ow2.asm:asm-analysis:${project.asm}" - api "org.ow2.asm:asm-commons:${project.asm}" - api "org.ow2.asm:asm-tree:${project.asm}" - api "org.ow2.asm:asm-util:${project.asm}" - - api("net.fabricmc:sponge-mixin:${project.sponge_mixin}") { - exclude module: 'launchwrapper' - exclude module: 'guava' - } - api "net.fabricmc:tiny-mappings-parser:${project.tiny_mappings_parser}" - api "net.fabricmc:tiny-remapper:${project.tiny_remapper}" - api "net.fabricmc:access-widener:${project.access_widener}" - - /*include*/ api "org.quiltmc:quilt-json5:${project.quilt_json5}" - include "org.quiltmc:quilt-loader-sat4j:${project.quilt_loader_sat4j}" - - include "org.quiltmc.quilt-config.serializers:toml:${project.quilt_config}" - include "org.quiltmc.quilt-config.serializers:json5:${project.quilt_config}" - api "org.quiltmc:quilt-config:${project.quilt_config}" - - include "com.electronwill.night-config:core:${project.night_config}" - include "com.electronwill.night-config:toml:${project.night_config}" - shadow "com.electronwill.night-config:core:${project.night_config}" - shadow "com.electronwill.night-config:toml:${project.night_config}" - - development "io.github.llamalad7:mixinextras-fabric:$mixin_extras" + include project(path: ':dependencies', configuration: 'include') + development project(path: ':dependencies', configuration: 'development') // also must update in minecraft AND minecraft test compileOnly "org.quiltmc.chasm:chasm:${project.quilt_chasm}" compileOnly "org.quiltmc.chasm:chassembly:${project.quilt_chasm}" - shadow "org.quiltmc.quilt-config.serializers:toml:${project.quilt_config}" - shadow "org.quiltmc.quilt-config.serializers:json5:${project.quilt_config}" - shadow "org.quiltmc.parsers:json:${project.quilt_parsers}" - include "org.quiltmc.parsers:json:${project.quilt_parsers}" - include "com.unascribed:flexver-java:${project.flexver}" - shadow "com.unascribed:flexver-java:${project.flexver}" - testCompileOnly "org.jetbrains:annotations:${project.annotations}" // Unit testing testImplementation(platform("org.junit:junit-bom:${project.junit_bom}")) testImplementation("org.junit.jupiter:junit-jupiter") + + /*api*/ localImplementation project(':dependencies') +} + +def javaComponent = components.java as AdhocComponentWithVariants +javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { + skip() } test { @@ -179,17 +145,6 @@ processResources { } } -java { - sourceCompatibility = 8 - targetCompatibility = 8 - withJavadocJar() - withSourcesJar() -} - -compileJava { - options.release.set(8) -} - jar { enabled = false // Set the classifier to fix gradle task validation confusion. @@ -305,8 +260,6 @@ task testJar(type: Jar) { from sourceSets.test.output } - - task copyJson() { def inJson = file('build/resources/main/quilt_installer.json') //def inLwJson = file('src/main/resources/fabric-installer.launchwrapper.json') @@ -327,14 +280,13 @@ tasks.build.dependsOn "copyJson" tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - - // Target JDK 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release.set(8) - } } javadoc { + javadocTool.set javaToolchains.javadocToolFor { + languageVersion = JavaLanguageVersion.of(17) + } + options { if (file("README.html").exists()) { overview = "README.html" @@ -379,20 +331,20 @@ allprojects { } } -// Causes more trouble than its worth -tasks.withType(GenerateModuleMetadata) { - enabled = false +[configurations.runtimeElements, configurations.apiElements].each { configuration -> + configuration.outgoing.artifacts.clear() + artifacts { + add(configuration.name, proguardFile) { + builtBy proguardJar + } + } } publishing { publications { mavenJava(MavenPublication) { // add all the jars that should be included when publishing to maven - artifact(proguardFile) { - builtBy proguardJar - } - artifact(sourcesJar) - artifact javadocJar + from components.java artifact(file('build/resources/main/quilt_installer.json')) { builtBy processResources builtBy copyJson @@ -400,42 +352,6 @@ publishing { // artifact(file('src/main/resources/fabric-installer.launchwrapper.json')) { // builtBy copyJson // classifier = "launchwrapper" -// } - - // Manually inject the dependencies into the final POM. - // This allows for use without Loom in projects that don't need it. - // - // This is done this way to avoid including dependencies that are - // shaded in, as Gradle seems to provide no clean way of excluding - // dependencies from the final POM. - // - // Note: This only uses the `api` configuration to determine what is - // fine to include, and does not respect exclusions. A more advanced - // implementation that excludes the `include` configuration from - // runtime & compile classpaths would likely prove to be better if - // Quilt ever needs to have dependencies that aren't to be shaded nor - // passed through to the application. - // TODO: disabled until Loom can properly handle this. -// pom.withXml { -// final def dependenciesNode = asNode().appendNode("dependencies") -// -// for (final def dep : configurations.api.allDependencies) { -// // Tests for an external dependency. -// // Provides a guarantee that the needed metadata is present. -// if (dep instanceof ExternalDependency) { -// // Inject the dependency metadata. -// final def dependencyNode = dependenciesNode.appendNode("dependency") -// -// dependencyNode.appendNode("groupId", dep.group) -// dependencyNode.appendNode("artifactId", dep.name) -// dependencyNode.appendNode("version", dep.version) -// -// // Note: If ever retrofitted to include the runtime classpath, -// // change this to use the runtime scope if the dependency is not -// // present in the compile classpath. -// dependencyNode.appendNode("scope", "compile") -// } -// } // } } } diff --git a/dependencies/build.gradle b/dependencies/build.gradle new file mode 100644 index 000000000..398232f9d --- /dev/null +++ b/dependencies/build.gradle @@ -0,0 +1,113 @@ +plugins { + id 'maven-publish' + id 'java' +} + +base.archivesName.set 'quilt-loader-dependencies' +version = rootProject.version +group = rootProject.group + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +def ENV = System.getenv() + +configurations { + development { + transitive = false + canBeConsumed = true + } + + published { + extendsFrom development + } + + runtimeElements { + extendsFrom published + outgoing.artifacts.clear() + outgoing.variants.clear() + } + apiElements { + extendsFrom published + outgoing.artifacts.clear() + outgoing.variants.clear() + } + + include { + transitive = false + } +} + +[configurations.runtimeElements, configurations.apiElements].each { + // included in quilt loader and not relocated + it.exclude(group: 'org.quiltmc.quilt-config.serializers', module: 'toml') + it.exclude(group: 'org.quiltmc.quilt-config.serializers', module: 'json5') +} + +dependencies { + // Non-"include"d dependencies must be added to the LoaderLibrary class as well. + published "org.ow2.asm:asm:${project.asm}" + published "org.ow2.asm:asm-analysis:${project.asm}" + published "org.ow2.asm:asm-commons:${project.asm}" + published "org.ow2.asm:asm-tree:${project.asm}" + published "org.ow2.asm:asm-util:${project.asm}" + + published("net.fabricmc:sponge-mixin:${project.sponge_mixin}") { + exclude module: 'launchwrapper' + exclude module: 'guava' + } + published "net.fabricmc:tiny-mappings-parser:${project.tiny_mappings_parser}" + published "net.fabricmc:tiny-remapper:${project.tiny_remapper}" + published "net.fabricmc:access-widener:${project.access_widener}" + + /*include*/ published "org.quiltmc:quilt-json5:${project.quilt_json5}" + published "org.quiltmc:quilt-config:${project.quilt_config}" + + development "io.github.llamalad7:mixinextras-fabric:$mixin_extras" + + include "org.quiltmc:quilt-loader-sat4j:${project.quilt_loader_sat4j}" + + include "org.quiltmc.quilt-config.serializers:toml:${project.quilt_config}" + include "org.quiltmc.quilt-config.serializers:json5:${project.quilt_config}" + + include "com.electronwill.night-config:core:${project.night_config}" + include "com.electronwill.night-config:toml:${project.night_config}" + + include "org.quiltmc.parsers:json:${project.quilt_parsers}" + include "com.unascribed:flexver-java:${project.flexver}" +} + +publishing { + publications { + maven(MavenPublication) { + artifactId project.archivesBaseName + from components.java + } + } + + repositories { + if (ENV.MAVEN_URL) { + maven { + url ENV.MAVEN_URL + credentials { + username ENV.MAVEN_USERNAME + password ENV.MAVEN_PASSWORD + } + } + } else if (ENV.SNAPSHOTS_URL) { + maven { + url ENV.SNAPSHOTS_URL + + credentials { + username ENV.SNAPSHOTS_USERNAME + password ENV.SNAPSHOTS_PASSWORD + } + } + } else { + mavenLocal() + } + } +} \ No newline at end of file diff --git a/junit/build.gradle b/junit/build.gradle index 914adfa1c..1de090269 100644 --- a/junit/build.gradle +++ b/junit/build.gradle @@ -2,24 +2,33 @@ plugins { id("maven-publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } + withSourcesJar() +} archivesBaseName = "quilt-loader-junit" version = rootProject.version group = rootProject.group def ENV = System.getenv() -compileJava { - options.release.set(8) -} repositories { mavenCentral() } +configurations { + compileClasspath.extendsFrom localImplementation + runtimeClasspath.extendsFrom localImplementation + testImplementation.extendsFrom localImplementation +} + dependencies { api project(":") + localImplementation project(':dependencies') + localImplementation project(path: ':dependencies', configuration: 'include') api platform("org.junit:junit-bom:5.9.2") api "org.junit.jupiter:junit-jupiter-engine" @@ -30,16 +39,8 @@ dependencies { compileOnly "org.quiltmc.chasm:chasm:${project.quilt_chasm}" } -java { - withSourcesJar() -} - tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = 8 - } } publishing { diff --git a/minecraft-test/build.gradle b/minecraft-test/build.gradle index 3c7be82af..0fd4ac5fc 100644 --- a/minecraft-test/build.gradle +++ b/minecraft-test/build.gradle @@ -6,8 +6,12 @@ plugins { id("fabric-loom") version "0.10-SNAPSHOT" } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + repositories { maven { url = "https://maven.quiltmc.org/repository/release" @@ -39,13 +43,6 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = 8 - } } spotless { diff --git a/minecraft/build.gradle b/minecraft/build.gradle index 2a15e0f6a..ebac2fe81 100644 --- a/minecraft/build.gradle +++ b/minecraft/build.gradle @@ -1,8 +1,7 @@ -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -compileJava { - options.release.set(8) +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } } repositories { @@ -13,8 +12,9 @@ repositories { } dependencies { - api project(":") - implementation project(":").sourceSets.main.output + implementation project(':dependencies') + implementation project(path: ':dependencies', configuration: 'include') + implementation project(":") // log4j wrapper compileOnly 'org.apache.logging.log4j:log4j-api:2.8.1' // slf4j wrapper @@ -39,10 +39,6 @@ sourceSets { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = 8 - } } jar { diff --git a/minecraft/minecraft-test/build.gradle b/minecraft/minecraft-test/build.gradle index e846d5a31..5135045bd 100644 --- a/minecraft/minecraft-test/build.gradle +++ b/minecraft/minecraft-test/build.gradle @@ -18,10 +18,9 @@ dependencies { minecraft "com.mojang:minecraft:1.20.2" mappings "org.quiltmc:quilt-mappings:1.20.2+build.1:intermediary-v2" - implementation project(":minecraft") - implementation project(":minecraft").sourceSets.main.output - implementation project(":") + implementation project(":dependencies") + implementation project(path: ":dependencies", configuration: "include") implementation project(":").sourceSets.main.output // so that it works on runtime implementation "org.quiltmc.chasm:chassembly:${project.quilt_chasm}" diff --git a/settings.gradle b/settings.gradle index 1ceb798c3..6f219d4a4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,9 +13,13 @@ pluginManagement { } } +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} rootProject.name = "quilt-loader" include "minecraft" include "minecraft:minecraft-test" -include 'junit' \ No newline at end of file +include 'junit' +include 'dependencies' \ No newline at end of file