Gradle build change.

This commit is contained in:
zaxar163 2019-01-09 12:29:54 +04:00
parent de22bd3d33
commit 59063daed3
No known key found for this signature in database
GPG key ID: CEE900027AE098E0
12 changed files with 72 additions and 58 deletions

View file

@ -23,7 +23,7 @@
}
jar {
dependsOn parent.childProjects.Launcher.tasks.build, parent.childProjects.Launcher.tasks.genRuntimeJS, parent.childProjects.Launcher.tasks.jar
dependsOn parent.childProjects.Launcher.tasks.build
from { configurations.pack.collect { it.isDirectory() ? it : zipTree(it) } }
from(parent.childProjects.Launcher.tasks.jar.archivePath, parent.childProjects.Launcher.tasks.genRuntimeJS.archivePath)
manifest.attributes("Main-Class": mainClassName,
@ -60,8 +60,6 @@ pack project(':libLauncher') // pack
compileOnly('net.sf.launch4j:launch4j:3.12') { // need user
exclude group: '*'
}
//compile 'org.mozilla:rhino:1.7.10' will be module
}
task hikari(type: Copy) {
@ -75,4 +73,10 @@ task dumpLibs(type: Copy) {
from configurations.bundleOnly
}
build.dependsOn tasks.dumpLibs
task dumpClientLibs(type: Copy) {
dependsOn parent.childProjects.Launcher.tasks.build
into "$buildDir/libs/launcher-libraries"
from parent.childProjects.Launcher.tasks.dumpLibs.destinationDir
}
build.dependsOn tasks.dumpLibs, tasks.dumpClientLibs

View file

@ -330,7 +330,10 @@ public static void main(String... args) throws Throwable {
public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecException {
this.dir = dir;
launcherLibraries = dir.resolve("launcher-libraries");
if (!Files.isDirectory(launcherLibraries)) Files.createDirectory(launcherLibraries);
if (!Files.isDirectory(launcherLibraries)) {
Files.deleteIfExists(launcherLibraries);
Files.createDirectory(launcherLibraries);
}
this.args = Arrays.asList(args);
configFile = dir.resolve("LaunchServer.conf");
publicKeyFile = dir.resolve("public.key");

View file

@ -12,9 +12,9 @@
import java.util.Collections;
import java.util.jar.JarFile;
public class StarterAgent {
public final class StarterAgent {
public static final class StarterVisitor extends SimpleFileVisitor<Path> {
private static final class StarterVisitor extends SimpleFileVisitor<Path> {
private final Instrumentation inst;
private StarterVisitor(Instrumentation inst) {

View file

@ -1,11 +1,8 @@
package ru.gravit.launchserver.binary;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
@ -17,27 +14,12 @@
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
import ru.gravit.launchserver.binary.tasks.ProGuardBuildTask;
import ru.gravit.launchserver.binary.tasks.AdditionalFixesApplyTask;
import ru.gravit.launchserver.binary.tasks.UnpackBuildTask;
import ru.gravit.launchserver.binary.tasks.PrepareBuildTask;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
public final class JARLauncherBinary extends LauncherBinary {
private static final class ListFileVisitor extends SimpleFileVisitor<Path> {
private final List<Path> lst;
private ListFileVisitor(List<Path> lst) {
this.lst = lst;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.toFile().getName().endsWith(".jar"))
lst.add(file);
return super.visitFile(file, attrs);
}
}
public final AtomicLong count;
public final Path runtimeDir;
public final Path guardDir;
@ -54,12 +36,15 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
buildDir = server.dir.resolve("build");
tasks = new ArrayList<>();
coreLibs = new ArrayList<>();
Files.createDirectory(buildDir);
if (!Files.isDirectory(buildDir)) {
Files.deleteIfExists(buildDir);
Files.createDirectory(buildDir);
}
}
@Override
public void init() {
tasks.add(new UnpackBuildTask(server));
tasks.add(new PrepareBuildTask(server));
tasks.add(new MainBuildTask(server));
tasks.add(new ProGuardBuildTask(server));
tasks.add(new AttachJarsTask(server));
@ -69,9 +54,7 @@ public void init() {
@Override
public void build() throws IOException {
LogHelper.info("Building launcher binary file");
count.set(0);
coreLibs.clear();
IOHelper.walk(server.launcherLibraries, new ListFileVisitor(coreLibs), true);
count.set(0); // set jar number
Path thisPath = null;
boolean isNeedDelete = false;
long time_start = System.currentTimeMillis();

View file

@ -6,13 +6,18 @@
import ru.gravit.utils.helper.UnpackHelper;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
public class UnpackBuildTask implements LauncherBuildTask {
public class PrepareBuildTask implements LauncherBuildTask {
private final LaunchServer server;
private final Path result;
public UnpackBuildTask(LaunchServer server) {
public PrepareBuildTask(LaunchServer server) {
this.server = server;
result = server.launcherBinary.buildDir.resolve(server.config.binaryName + "-clean.jar");
}
@ -24,6 +29,8 @@ public String getName() {
@Override
public Path process(Path inputFile) throws IOException {
server.launcherBinary.coreLibs.clear();
IOHelper.walk(server.launcherLibraries, new ListFileVisitor(server.launcherBinary.coreLibs), true);
UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), result);
tryUnpack();
return result;
@ -39,4 +46,19 @@ public void tryUnpack() throws IOException {
UnpackHelper.unpackZipNoCheck("guard.zip", server.launcherBinary.guardDir);
UnpackHelper.unpackZipNoCheck("runtime.zip", server.launcherBinary.runtimeDir);
}
private static final class ListFileVisitor extends SimpleFileVisitor<Path> {
private final List<Path> lst;
private ListFileVisitor(List<Path> lst) {
this.lst = lst;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (!Files.isDirectory(file) && file.toFile().getName().endsWith(".jar"))
lst.add(file);
return super.visitFile(file, attrs);
}
}
}

View file

@ -1,19 +1,17 @@
String mainClassName = "ru.gravit.launcher.ClientLauncherWrapper"
String mainAgentName = "ru.gravit.launcher.LauncherAgent"
repositories {
maven {
url "http://repo.spring.io/plugins-release/"
}
maven {
url "http://repo.spring.io/plugins-release/"
}
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
jar {
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
manifest.attributes("Main-Class": mainClassName,
manifest.attributes("Main-Class": mainClassName,
"Premain-Class": mainAgentName,
"Can-Redefine-Classes": "true",
"Can-Retransform-Classes": "true",
@ -21,14 +19,20 @@
}
dependencies {
compile project(':LauncherAPI')
compile 'com.github.oshi:oshi-core:3.11.0'
compile project(':LauncherAPI')
compile 'com.github.oshi:oshi-core:3.11.0'
}
task genRuntimeJS(type: Zip) {
archiveName = "runtime.zip"
destinationDir = file("${buildDir}/tmp")
from "runtime/"
archiveName = "runtime.zip"
destinationDir = file("${buildDir}/tmp")
from "runtime/"
}
build.dependsOn tasks.genRuntimeJS
task dumpLibs(type: Copy) {
into "$buildDir/libs/libraries"
from configurations.runtime
}
build.dependsOn tasks.genRuntimeJS, tasks.dumpLibs

View file

@ -2,8 +2,8 @@
targetCompatibility = '1.8'
dependencies {
compile project(':libLauncher')
compile 'javax.websocket:javax.websocket-client-api:1.1'
compileOnly 'com.google.guava:guava:26.0-jre'
compile files('../compat/authlib/authlib-clean.jar')
compile project(':libLauncher')
compile 'javax.websocket:javax.websocket-client-api:1.1'
compileOnly 'com.google.guava:guava:26.0-jre'
compile files('../compat/authlib/authlib-clean.jar')
}

View file

@ -22,5 +22,4 @@
dependencies {
compile project(':LauncherAPI')
compile 'org.javassist:javassist:3.23.1-GA'
}

View file

@ -1,6 +1,5 @@
package ru.gravit.launcher.server;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import ru.gravit.launcher.ClientPermissions;

View file

@ -1,18 +1,18 @@
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
}
subprojects {
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url "http://clojars.org/repo/"
}
}
}
subprojects {
apply plugin: 'java'
configurations {
apt
aptCompileOnly

View file

@ -3,5 +3,5 @@
dependencies {
compileOnly 'org.fusesource.jansi:jansi:1.17.1'
compile 'com.google.code.gson:gson:2.8.5'
compile 'com.google.code.gson:gson:2.8.5'
}

@ -1 +1 @@
Subproject commit f87bdf0e1eeed4ca097e4ab90b99b0639aa4b52a
Subproject commit 5e37ef4d9a6d001e70b4ea5c3cd837e30b692d51