mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Refactor: Change Build Method
This commit is contained in:
1 parent
7c303b6cfd
commit
46dd94dcf9
5 files changed
+252
-32
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="OrangeX-Client [buildInjector]" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<configuration default="false" name="OrangeX-Client [buildAll]" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
@@ -10,7 +10,7 @@
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="buildInjector" />
|
||||
<option value="buildAll" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
Generated
+2
-2
@@ -1,10 +1,10 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Injector" type="JarApplication">
|
||||
<option name="JAR_PATH" value="$PROJECT_DIR$/out/Injector.jar" />
|
||||
<option name="WORKING_DIRECTORY" value="D:\Development\OrangeX-Client" />
|
||||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$\out" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<method v="2">
|
||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="OrangeX-Client [buildInjector]" run_configuration_type="GradleRunConfiguration" />
|
||||
<option name="RunConfigurationTask" enabled="false" run_configuration_name="OrangeX-Client [buildInjector]" run_configuration_type="GradleRunConfiguration" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
Generated
+124
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
@@ -3,6 +3,7 @@ package cn.xiaozhou233.orangex.injector;
|
||||
import cn.xiaozhou233.juiceagent.injector.InjectorNative;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -17,13 +18,16 @@ public class Injector {
|
||||
|
||||
int pid = -1;
|
||||
|
||||
// Unzip injection.zip to ~/.orangex
|
||||
System.out.println("Unzip injection.zip to " + orangexPath);
|
||||
try (InputStream zipStream = ClassLoader.getSystemResourceAsStream("injection.zip")) {
|
||||
if (zipStream == null) {
|
||||
System.err.println("ZIP resource not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
File zipFile = new File("injection.zip");
|
||||
|
||||
if (!zipFile.exists()) {
|
||||
System.err.println("injection.zip not found in runtime directory!");
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream zipStream = new FileInputStream(zipFile)) {
|
||||
FileUtils.unzip(zipStream, new File(orangexPath));
|
||||
System.out.println("Done!");
|
||||
} catch (IOException e) {
|
||||
|
||||
+114
-22
@@ -1,64 +1,156 @@
|
||||
// ░██████ ░██ ░██
|
||||
// ░██ ░██ ░██ ░██
|
||||
//░██ ░██ ░██░████ ░██████ ░████████ ░████████ ░███████ ░██░██
|
||||
//░██ ░██ ░███ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░███
|
||||
//░██ ░██ ░██ ░███████ ░██ ░██ ░██ ░██ ░█████████ ░██░██
|
||||
// ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░███ ░██ ░██ ░██
|
||||
// ░██████ ░██ ░█████░██ ░██ ░██ ░█████░██ ░███████ ░██ ░██
|
||||
// ░██
|
||||
// ░███████
|
||||
//
|
||||
|
||||
plugins {
|
||||
id 'lifecycle-base'
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Variables
|
||||
// ============================
|
||||
def JuiceAgentJar = "libraries/JuiceAgent-API-1.4.0+build.1.jar"
|
||||
def outDir = layout.projectDirectory.dir("out")
|
||||
def tmpDir = layout.projectDirectory.dir("out/tmp")
|
||||
def runBatFile = layout.projectDirectory.file("out/run.bat")
|
||||
|
||||
// ============================
|
||||
// Clean output directory
|
||||
// ============================
|
||||
tasks.register('cleanOut', Delete) {
|
||||
delete("$outDir/Injector.jar", "$outDir/injection.zip", runBatFile)
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Build injection
|
||||
// ============================
|
||||
tasks.register("buildInjection", Copy) {
|
||||
group = 'build'
|
||||
description = 'Build and collect all jars + resources into out/tmp'
|
||||
description = 'Build injection and copy all required files to tmp directory'
|
||||
|
||||
// Incremental build: only copy changed files
|
||||
outputs.upToDateWhen { false } // optional: force always check, can remove for caching
|
||||
|
||||
dependsOn(
|
||||
project(':OrangeX').tasks.named('build'),
|
||||
project(':Loader').tasks.named('build')
|
||||
project(':OrangeX').tasks.named('shadowJar'),
|
||||
project(':Loader').tasks.named('shadowJar')
|
||||
)
|
||||
|
||||
into(layout.projectDirectory.dir('out/tmp'))
|
||||
into(tmpDir)
|
||||
|
||||
from(project(':OrangeX').tasks.named('shadowJar').map { it.archiveFile }) {
|
||||
rename { 'OrangeX.jar' }
|
||||
}
|
||||
|
||||
from(project(':Loader').tasks.named('shadowJar').map { it.archiveFile }) {
|
||||
rename { 'Entry.jar' }
|
||||
}
|
||||
|
||||
from(layout.projectDirectory.dir('natives'))
|
||||
from(layout.projectDirectory.dir('resources'))
|
||||
from(layout.projectDirectory.file('libraries/JuiceLoader.jar'))
|
||||
|
||||
from(layout.projectDirectory.file(JuiceAgentJar)) {
|
||||
rename { 'JuiceAgent.jar' }
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Package injection into injection.zip
|
||||
// ============================
|
||||
tasks.register("packInjection", Zip) {
|
||||
group = 'build'
|
||||
description = 'Package all collected files into injection.zip'
|
||||
description = 'Package all files from tmp into injection.zip'
|
||||
|
||||
dependsOn(tasks.named("buildInjection"))
|
||||
|
||||
destinationDirectory.set(layout.projectDirectory.dir("out"))
|
||||
destinationDirectory.set(outDir)
|
||||
archiveFileName.set("injection.zip")
|
||||
|
||||
from(layout.projectDirectory.dir("out/tmp"))
|
||||
from(tmpDir)
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Build Injector.jar
|
||||
// ============================
|
||||
tasks.register("buildInjector", Jar) {
|
||||
group = 'build'
|
||||
description = 'Build Injector.jar including injection.zip'
|
||||
description = 'Build Injector.jar including injection.zip and subproject jar'
|
||||
|
||||
dependsOn(tasks.named("packInjection"))
|
||||
dependsOn(project(':Injector').tasks.named('shadowJar'))
|
||||
dependsOn(
|
||||
tasks.named("packInjection"),
|
||||
project(':Injector').tasks.named('shadowJar')
|
||||
)
|
||||
|
||||
destinationDirectory.set(layout.projectDirectory.dir("out"))
|
||||
destinationDirectory.set(outDir)
|
||||
archiveFileName.set("Injector.jar")
|
||||
|
||||
from(zipTree(project(':Injector').tasks.named('shadowJar').map { it.archiveFile })) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
from(layout.projectDirectory.file("out/injection.zip")) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'cn.xiaozhou233.orangex.injector.Injector'
|
||||
)
|
||||
}
|
||||
|
||||
doLast {
|
||||
delete('out/injection.zip')
|
||||
attributes('Main-Class': 'cn.xiaozhou233.orangex.injector.Injector')
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Generate run.bat
|
||||
// ============================
|
||||
tasks.register("generateRunBat") {
|
||||
group = 'build'
|
||||
description = 'Generate run.bat to run Injector.jar'
|
||||
|
||||
dependsOn(tasks.named("buildInjector"))
|
||||
|
||||
outputs.file(runBatFile)
|
||||
|
||||
doLast {
|
||||
runBatFile.asFile.text =
|
||||
"""@echo off
|
||||
java -jar Injector.jar
|
||||
pause
|
||||
"""
|
||||
println("run.bat generated in 'out/' folder")
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Main build task
|
||||
// ============================
|
||||
tasks.register("buildAll") {
|
||||
dependsOn(tasks.named("generateRunBat"))
|
||||
|
||||
doFirst {
|
||||
println("Building OrangeX-Client...")
|
||||
}
|
||||
|
||||
doLast {
|
||||
println("Build finished! Injector.jar, injection.zip, and run.bat are in 'out/' folder.")
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Task execution order chain
|
||||
// ============================
|
||||
tasks.named("buildInjection") {
|
||||
dependsOn(tasks.named("cleanOut"))
|
||||
}
|
||||
|
||||
tasks.named("packInjection") {
|
||||
dependsOn(tasks.named("buildInjection"))
|
||||
}
|
||||
|
||||
tasks.named("buildInjector") {
|
||||
dependsOn(tasks.named("packInjection"))
|
||||
}
|
||||
|
||||
tasks.named("generateRunBat") {
|
||||
dependsOn(tasks.named("buildInjector"))
|
||||
}
|
||||
Reference in new issue
Block a user