mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Merge pull request #364 from GravitLauncher/scriptsRewrite
[FEATURE] Переписал Gradle скрипты.
This commit is contained in:
commit
81d11198e2
9 changed files with 82 additions and 85 deletions
|
@ -22,16 +22,15 @@
|
||||||
hikari
|
hikari
|
||||||
pack
|
pack
|
||||||
launch4j
|
launch4j
|
||||||
launch4jCJ
|
|
||||||
bundleOnly.extendsFrom bundle
|
bundleOnly.extendsFrom bundle
|
||||||
api.extendsFrom bundle, hikari, pack, launch4jCJ, launch4j
|
api.extendsFrom bundle, hikari, pack, launch4j
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
dependsOn parent.childProjects.Launcher.tasks.build
|
dependsOn parent.childProjects.Launcher.tasks.assemble
|
||||||
from { configurations.pack.collect { it.isDirectory() ? it : zipTree(it) } }
|
from { configurations.pack.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||||
from(parent.childProjects.Launcher.tasks.shadowJar.archivePath)
|
from(parent.childProjects.Launcher.tasks.shadowJar)
|
||||||
from(parent.childProjects.Launcher.tasks.genRuntimeJS.archivePath)
|
from(parent.childProjects.Launcher.tasks.genRuntimeJS)
|
||||||
manifest.attributes("Main-Class": mainClassName,
|
manifest.attributes("Main-Class": mainClassName,
|
||||||
"Premain-Class": mainAgentName,
|
"Premain-Class": mainAgentName,
|
||||||
"Can-Redefine-Classes": "true",
|
"Can-Redefine-Classes": "true",
|
||||||
|
@ -71,23 +70,20 @@ task cleanjar(type: Jar, dependsOn: jar) {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
pack project(':LauncherAPI')
|
pack project(':LauncherAPI')
|
||||||
bundle 'org.ow2.asm:asm-commons:7.3.1'
|
bundle group: 'org.fusesource.jansi', name:'jansi', version: rootProject['verJansi']
|
||||||
bundle 'mysql:mysql-connector-java:8.0.16'
|
bundle group: 'org.jline', name: 'jline', version: rootProject['verJline']
|
||||||
bundle 'org.postgresql:postgresql:42.2.6'
|
bundle group: 'org.jline', name: 'jline-reader', version: rootProject['verJline']
|
||||||
bundle 'org.jline:jline:3.13.1'
|
bundle group: 'org.jline', name: 'jline-terminal', version: rootProject['verJline']
|
||||||
bundle 'org.jline:jline-reader:3.13.1'
|
bundle group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: rootProject['verBcpkix']
|
||||||
bundle 'org.jline:jline-terminal:3.13.1'
|
bundle group: 'org.ow2.asm', name: 'asm-commons', version: rootProject['verAsm']
|
||||||
bundle 'net.sf.proguard:proguard-base:6.2.0'
|
bundle group: 'io.netty', name: 'netty-all', version: rootProject['verNetty']
|
||||||
bundle 'org.fusesource.jansi:jansi:1.18'
|
bundle group: 'org.slf4j', name: 'slf4j-simple', version: rootProject['verSlf4j']
|
||||||
bundle 'commons-io:commons-io:2.6'
|
bundle group: 'org.slf4j', name: 'slf4j-api', version: rootProject['verSlf4j']
|
||||||
bundle 'commons-codec:commons-codec:1.12'
|
bundle group: 'org.hibernate', name: 'hibernate-core', version: rootProject['verHibernate']
|
||||||
bundle 'org.apache.httpcomponents:httpclient:4.5.10'
|
bundle group: 'mysql', name: 'mysql-connector-java', version: rootProject['verMySQLConn']
|
||||||
bundle 'io.netty:netty-all:4.1.43.Final'
|
bundle group: 'org.postgresql', name: 'postgresql', version: rootProject['verPostgreSQLConn']
|
||||||
bundle 'org.hibernate:hibernate-core:5.4.9.Final'
|
bundle group: 'net.sf.proguard', name: 'proguard-base', version: rootProject['verProguard']
|
||||||
bundle 'org.bouncycastle:bcpkix-jdk15on:1.61'
|
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
|
||||||
|
|
||||||
bundle 'org.slf4j:slf4j-simple:1.7.25'
|
|
||||||
bundle 'org.slf4j:slf4j-api:1.7.25'
|
|
||||||
|
|
||||||
hikari 'io.micrometer:micrometer-core:1.0.6'
|
hikari 'io.micrometer:micrometer-core:1.0.6'
|
||||||
hikari('com.zaxxer:HikariCP:3.4.1') {
|
hikari('com.zaxxer:HikariCP:3.4.1') {
|
||||||
|
@ -96,25 +92,20 @@ pack project(':LauncherAPI')
|
||||||
exclude group: 'org.slf4j'
|
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: 'org.apache.ant'
|
||||||
exclude group: 'net.java.abeille'
|
exclude group: 'net.java.abeille'
|
||||||
exclude group: 'foxtrot'
|
exclude group: 'foxtrot'
|
||||||
exclude group: 'com.jgoodies'
|
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') {
|
compileOnlyA group: 'com.google.guava', name: 'guava', version: rootProject['verGuavaC']
|
||||||
exclude group: '*'
|
// Do not update (laggy deps).
|
||||||
}
|
compileOnlyA 'log4j:log4j:1.2.17'
|
||||||
|
|
||||||
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 'org.apache.logging.log4j:log4j-core:2.11.2'
|
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task hikari(type: Copy) {
|
task hikari(type: Copy) {
|
||||||
|
@ -123,39 +114,25 @@ task hikari(type: Copy) {
|
||||||
from configurations.hikari
|
from configurations.hikari
|
||||||
}
|
}
|
||||||
|
|
||||||
task launch4jM(type: Copy) {
|
task launch4j(type: Copy) {
|
||||||
duplicatesStrategy = 'EXCLUDE'
|
duplicatesStrategy = 'EXCLUDE'
|
||||||
into "$buildDir/libs/libraries/launch4j"
|
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
|
includeEmptyDirs false
|
||||||
eachFile { FileCopyDetails fcp ->
|
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 segments = fcp.relativePath.segments
|
||||||
def pathSegments = segments[1..-1] as String[]
|
def pathSegments = segments[1..-1] as String[]
|
||||||
fcp.relativePath = new RelativePath(!fcp.file.isDirectory(), pathSegments)
|
fcp.relativePath = new RelativePath(!fcp.file.isDirectory(), pathSegments)
|
||||||
fcp.mode = 0755
|
} else if (fcp.relativePath.pathString.contains("META-INF")) fcp.exclude()
|
||||||
} 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"
|
|
||||||
}
|
|
||||||
fcp.mode = 0755
|
fcp.mode = 0755
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task dumpLibs(type: Copy) {
|
task dumpLibs(type: Copy) {
|
||||||
duplicatesStrategy = 'EXCLUDE'
|
duplicatesStrategy = 'EXCLUDE'
|
||||||
dependsOn tasks.hikari, tasks.launch4jM, tasks.launch4jA
|
dependsOn tasks.hikari, tasks.launch4j
|
||||||
into "$buildDir/libs/libraries"
|
into "$buildDir/libs/libraries"
|
||||||
from configurations.bundleOnly
|
from configurations.bundleOnly
|
||||||
}
|
}
|
||||||
|
@ -173,14 +150,14 @@ task bundle(type: Zip) {
|
||||||
destinationDirectory = file("$buildDir")
|
destinationDirectory = file("$buildDir")
|
||||||
from(tasks.dumpLibs.destinationDir) { into 'libraries' }
|
from(tasks.dumpLibs.destinationDir) { into 'libraries' }
|
||||||
from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' }
|
from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' }
|
||||||
from tasks.jar.archivePath
|
from(tasks.jar)
|
||||||
from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' }
|
from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' }
|
||||||
}
|
}
|
||||||
|
|
||||||
task dumpClientLibs(type: Copy) {
|
task dumpClientLibs(type: Copy) {
|
||||||
dependsOn parent.childProjects.Launcher.tasks.build
|
dependsOn parent.childProjects.Launcher.tasks.build
|
||||||
into "$buildDir/libs/launcher-libraries"
|
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
|
assemble.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.dumpClientLibs, tasks.bundle, tasks.cleanjar
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
import pro.gravit.launchserver.asm.InjectClassAcceptor;
|
import pro.gravit.launchserver.asm.InjectClassAcceptor;
|
||||||
import pro.gravit.utils.helper.JarHelper;
|
import pro.gravit.utils.helper.JarHelper;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -38,11 +40,11 @@ public static class TestClass
|
||||||
public Map<String, String> map;
|
public Map<String, String> map;
|
||||||
}
|
}
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void prepare() throws Exception {
|
public static void prepare() throws Throwable {
|
||||||
classLoader = new ASMClassLoader(ASMTransformersTest.class.getClassLoader());
|
classLoader = new ASMClassLoader(ASMTransformersTest.class.getClassLoader());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void testASM() throws Exception
|
void testASM() throws Throwable
|
||||||
{
|
{
|
||||||
ClassReader reader = new ClassReader(JarHelper.getClassBytes(TestClass.class));
|
ClassReader reader = new ClassReader(JarHelper.getClassBytes(TestClass.class));
|
||||||
ClassNode node = new ClassNode();
|
ClassNode node = new ClassNode();
|
||||||
|
@ -65,15 +67,13 @@ void testASM() throws Exception
|
||||||
byte[] bytes = writer.toByteArray();
|
byte[] bytes = writer.toByteArray();
|
||||||
classLoader.rawDefineClass("ASMTestClass", bytes, 0, bytes.length);
|
classLoader.rawDefineClass("ASMTestClass", bytes, 0, bytes.length);
|
||||||
Class<?> clazz = classLoader.loadClass("ASMTestClass");
|
Class<?> clazz = classLoader.loadClass("ASMTestClass");
|
||||||
Object instance = clazz.newInstance();
|
Object instance = MethodHandles.publicLookup().findConstructor(clazz, MethodType.methodType(void.class)).invoke();
|
||||||
Field field = clazz.getField("test");
|
Assertions.assertEquals(1234, (int)
|
||||||
Object result = field.get(instance);
|
MethodHandles.publicLookup().findGetter(clazz, "test", int.class).invoke(instance));
|
||||||
Assertions.assertEquals(1234, (int) (Integer) result);
|
Assertions.assertEquals(strings, (List<String>)
|
||||||
field = clazz.getField("s");
|
MethodHandles.publicLookup().findGetter(clazz, "s", List.class).invoke(instance));
|
||||||
result = field.get(instance);
|
|
||||||
Assertions.assertEquals(strings, result);
|
Assertions.assertEquals(byteMap, (Map<String, Object>)
|
||||||
field = clazz.getField("map");
|
MethodHandles.publicLookup().findGetter(clazz, "map", Map.class).invoke(instance));
|
||||||
result = field.get(instance);
|
|
||||||
Assertions.assertEquals(byteMap, result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,9 +53,9 @@ task javadocJar(type: Jar) {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
pack project(':LauncherAPI')
|
pack project(':LauncherAPI')
|
||||||
bundle 'com.github.oshi:oshi-core:3.13.0'
|
bundle group: 'com.github.oshi', name: 'oshi-core', version: rootProject['verOshiCore']
|
||||||
pack 'io.netty:netty-codec-http:4.1.43.Final'
|
pack group: 'io.netty', name: 'netty-codec-http', version: rootProject['verNetty']
|
||||||
pack 'org.ow2.asm:asm-tree:7.1'
|
pack group: 'org.ow2.asm', name: 'asm-tree', version: rootProject['verAsm']
|
||||||
}
|
}
|
||||||
|
|
||||||
task genRuntimeJS(type: Zip) {
|
task genRuntimeJS(type: Zip) {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':LauncherCore')
|
api project(':LauncherCore')
|
||||||
compileOnly 'io.netty:netty-codec-http:4.1.43.Final'
|
compileOnly group: 'io.netty', name: 'netty-codec-http', version: rootProject['verNetty']
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
|
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':LauncherAPI')
|
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')
|
api files('../compat/authlib/authlib-clean.jar')
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
targetCompatibility = '1.8'
|
targetCompatibility = '1.8'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.fusesource.jansi:jansi:1.18'
|
compileOnly group: 'org.fusesource.jansi', name:'jansi', version: rootProject['verJansi']
|
||||||
compileOnly 'org.jline:jline:3.11.0'
|
compileOnly group: 'org.jline', name: 'jline', version: rootProject['verJline']
|
||||||
compileOnly 'org.jline:jline-reader:3.11.0'
|
compileOnly group: 'org.jline', name: 'jline-reader', version: rootProject['verJline']
|
||||||
compileOnly 'org.jline:jline-terminal:3.11.0'
|
compileOnly group: 'org.jline', name: 'jline-terminal', version: rootProject['verJline']
|
||||||
compileOnly 'org.bouncycastle:bcprov-jdk15:1.46'
|
compileOnly group: 'org.bouncycastle', name: 'bcprov-jdk15', version: rootProject['verBcprov']
|
||||||
api 'com.google.code.gson:gson:2.8.5'
|
api group: 'com.google.code.gson', name: 'gson', version: rootProject['verGson']
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
|
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|
|
@ -38,7 +38,7 @@ task javadocJar(type: Jar) {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
pack project(':LauncherAuthlib')
|
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 {
|
shadowJar {
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.1.2-SNAPSHOT'
|
version = '5.1.2-SNAPSHOT'
|
||||||
|
|
||||||
|
apply from: 'props.gradle'
|
||||||
|
|
||||||
configure(subprojects.findAll { it.name != 'modules' }) {
|
configure(subprojects.findAll { it.name != 'modules' }) {
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
|
18
props.gradle
Normal file
18
props.gradle
Normal 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'
|
||||||
|
}
|
Loading…
Reference in a new issue