[FEATURE] Multi-Release JAR и компиляция только на Java 11+

This commit is contained in:
Gravit 2019-11-25 00:33:18 +07:00
parent 178fab6ff7
commit e9db1b307b
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 38 additions and 4 deletions

View file

@ -11,7 +11,7 @@ stages:
- test
build:
image: frekele/java
image: java:11
stage: build
before_script:
- apt-get -y update
@ -43,7 +43,7 @@ build:
- artifacts
test:
image: frekele/java
image: java:11
stage: test
script:
- ./gradlew check

View file

@ -1,3 +1,6 @@
plugins {
id 'org.openjfx.javafxplugin' version '0.0.5'
}
apply plugin: 'com.github.johnrengelman.shadow'
String mainClassName = "pro.gravit.launcher.ClientLauncherWrapper"
@ -8,7 +11,10 @@
url "http://repo.spring.io/plugins-release/"
}
}
javafx {
version = "12"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

View file

@ -1,3 +1,4 @@
apply plugin: 'java-library'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
@ -17,10 +18,26 @@
events "passed", "skipped", "failed"
}
}
sourceSets {
java9 {
java {
srcDirs = ['src/main/java9']
}
dependencies {
java9Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava }
}
}
}
jar {
into('META-INF/versions/9') {
from sourceSets.java9.output
}
classifier = 'clean'
}
compileJava9Java {
sourceCompatibility = 9
targetCompatibility = 9
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava

View file

@ -59,6 +59,17 @@ public static OS byName(String name) {
public static final ClassLoader LOADER = ClassLoader.getSystemClassLoader();
public static final int JVM_VERSION = getVersion();
public static int getVersion() {
String version = System.getProperty("java.version");
if(version.startsWith("1.")) {
version = version.substring(2, 3);
} else {
int dot = version.indexOf(".");
if(dot != -1) { version = version.substring(0, dot); }
} return Integer.parseInt(version);
}
static {
try {
MethodHandles.publicLookup(); // Just to initialize class