aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-11-01 21:11:09 +0100
committernea <nea@nea.moe>2023-11-01 21:11:09 +0100
commit21ca764e26fdbb903ce380874cc2798f17de9034 (patch)
tree52931b66e52120a22d20354d0fe1adb26876cded
parent297cb01f220a617dd08096467978b2fccbc27695 (diff)
downloadModernJavaLauncher-21ca764e26fdbb903ce380874cc2798f17de9034.tar.gz
ModernJavaLauncher-21ca764e26fdbb903ce380874cc2798f17de9034.tar.bz2
ModernJavaLauncher-21ca764e26fdbb903ce380874cc2798f17de9034.zip
Make MJL package the agent
-rw-r--r--agent/build.gradle.kts11
-rw-r--r--build.gradle.kts11
-rw-r--r--examplemod.ipr104
-rw-r--r--examplemod.iws427
-rwxr-xr-xinstall.sh6
-rw-r--r--src/main/java/moe/nea/modernjava/launch/live/FCPFixTweaker.java2
-rw-r--r--src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java33
7 files changed, 48 insertions, 546 deletions
diff --git a/agent/build.gradle.kts b/agent/build.gradle.kts
index 983f917..c85be22 100644
--- a/agent/build.gradle.kts
+++ b/agent/build.gradle.kts
@@ -9,15 +9,13 @@ java {
val shadowOnly: Configuration by configurations.creating {
- attributes {
- this.attribute(org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11)
- }
}
dependencies {
shadowOnly(implementation("org.ow2.asm:asm:9.4")!!)
shadowOnly(implementation("org.ow2.asm:asm-commons:9.4")!!)
shadowOnly("dev.architectury:architectury-pack200:0.1.3")
+ shadowOnly("org.apache.commons:commons-lang3:3.13.0")
}
tasks.withType(Jar::class) {
manifest {
@@ -36,4 +34,9 @@ tasks.shadowJar {
tasks.jar {
archiveClassifier.set("thin")
}
-tasks.assemble.get().dependsOn(tasks.shadowJar) \ No newline at end of file
+tasks.assemble.get().dependsOn(tasks.shadowJar)
+
+configurations.create("agentShadow")
+artifacts {
+ add("agentShadow", tasks.shadowJar)
+}
diff --git a/build.gradle.kts b/build.gradle.kts
index 154215c..46deb21 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -47,6 +47,8 @@ val shadowImpl: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
+val agentDeps: Configuration by configurations.creating
+
val shadowOnly: Configuration by configurations.creating {
attributes {
this.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
@@ -63,10 +65,18 @@ dependencies {
shadowImpl("com.github.Skytils:AsmHelper:91ecc2bd9c")
shadowImpl(enforcedPlatform(kotlin("bom")))
shadowImpl(kotlin("stdlib"))
+ agentDeps(project(":agent",configuration = "agentShadow"))
}
// Tasks:
+val doubleWrappedJar by tasks.creating(Zip::class) {
+ archiveFileName.set("agent.jar")
+ destinationDirectory.set(project.layout.buildDirectory.dir("wrapper"))
+ from(agentDeps)
+ into("agent")
+}
+
tasks.withType(JavaCompile::class) {
options.encoding = "UTF-8"
}
@@ -97,6 +107,7 @@ tasks.shadowJar {
archiveClassifier.set("all-dev")
relocate("dev.falsehonesty.asmhelper", "moe.nea.modernjava.dep.asmhelper")
configurations = listOf(shadowImpl, shadowOnly)
+ from(doubleWrappedJar)
}
tasks.assemble.get().dependsOn(tasks.remapJar)
diff --git a/examplemod.ipr b/examplemod.ipr
deleted file mode 100644
index 4ec7ca2..0000000
--- a/examplemod.ipr
+++ /dev/null
@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="CompilerConfiguration">
- <option name="DEFAULT_COMPILER" value="Javac"/>
- <resourceExtensions>
- <entry name=".+\.(properties|xml|html|dtd|tld)"/>
- <entry name=".+\.(gif|png|jpeg|jpg)"/>
- </resourceExtensions>
- <wildcardResourcePatterns>
- <entry name="!?*.class"/>
- <entry name="!?*.scala"/>
- <entry name="!?*.groovy"/>
- <entry name="!?*.java"/>
- </wildcardResourcePatterns>
- <annotationProcessing enabled="false" useClasspath="true"/>
- <bytecodeTargetLevel target="1.8"/>
- </component>
- <component name="CopyrightManager" default="">
- <module2copyright/>
- </component>
- <component name="DependencyValidationManager">
- <option name="SKIP_IMPORT_STATEMENTS" value="false"/>
- </component>
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"/>
- <component name="GradleUISettings">
- <setting name="root"/>
- </component>
- <component name="GradleUISettings2">
- <setting name="root"/>
- </component>
- <component name="IdProvider" IDEtalkID="11DA1DB66DD62DDA1ED602B7079FE97C"/>
- <component name="JavadocGenerationManager">
- <option name="OUTPUT_DIRECTORY"/>
- <option name="OPTION_SCOPE" value="protected"/>
- <option name="OPTION_HIERARCHY" value="true"/>
- <option name="OPTION_NAVIGATOR" value="true"/>
- <option name="OPTION_INDEX" value="true"/>
- <option name="OPTION_SEPARATE_INDEX" value="true"/>
- <option name="OPTION_DOCUMENT_TAG_USE" value="false"/>
- <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false"/>
- <option name="OPTION_DOCUMENT_TAG_VERSION" value="false"/>
- <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true"/>
- <option name="OPTION_DEPRECATED_LIST" value="true"/>
- <option name="OTHER_OPTIONS" value=""/>
- <option name="HEAP_SIZE"/>
- <option name="LOCALE"/>
- <option name="OPEN_IN_BROWSER" value="true"/>
- </component>
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/examplemod.iml" filepath="$PROJECT_DIR$/examplemod.iml"/>
- </modules>
- </component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-type="JavaSDK" assert-jdk-15="true" project-jdk-name="19">
- <output url="file://$PROJECT_DIR$/out"/>
- </component>
- <component name="SvnBranchConfigurationManager">
- <option name="mySupportsUserInfoFilter" value="true"/>
- </component>
- <component name="VcsDirectoryMappings">
- <mapping directory="" vcs=""/>
- </component>
- <component name="masterDetails">
- <states>
- <state key="ArtifactsStructureConfigurable.UI">
- <UIState>
- <splitter-proportions>
- <SplitterProportionsDataImpl/>
- </splitter-proportions>
- <settings/>
- </UIState>
- </state>
- <state key="Copyright.UI">
- <UIState>
- <splitter-proportions>
- <SplitterProportionsDataImpl/>
- </splitter-proportions>
- </UIState>
- </state>
- <state key="ProjectJDKs.UI">
- <UIState>
- <splitter-proportions>
- <SplitterProportionsDataImpl>
- <option name="proportions">
- <list>
- <option value="0.2"/>
- </list>
- </option>
- </SplitterProportionsDataImpl>
- </splitter-proportions>
- <last-edited>1.6</last-edited>
- </UIState>
- </state>
- <state key="ScopeChooserConfigurable.UI">
- <UIState>
- <splitter-proportions>
- <SplitterProportionsDataImpl/>
- </splitter-proportions>
- <settings/>
- </UIState>
- </state>
- </states>
- </component>
-</project>
diff --git a/examplemod.iws b/examplemod.iws
deleted file mode 100644
index 0819613..0000000
--- a/examplemod.iws
+++ /dev/null
@@ -1,427 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project version="4">
-
- <component name="ChangeListManager">
-
- <option name="TRACKING_ENABLED" value="true"/>
-
- <option name="SHOW_DIALOG" value="false"/>
-
- <option name="HIGHLIGHT_CONFLICTS" value="true"/>
-
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false"/>
-
- <option name="LAST_RESOLUTION" value="IGNORE"/>
-
- </component>
-
- <component flattened_view="true" name="ChangesViewManager" show_ignored="false"/>
-
- <component name="CreatePatchCommitExecutor">
-
- <option name="PATCH_PATH" value=""/>
-
- <option name="REVERSE_PATCH" value="false"/>
-
- </component>
-
- <component name="DaemonCodeAnalyzer">
-
- <disable_hints/>
-
- </component>
-
- <component name="DebuggerManager">
-
- <breakpoint_any>
-
- <breakpoint>
-
- <option name="NOTIFY_CAUGHT" value="true"/>
-
- <option name="NOTIFY_UNCAUGHT" value="true"/>
-
- <option name="ENABLED" value="false"/>
-
- <option name="LOG_ENABLED" value="false"/>
-
- <option name="LOG_EXPRESSION_ENABLED" value="false"/>
-
- <option name="SUSPEND_POLICY" value="SuspendAll"/>
-
- <option name="COUNT_FILTER_ENABLED" value="false"/>
-
- <option name="COUNT_FILTER" value="0"/>
-
- <option name="CONDITION_ENABLED" value="false"/>
-
- <option name="CLASS_FILTERS_ENABLED" value="false"/>
-
- <option name="INSTANCE_FILTERS_ENABLED" value="false"/>
-
- <option name="CONDITION" value=""/>
-
- <option name="LOG_MESSAGE" value=""/>
-
- </breakpoint>
-
- <breakpoint>
-
- <option name="NOTIFY_CAUGHT" value="true"/>
-
- <option name="NOTIFY_UNCAUGHT" value="true"/>
-
- <option name="ENABLED" value="false"/>
-
- <option name="LOG_ENABLED" value="false"/>
-
- <option name="LOG_EXPRESSION_ENABLED" value="false"/>
-
- <option name="SUSPEND_POLICY" value="SuspendAll"/>
-
- <option name="COUNT_FILTER_ENABLED" value="false"/>
-
- <option name="COUNT_FILTER" value="0"/>
-
- <option name="CONDITION_ENABLED" value="false"/>
-
- <option name="CLASS_FILTERS_ENABLED" value="false"/>
-
- <option name="INSTANCE_FILTERS_ENABLED" value="false"/>
-
- <option name="CONDITION" value=""/>
-
- <option name="LOG_MESSAGE" value=""/>
-
- </breakpoint>
-
- </breakpoint_any>
-
- <breakpoint_rules/>
-
- <ui_properties/>
-
- </component>
-
- <component name="ModuleEditorState">
-
- <option name="LAST_EDITED_MODULE_NAME"/>
-
- <option name="LAST_EDITED_TAB_NAME"/>
-
- </component>
-
- <component name="ProjectInspectionProfilesVisibleTreeState">
-
- <entry key="Project Default">
-
- <profile-state/>
-
- </entry>
-
- </component>
-
- <component name="ProjectLevelVcsManager">
-
- <OptionsSetting id="Add" value="true"/>
-
- <OptionsSetting id="Remove" value="true"/>
-
- <OptionsSetting id="Checkout" value="true"/>
-
- <OptionsSetting id="Update" value="true"/>
-
- <OptionsSetting id="Status" value="true"/>
-
- <OptionsSetting id="Edit" value="true"/>
-
- <ConfirmationsSetting id="Add" value="0"/>
-
- <ConfirmationsSetting id="Remove" value="0"/>
-
- </component>
-
- <component name="ProjectReloadState">
-
- <option name="STATE" value="0"/>
-
- </component>
-
- <component name="PropertiesComponent">
-
- <property name="GoToFile.includeJavaFiles" value="false"/>
-
- <property name="GoToClass.toSaveIncludeLibraries" value="false"/>
-
- <property name="MemberChooser.sorted" value="false"/>
-
- <property name="MemberChooser.showClasses" value="true"/>
-
- <property name="GoToClass.includeLibraries" value="false"/>
-
- <property name="MemberChooser.copyJavadoc" value="false"/>
-
- </component>
-
- <component name="RunManager">
-
- <configuration default="true" factoryName="Remote" type="Remote">
-
- <option name="USE_SOCKET_TRANSPORT" value="true"/>
-
- <option name="SERVER_MODE" value="false"/>
-
- <option name="SHMEM_ADDRESS" value="javadebug"/>
-
- <option name="HOST" value="localhost"/>
-
- <option name="PORT" value="5005"/>
-
- <method>
-
- <option enabled="false" name="BuildArtifacts"/>
-
- </method>
-
- </configuration>
-
- <configuration default="true" factoryName="Applet" type="Applet">
-
- <module name=""/>
-
- <option name="MAIN_CLASS_NAME"/>
-
- <option name="HTML_FILE_NAME"/>
-
- <option name="HTML_USED" value="false"/>
-
- <option name="WIDTH" value="400"/>
-
- <option name="HEIGHT" value="300"/>
-
- <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy"/>
-
- <option name="VM_PARAMETERS"/>
-
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
-
- <option name="ALTERNATIVE_JRE_PATH"/>
-
- <method>
-
- <option enabled="false" name="BuildArtifacts"/>
-
- <option enabled="true" name="Make"/>
-
- </method>
-
- </configuration>
-
- <configuration default="true" factoryName="Application" type="Application">
-
- <extension enabled="false" merge="false" name="coverage"/>
-
- <option name="MAIN_CLASS_NAME"/>
-
- <option name="VM_PARAMETERS"/>
-
- <option name="PROGRAM_PARAMETERS"/>
-
- <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$"/>
-
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
-
- <option name="ALTERNATIVE_JRE_PATH"/>
-
- <option name="ENABLE_SWING_INSPECTOR" value="false"/>
-
- <option name="ENV_VARIABLES"/>
-
- <option name="PASS_PARENT_ENVS" value="true"/>
-
- <module name=""/>
-
- <envs/>
-
- <method>
-
- <option enabled="false" name="BuildArtifacts"/>
-
- <option enabled="true" name="Make"/>
-
- </method>
-
- </configuration>
-
- <configuration default="true" factoryName="JUnit" type="JUnit">
-
- <extension enabled="false" merge="false" name="coverage"/>
-
- <module name=""/>
-
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
-
- <option name="ALTERNATIVE_JRE_PATH"/>
-
- <option name="PACKAGE_NAME"/>
-
- <option name="MAIN_CLASS_NAME"/>
-
- <option name="METHOD_NAME"/>
-
- <option name="TEST_OBJECT" value="class"/>
-
- <option name="VM_PARAMETERS"/>
-
- <option name="PARAMETERS"/>
-
- <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$"/>
-
- <option name="ENV_VARIABLES"/>
-
- <option name="PASS_PARENT_ENVS" value="true"/>
-
- <option name="TEST_SEARCH_SCOPE">
-
- <value defaultName="moduleWithDependencies"/>
-
- </option>
-
- <envs/>
-
- <method>
-
- <option enabled="false" name="BuildArtifacts"/>
-
- <option enabled="true" name="Make"/>
-
- </method>
-
- </configuration>
-
- <list size="0"/>
-
- <configuration default="true" name="&lt;template&gt;" selected="false" type="WebApp">
-
- <Host>localhost</Host>
-
- <Port>5050</Port>
-
- </configuration>
-
- <component name="ProjectRunConfigurationManager"/>
- <configuration default="false" factoryName="Application" name="Minecraft Client" type="Application">
- <module name="examplemod.main"/>
- <option name="MAIN_CLASS_NAME" value="net.fabricmc.devlaunchinjector.Main"/>
- <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/run"/>
- <option name="VM_PARAMETERS" value="&quot;-Dfabric.dli.config=/home/nea/src/ModernJavaLauncher/.gradle/loom-cache/launch.cfg&quot; &quot;-Dfabric.dli.env=client&quot; &quot;-Dfabric.dli.main=net.minecraft.launchwrapper.Launch&quot;"/>
- </configuration>
- <component name="ProjectRunConfigurationManager"/>
- <configuration default="false" factoryName="Application" name="Minecraft Server" type="Application">
- <module name="examplemod.main"/>
- <option name="MAIN_CLASS_NAME" value="net.fabricmc.devlaunchinjector.Main"/>
- <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/run"/>
- <option name="VM_PARAMETERS" value="&quot;-Dfabric.dli.config=/home/nea/src/ModernJavaLauncher/.gradle/loom-cache/launch.cfg&quot; &quot;-Dfabric.dli.env=server&quot; &quot;-Dfabric.dli.main=net.minecraft.launchwrapper.Launch&quot;"/>
- <option name="PROGRAM_PARAMETERS" value="&quot;nogui&quot;"/>
- </configuration>
- </component>
-
- <component name="ShelveChangesManager" show_recycled="false"/>
-
- <component maxAnnotateRevisions="500" name="SvnConfiguration">
-
- <option name="USER" value=""/>
-
- <option name="PASSWORD" value=""/>
-
- <option name="LAST_MERGED_REVISION"/>
-
- <option name="UPDATE_RUN_STATUS" value="false"/>
-
- <option name="MERGE_DRY_RUN" value="false"/>
-
- <option name="MERGE_DIFF_USE_ANCESTRY" value="true"/>
-
- <option name="UPDATE_LOCK_ON_DEMAND" value="false"/>
-
- <option name="IGNORE_SPACES_IN_MERGE" value="false"/>
-
- <option name="DETECT_NESTED_COPIES" value="true"/>
-
- <option name="IGNORE_SPACES_IN_ANNOTATE" value="true"/>
-
- <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true"/>
-
- <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
-
- </component>
-
- <component name="TaskManager">
-
- <task active="true" id="Default" summary="Default task"/>
-
- <servers/>
-
- </component>
-
- <component name="VcsManagerConfiguration">
-
- <option name="OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT" value="true"/>
-
- <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="true"/>
-
- <option name="PERFORM_UPDATE_IN_BACKGROUND" value="true"/>
-
- <option name="PERFORM_COMMIT_IN_BACKGROUND" value="true"/>
-
- <option name="PERFORM_EDIT_IN_BACKGROUND" value="true"/>
-
- <option name="PERFORM_CHECKOUT_IN_BACKGROUND" value="true"/>
-
- <option name="PERFORM_ADD_REMOVE_IN_BACKGROUND" value="true"/>
-
- <option name="PERFORM_ROLLBACK_IN_BACKGROUND" value="false"/>
-
- <option name="CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND" value="false"/>
-
- <option name="ENABLE_BACKGROUND_PROCESSES" value="false"/>
-
- <option name="CHANGED_ON_SERVER_INTERVAL" value="60"/>
-
- <option name="FORCE_NON_EMPTY_COMMENT" value="false"/>
-
- <option name="LAST_COMMIT_MESSAGE"/>
-
- <option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true"/>
-
- <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false"/>
-
- <option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false"/>
-
- <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false"/>
-
- <option name="REFORMAT_BEFORE_FILE_COMMIT" value="false"/>
-
- <option name="FILE_HISTORY_DIALOG_COMMENTS_SPLITTER_PROPORTION" value="0.8"/>
-
- <option name="FILE_HISTORY_DIALOG_SPLITTER_PROPORTION" value="0.5"/>
-
- <option name="ACTIVE_VCS_NAME"/>
-
- <option name="UPDATE_GROUP_BY_PACKAGES" value="false"/>
-
- <option name="UPDATE_GROUP_BY_CHANGELIST" value="false"/>
-
- <option name="SHOW_FILE_HISTORY_AS_TREE" value="false"/>
-
- <option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6"/>
-
- </component>
-
- <component name="XDebuggerManager">
-
- <breakpoint-manager/>
-
- </component>
-
-</project>
diff --git a/install.sh b/install.sh
index 89a94d8..4415fcc 100755
--- a/install.sh
+++ b/install.sh
@@ -2,9 +2,9 @@
set -euo pipefail
-rm -f ~/.local/share/PrismLauncher/instances/1.8.9/.minecraft/mods/examplemod-*
-./gradlew :build :target:build
-cp ./build/libs/examplemod-1.0.0.jar ~/.local/share/PrismLauncher/instances/1.8.9/.minecraft/mods
+rm -f ~/.local/share/PrismLauncher/instances/1.8.9/.minecraft/mods/ModernJavaLauncher-*
+./gradlew :agent:build :build
+cp ./build/libs/ModernJavaLauncher-1.0.0.jar ~/.local/share/PrismLauncher/instances/1.8.9/.minecraft/mods
diff --git a/src/main/java/moe/nea/modernjava/launch/live/FCPFixTweaker.java b/src/main/java/moe/nea/modernjava/launch/live/FCPFixTweaker.java
index a5bf648..0fe2285 100644
--- a/src/main/java/moe/nea/modernjava/launch/live/FCPFixTweaker.java
+++ b/src/main/java/moe/nea/modernjava/launch/live/FCPFixTweaker.java
@@ -17,6 +17,8 @@ public class FCPFixTweaker implements ITweaker {
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
+ classLoader.addClassLoaderExclusion("moe.nea.modernjava.");
+ classLoader.addClassLoaderExclusion("kotlin.");
classLoader.registerTransformer("moe.nea.modernjava.launch.transform.TransObjectHolderRef");
}
diff --git a/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java b/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java
index 04fb0ea..fe74c42 100644
--- a/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java
+++ b/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java
@@ -5,10 +5,14 @@ import moe.nea.modernjava.launch.util.TextIoUtils;
import moe.nea.modernjava.launch.util.WellKnownBlackboard;
import net.minecraftforge.fml.common.launcher.FMLTweaker;
import net.minecraftforge.fml.nea.moe.modernjava.IAMFML;
+import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.lang.management.ManagementFactory;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -42,7 +46,21 @@ public class FCPRelauncher {
}
public static File findJavaLauncher() {
- return new File("/home/nea/.sdkman/candidates/java/16.0.2-tem/bin/java")
+ return new File("/home/nea/.sdkman/candidates/java/16.0.2-tem/bin/java");
+ }
+
+ public static File findAgentJar() {
+ try {
+ File file = File.createTempFile("mjr-agent", ".jar");
+ try (InputStream is = FCPRelauncher.class.getResourceAsStream("/agent/agent.jar");
+ OutputStream os = Files.newOutputStream(file.toPath())) {
+ assert is != null;
+ IOUtils.copy(is, os);
+ }
+ return file;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
public static void relaunch() {
@@ -50,12 +68,11 @@ public class FCPRelauncher {
List<String> originalArgs = getOriginalArguments();
File modernJavaPath = findJavaLauncher();
+ System.out.println("Located modern minecraft at: " + modernJavaPath);
+ File agentFile = findAgentJar();
+ System.out.println("Located agent jar at: " + agentFile);
- File agentFile;
- agentFile = new File("/home/nea/src/ModernJavaLauncher/target/build/libs/target.jar");
-
- System.out.println("Located modern minecraft at: " + modernJavaPath);
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.inheritIO();
@@ -80,10 +97,10 @@ public class FCPRelauncher {
}
if (System.getProperty(PropertyNames.DEBUG_PORT) != null)
fullCommandLine.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:" + System.getProperty(PropertyNames.DEBUG_PORT));
- fullCommandLine.add("-javaagent:" + agentFile);
+ fullCommandLine.add("-javaagent:" + agentFile.getAbsolutePath());
fullCommandLine.add("--add-modules=ALL-MODULE-PATH,ALL-SYSTEM,ALL-DEFAULT,java.sql");
- fullCommandLine.add("-Xbootclasspath/a:" + agentFile);
- fullCommandLine.add("moe.nea.modernjava.target.RelaunchEntryPoint");
+ fullCommandLine.add("-Xbootclasspath/a:" + agentFile.getAbsolutePath());
+ fullCommandLine.add("moe.nea.modernjava.agent.RelaunchEntryPoint");
fullCommandLine.addAll(originalArgs);
System.out.println("Full relaunch commandline: " + fullCommandLine);