Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev

This commit is contained in:
Gravit 2020-03-22 03:41:34 +07:00
commit 0ddf04b6aa
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
9 changed files with 82 additions and 85 deletions

View file

@ -22,16 +22,15 @@
hikari
pack
launch4j
launch4jCJ
bundleOnly.extendsFrom bundle
api.extendsFrom bundle, hikari, pack, launch4jCJ, launch4j
api.extendsFrom bundle, hikari, pack, launch4j
}
jar {
dependsOn parent.childProjects.Launcher.tasks.build
dependsOn parent.childProjects.Launcher.tasks.assemble
from { configurations.pack.collect { it.isDirectory() ? it : zipTree(it) } }
from(parent.childProjects.Launcher.tasks.shadowJar.archivePath)
from(parent.childProjects.Launcher.tasks.genRuntimeJS.archivePath)
from(parent.childProjects.Launcher.tasks.shadowJar)
from(parent.childProjects.Launcher.tasks.genRuntimeJS)
manifest.attributes("Main-Class": mainClassName,
"Premain-Class": mainAgentName,
"Can-Redefine-Classes": "true",
@ -71,23 +70,20 @@ task cleanjar(type: Jar, dependsOn: jar) {
dependencies {
pack project(':LauncherAPI')
bundle 'org.ow2.asm:asm-commons:7.3.1'
bundle 'mysql:mysql-connector-java:8.0.16'
bundle 'org.postgresql:postgresql:42.2.6'
bundle 'org.jline:jline:3.13.1'
bundle 'org.jline:jline-reader:3.13.1'
bundle 'org.jline:jline-terminal:3.13.1'
bundle 'net.sf.proguard:proguard-base:6.2.0'
bundle 'org.fusesource.jansi:jansi:1.18'
bundle 'commons-io:commons-io:2.6'
bundle 'commons-codec:commons-codec:1.12'
bundle 'org.apache.httpcomponents:httpclient:4.5.10'
bundle 'io.netty:netty-all:4.1.43.Final'
bundle 'org.hibernate:hibernate-core:5.4.9.Final'
bundle 'org.bouncycastle:bcpkix-jdk15on:1.61'
bundle 'org.slf4j:slf4j-simple:1.7.25'
bundle 'org.slf4j:slf4j-api:1.7.25'
bundle group: 'org.fusesource.jansi', name:'jansi', version: rootProject['verJansi']
bundle group: 'org.jline', name: 'jline', version: rootProject['verJline']
bundle group: 'org.jline', name: 'jline-reader', version: rootProject['verJline']
bundle group: 'org.jline', name: 'jline-terminal', version: rootProject['verJline']
bundle group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: rootProject['verBcpkix']
bundle group: 'org.ow2.asm', name: 'asm-commons', version: rootProject['verAsm']
bundle group: 'io.netty', name: 'netty-all', version: rootProject['verNetty']
bundle group: 'org.slf4j', name: 'slf4j-simple', version: rootProject['verSlf4j']
bundle group: 'org.slf4j', name: 'slf4j-api', version: rootProject['verSlf4j']
bundle group: 'org.hibernate', name: 'hibernate-core', version: rootProject['verHibernate']
bundle group: 'mysql', name: 'mysql-connector-java', version: rootProject['verMySQLConn']
bundle group: 'org.postgresql', name: 'postgresql', version: rootProject['verPostgreSQLConn']
bundle group: 'net.sf.proguard', name: 'proguard-base', version: rootProject['verProguard']
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
hikari 'io.micrometer:micrometer-core:1.0.6'
hikari('com.zaxxer:HikariCP:3.4.1') {
@ -96,25 +92,20 @@ pack project(':LauncherAPI')
exclude group: 'org.slf4j'
}
launch4j('net.sf.launch4j:launch4j:3.12') {
launch4j('net.sf.launch4j:launch4j:' + rootProject['verLaunch4j']) {
exclude group: 'org.apache.ant'
exclude group: 'net.java.abeille'
exclude group: 'foxtrot'
exclude group: 'com.jgoodies'
exclude group: 'org.slf4j'
}
launch4j('net.sf.launch4j:launch4j:' + rootProject['verLaunch4j'] + ':workdir-win32') { transitive = false }
launch4j('net.sf.launch4j:launch4j:' + rootProject['verLaunch4j'] + 'workdir-linux') { transitive = false }
launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-win32') {
exclude group: '*'
}
launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-linux') {
exclude group: '*'
}
compileOnlyA 'com.google.guava:guava:26.0-jre'
compileOnlyA 'log4j:log4j:1.2.17' // Do not update (laggy dep).
compileOnlyA group: 'com.google.guava', name: 'guava', version: rootProject['verGuavaC']
// Do not update (laggy deps).
compileOnlyA 'log4j:log4j:1.2.17'
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
}
task hikari(type: Copy) {
@ -123,39 +114,25 @@ task hikari(type: Copy) {
from configurations.hikari
}
task launch4jM(type: Copy) {
task launch4j(type: Copy) {
duplicatesStrategy = 'EXCLUDE'
into "$buildDir/libs/libraries/launch4j"
from(configurations.launch4jCJ.collect { it.isDirectory() ? it : zipTree(it) })
from(configurations.launch4j.collect { it.isDirectory() ? it : ((it.getName().startsWith("launch4j") && it.getName().contains("workdir")) ? zipTree(it) : it) })
includeEmptyDirs false
eachFile { FileCopyDetails fcp ->
if (fcp.relativePath.pathString.startsWith("launch4j-")) {
if (fcp.relativePath.pathString.startsWith("launch4j-") &&
fcp.relativePath.pathString.contains("workdir")) {
def segments = fcp.relativePath.segments
def pathSegments = segments[1..-1] as String[]
fcp.relativePath = new RelativePath(!fcp.file.isDirectory(), pathSegments)
fcp.mode = 0755
} else {
fcp.exclude()
}
}
}
task launch4jA(type: Copy) {
duplicatesStrategy = 'EXCLUDE'
into "$buildDir/libs/libraries/launch4j"
from(configurations.launch4j)
includeEmptyDirs false
eachFile { FileCopyDetails fcp ->
if (fcp.name.startsWith("launch4j")) {
fcp.name = "launch4j.jar"
}
} else if (fcp.relativePath.pathString.contains("META-INF")) fcp.exclude()
fcp.mode = 0755
}
}
task dumpLibs(type: Copy) {
duplicatesStrategy = 'EXCLUDE'
dependsOn tasks.hikari, tasks.launch4jM, tasks.launch4jA
dependsOn tasks.hikari, tasks.launch4j
into "$buildDir/libs/libraries"
from configurations.bundleOnly
}
@ -173,14 +150,14 @@ task bundle(type: Zip) {
destinationDirectory = file("$buildDir")
from(tasks.dumpLibs.destinationDir) { into 'libraries' }
from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' }
from tasks.jar.archivePath
from(tasks.jar)
from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' }
}
task dumpClientLibs(type: Copy) {
dependsOn parent.childProjects.Launcher.tasks.build
into "$buildDir/libs/launcher-libraries"
from parent.childProjects.Launcher.tasks.dumpLibs.destinationDir
from parent.childProjects.Launcher.tasks.dumpLibs
}
assemble.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.dumpClientLibs, tasks.bundle, tasks.cleanjar

View file

@ -10,6 +10,8 @@
import pro.gravit.launchserver.asm.InjectClassAcceptor;
import pro.gravit.utils.helper.JarHelper;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
@ -38,11 +40,11 @@ public static class TestClass
public Map<String, String> map;
}
@BeforeAll
public static void prepare() throws Exception {
public static void prepare() throws Throwable {
classLoader = new ASMClassLoader(ASMTransformersTest.class.getClassLoader());
}
@Test
void testASM() throws Exception
void testASM() throws Throwable
{
ClassReader reader = new ClassReader(JarHelper.getClassBytes(TestClass.class));
ClassNode node = new ClassNode();
@ -65,15 +67,13 @@ void testASM() throws Exception
byte[] bytes = writer.toByteArray();
classLoader.rawDefineClass("ASMTestClass", bytes, 0, bytes.length);
Class<?> clazz = classLoader.loadClass("ASMTestClass");
Object instance = clazz.newInstance();
Field field = clazz.getField("test");
Object result = field.get(instance);
Assertions.assertEquals(1234, (int) (Integer) result);
field = clazz.getField("s");
result = field.get(instance);
Assertions.assertEquals(strings, result);
field = clazz.getField("map");
result = field.get(instance);
Assertions.assertEquals(byteMap, result);
Object instance = MethodHandles.publicLookup().findConstructor(clazz, MethodType.methodType(void.class)).invoke();
Assertions.assertEquals(1234, (int)
MethodHandles.publicLookup().findGetter(clazz, "test", int.class).invoke(instance));
Assertions.assertEquals(strings, (List<String>)
MethodHandles.publicLookup().findGetter(clazz, "s", List.class).invoke(instance));
Assertions.assertEquals(byteMap, (Map<String, Object>)
MethodHandles.publicLookup().findGetter(clazz, "map", Map.class).invoke(instance));
}
}

View file

@ -53,9 +53,9 @@ task javadocJar(type: Jar) {
dependencies {
pack project(':LauncherAPI')
bundle 'com.github.oshi:oshi-core:3.13.0'
pack 'io.netty:netty-codec-http:4.1.43.Final'
pack 'org.ow2.asm:asm-tree:7.1'
bundle group: 'com.github.oshi', name: 'oshi-core', version: rootProject['verOshiCore']
pack group: 'io.netty', name: 'netty-codec-http', version: rootProject['verNetty']
pack group: 'org.ow2.asm', name: 'asm-tree', version: rootProject['verAsm']
}
task genRuntimeJS(type: Zip) {

View file

@ -3,8 +3,8 @@
dependencies {
api project(':LauncherCore')
compileOnly 'io.netty:netty-codec-http:4.1.43.Final'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
compileOnly group: 'io.netty', name: 'netty-codec-http', version: rootProject['verNetty']
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
}
test {

View file

@ -3,6 +3,6 @@
dependencies {
api project(':LauncherAPI')
compileOnly 'com.google.guava:guava:26.0-jre'
compileOnly group: 'com.google.guava', name: 'guava', version: rootProject['verGuavaC']
api files('../compat/authlib/authlib-clean.jar')
}

View file

@ -2,13 +2,13 @@
targetCompatibility = '1.8'
dependencies {
compileOnly 'org.fusesource.jansi:jansi:1.18'
compileOnly 'org.jline:jline:3.11.0'
compileOnly 'org.jline:jline-reader:3.11.0'
compileOnly 'org.jline:jline-terminal:3.11.0'
compileOnly 'org.bouncycastle:bcprov-jdk15:1.46'
api 'com.google.code.gson:gson:2.8.5'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
compileOnly group: 'org.fusesource.jansi', name:'jansi', version: rootProject['verJansi']
compileOnly group: 'org.jline', name: 'jline', version: rootProject['verJline']
compileOnly group: 'org.jline', name: 'jline-reader', version: rootProject['verJline']
compileOnly group: 'org.jline', name: 'jline-terminal', version: rootProject['verJline']
compileOnly group: 'org.bouncycastle', name: 'bcprov-jdk15', version: rootProject['verBcprov']
api group: 'com.google.code.gson', name: 'gson', version: rootProject['verGson']
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
}
test {

View file

@ -38,7 +38,7 @@ task javadocJar(type: Jar) {
dependencies {
pack project(':LauncherAuthlib')
pack 'io.netty:netty-codec-http:4.1.43.Final'
pack group: 'io.netty', name: 'netty-codec-http', version: rootProject['verNetty']
}
shadowJar {

View file

@ -7,6 +7,8 @@
group = 'pro.gravit.launcher'
version = '5.1.2-SNAPSHOT'
apply from: 'props.gradle'
configure(subprojects.findAll { it.name != 'modules' }) {
apply plugin: 'idea'
apply plugin: 'eclipse'

18
props.gradle Normal file
View file

@ -0,0 +1,18 @@
project.ext {
verAsm = '7.2'
verNetty = '4.1.43.Final'
verOshiCore = '3.13.0'
verJunit = '5.6.0'
verGuavaC = '26.0-jre'
verJansi = '1.18'
verJline = '3.11.0'
verBcprov = '1.46'
verGson = '2.8.5'
verBcpkix = '1.61'
verSlf4j = '1.7.25'
verMySQLConn = '8.0.16'
verPostgreSQLConn = '42.2.6'
verProguard = '6.2.0'
verLaunch4j = '3.12'
verHibernate = '5.4.9.Final'
}