diff options
author | LexManos <LexManos@gmail.com> | 2020-04-04 14:01:02 -0700 |
---|---|---|
committer | LexManos <LexManos@gmail.com> | 2020-04-04 14:01:02 -0700 |
commit | 977462b1780785a4ce9500646df07b6a4f638461 (patch) | |
tree | f4ee2ea5eee222668b1c3c868cc468e6d4314ba5 /build.gradle | |
parent | c5ae801c3a51aa6abf05c2eb5d6b3ebe592d02ab (diff) | |
download | Artifactural-977462b1780785a4ce9500646df07b6a4f638461.tar.gz Artifactural-977462b1780785a4ce9500646df07b6a4f638461.tar.bz2 Artifactural-977462b1780785a4ce9500646df07b6a4f638461.zip |
Use Method handles to bypass J12+ reflection blocking attempt.
Publish as Multi-Release jar as this API is only available on J9+
Diffstat (limited to 'build.gradle')
-rw-r--r-- | build.gradle | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/build.gradle b/build.gradle index d6cbd04..8b5242f 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,7 @@ import java.util.jar.JarFile apply plugin: 'java' apply plugin: 'maven-publish' +apply plugin: 'eclipse' group = 'net.minecraftforge' version = gitVersion() @@ -44,6 +45,7 @@ sourceSets { api shared gradlecomp + java9 } repositories { @@ -60,6 +62,8 @@ configurations { } dependencies { + java9Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava } + sharedImplementation sourceSets.api.output sharedImplementation 'commons-io:commons-io:2.4' @@ -74,6 +78,43 @@ dependencies { } +// Default all standard Java compile tasks to Java 8 +// We'll specify Java 9 only for the java9 compile task +tasks.withType(JavaCompile) { + options.encoding = 'utf-8' + options.deprecation = true + sourceCompatibility = 8 + targetCompatibility = 8 + options.compilerArgs.addAll(['--release', '8']) +} + +project(':artifactural9') { + apply plugin: 'java' + apply plugin: 'eclipse' + sourceCompatibility = targetCompatibility = 9 + group = rootProject.group + + sourceSets { + java9.java.srcDirs = [rootProject.file('src/java9').getAbsolutePath()] + } + + eclipse { + project { + name rootProject.name + '9' + linkedResource name: 'java9', type: '2', location: rootProject.file('src/java9').getAbsolutePath() + } + jdt { + sourceCompatibility = targetCompatibility = 9 + } + } + + tasks.withType(JavaCompile) { + options.encoding = 'utf-8' + sourceCompatibility = 9 + targetCompatibility = 9 + options.compilerArgs.addAll(['--release', '9']) + } +} def gradleRepositoryAdapterPath = Paths.get("com", "amadornes", "artifactural", "gradle", "GradleRepositoryAdapter.class") def classesDirs = sourceSets.gradlecomp.output.classesDirs.getFiles().first().toPath() @@ -159,8 +200,6 @@ class PatchGradleRepositoryAdapter extends DefaultTask { } } - - task patchConstructor(type: PatchGradleRepositoryAdapter) { constructorName = _constructorName constructorDesc = _constructorDesc @@ -178,12 +217,22 @@ jar { } from patchConstructor.outputs + + into('META-INF/versions/9') { + from project(':artifactural9').sourceSets.java9.output + } + + manifest { + attributes( + 'Multi-Release': 'true' + ) + } } jar.doLast { def jarPath = it.outputs.files.getFiles().first() def jarFile = new JarFile(jarPath) - def entry = jarFile.getEntry(gradleRepositoryAdapterPath.toString()) + def entry = jarFile.getEntry(gradleRepositoryAdapterPath.toString().replace('\\', '/')) def stream = jarFile.getInputStream(entry) ClassReader reader = new ClassReader(stream) @@ -264,10 +313,15 @@ publishing { username = project.properties.mavenUser password = project.properties.mavenPassword } - url 'http://files.minecraftforge.net/maven/manage/upload' + url 'https://files.minecraftforge.net/maven/manage/upload' } else { url 'file://' + rootProject.file('repo').getAbsolutePath() } } } } + +if (!JavaVersion.current().java9Compatible) { + println("You must build this with JDK 9") + System.exit(1) +} |