-
Notifications
You must be signed in to change notification settings - Fork 36
Early plugin support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: plugin
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,6 +64,12 @@ tasks.register('updatePluginManifest') { | |||||||||||||||||||||||||||||||||||||||||||||
| def manifestFile = file('src/main/resources/manifest.json') | ||||||||||||||||||||||||||||||||||||||||||||||
| doLast { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!manifestFile.exists()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (early_plugin.toBoolean()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // Early plugins do not require a manifest.json file. | ||||||||||||||||||||||||||||||||||||||||||||||
| // We still want to update the manifest if it exists, because an | ||||||||||||||||||||||||||||||||||||||||||||||
| // early plugin can also 'contain' and behave as a regular plugin. | ||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| throw new GradleException("Could not find manifest.json at ${manifestFile.path}!") | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| def manifestJson = new groovy.json.JsonSlurper().parseText(manifestFile.text) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -81,6 +87,17 @@ tasks.named('processResources') { | |||||||||||||||||||||||||||||||||||||||||||||
| def createServerRunArguments(String srcDir) { | ||||||||||||||||||||||||||||||||||||||||||||||
| def programParameters = '--allow-op --disable-sentry --assets="' + "${hytaleHome}/install/$patchline/package/game/latest/Assets.zip" + '"' | ||||||||||||||||||||||||||||||||||||||||||||||
| def modPaths = [] | ||||||||||||||||||||||||||||||||||||||||||||||
| if (early_plugin.toBoolean()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||
| * To enable ClassTransformers, Hytale Server requires that we give it the path | ||||||||||||||||||||||||||||||||||||||||||||||
| * to a folder that contains ANY jar file. | ||||||||||||||||||||||||||||||||||||||||||||||
| * The jar file could be empty, or be the server jar itself for all it cares. | ||||||||||||||||||||||||||||||||||||||||||||||
| * At a point in the future this might get changed, but for now we have to do something like this. | ||||||||||||||||||||||||||||||||||||||||||||||
| * See EarlyPluginLoader class for more details. | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| def generatedJarFileParentPath = "${projectDir.absolutePath}/build/libs" | ||||||||||||||||||||||||||||||||||||||||||||||
| programParameters += " --accept-early-plugins --early-plugins=${generatedJarFileParentPath}" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| if (includes_pack.toBoolean()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| modPaths << srcDir | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -101,13 +118,23 @@ idea.project.settings.runConfigurations { | |||||||||||||||||||||||||||||||||||||||||||||
| moduleName = project.idea.module.name + '.main' | ||||||||||||||||||||||||||||||||||||||||||||||
| programParameters = createServerRunArguments(sourceSets.main.java.srcDirs.first().parentFile.absolutePath) | ||||||||||||||||||||||||||||||||||||||||||||||
| workingDirectory = serverRunDir.absolutePath | ||||||||||||||||||||||||||||||||||||||||||||||
| if (early_plugin.toBoolean()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that the Gradle task to build the jar is run before launching | ||||||||||||||||||||||||||||||||||||||||||||||
| // so that the early-plugins folder contains a jar file. | ||||||||||||||||||||||||||||||||||||||||||||||
| beforeRun { | ||||||||||||||||||||||||||||||||||||||||||||||
| 'GradleTask'(org.jetbrains.gradle.ext.GradleTask) { | ||||||||||||||||||||||||||||||||||||||||||||||
| task = jar | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+121
to
+129
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If building the plugin jar is not needed anymore
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Creates a launch.json file for VSCode with the same configuration | ||||||||||||||||||||||||||||||||||||||||||||||
| tasks.register('generateVSCodeLaunch') { | ||||||||||||||||||||||||||||||||||||||||||||||
| def vscodeDir = file("$projectDir/.vscode") | ||||||||||||||||||||||||||||||||||||||||||||||
| def launchFile = file("$vscodeDir/launch.json") | ||||||||||||||||||||||||||||||||||||||||||||||
| def tasksFile = file("$vscodeDir/tasks.json") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If building the plugin jar is not needed anymore
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| doLast { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!vscodeDir.exists()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| vscodeDir.mkdirs() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -126,6 +153,28 @@ tasks.register('generateVSCodeLaunch') { | |||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| if (early_plugin.toBoolean()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that the Gradle task to build the jar is run before launching | ||||||||||||||||||||||||||||||||||||||||||||||
| // so that the early-plugins folder contains a jar file. | ||||||||||||||||||||||||||||||||||||||||||||||
| launchConfig.configurations[0].preLaunchTask = "gradle: jar" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def tasksConfig = [ | ||||||||||||||||||||||||||||||||||||||||||||||
| version: "2.0.0", | ||||||||||||||||||||||||||||||||||||||||||||||
| tasks: [ | ||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||
| "label": "gradle: jar", | ||||||||||||||||||||||||||||||||||||||||||||||
| "type": "shell", | ||||||||||||||||||||||||||||||||||||||||||||||
| "command": "./gradlew", | ||||||||||||||||||||||||||||||||||||||||||||||
| "args": ["jar"], | ||||||||||||||||||||||||||||||||||||||||||||||
| "problemMatcher": ["\$gradle"], | ||||||||||||||||||||||||||||||||||||||||||||||
| "windows": [ | ||||||||||||||||||||||||||||||||||||||||||||||
| "command": "gradlew.bat" | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
| tasksFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(tasksConfig)) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+156
to
+177
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If building the plugin jar is not needed anymore
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| launchFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(launchConfig)) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I've done here is use the generated plugin jar to enable ClassTransformer
But this requires us to build the jar before running the server, which is prone to errors. The generated jar directory can easily be modified for example.
What could be done here instead is to use the HytaleServer parent directory:
We would be sure that at least a jar is contained in the directory, and we would not have to build the plugin jar!
But it could lead to unexpected behavior if another jar is present in the HytaleServer parent directory.
I don't see a perfect solution here, but I'd be interested in hearing alternative approaches