-
Notifications
You must be signed in to change notification settings - Fork 1
Add GremlinJar and GremlinBootstrap #48
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
Draft
jpenilla
wants to merge
8
commits into
master
Choose a base branch
from
feat/gremlin-jar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b8c3d31
Add GremlinJar and GremlinBootstrap
jpenilla fa62b4a
Cleanup cache in GremlinBootstrap
jpenilla 4239baf
Improve manifest error handling
jpenilla cfe784f
Cleanup
jpenilla 631c8f8
Fix loading main with wrong context loader
jpenilla c301df6
adjust nesting strategy
jpenilla fe022f4
Use set for nestedJarsPaths
jpenilla e308bb3
specify UTF-8
jpenilla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
gradle-plugin/src/main/kotlin/xyz/jpenilla/gremlin/gradle/BootstrapJar.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * gremlin | ||
| * | ||
| * Copyright (c) 2025 Jason Penilla | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package xyz.jpenilla.gremlin.gradle | ||
|
|
||
| import org.gradle.api.file.ArchiveOperations | ||
| import org.gradle.api.file.ConfigurableFileCollection | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.InputFiles | ||
| import org.gradle.api.tasks.Optional | ||
| import org.gradle.api.tasks.TaskProvider | ||
| import org.gradle.jvm.tasks.Jar | ||
| import org.gradle.kotlin.dsl.attributes | ||
| import javax.inject.Inject | ||
|
|
||
| abstract class BootstrapJar : Jar() { | ||
| @get:InputFiles | ||
| abstract val gremlinRuntime: ConfigurableFileCollection | ||
|
|
||
| @get:Inject | ||
| abstract val archiveOps: ArchiveOperations | ||
|
|
||
| @get:Input | ||
| @get:Optional | ||
| abstract val mainClass: Property<String> | ||
|
|
||
| init { | ||
| manifest.attributes( | ||
| "Main-Class" to "xyz.jpenilla.gremlin.runtime.GremlinBootstrap", | ||
| ) | ||
| val runtime = gremlinRuntime.elements.map { | ||
| it.map { e -> | ||
| archiveOps.zipTree(e) | ||
| } | ||
| } | ||
| from(runtime) { | ||
| exclude("META-INF/*") | ||
| } | ||
| } | ||
|
|
||
| override fun copy() { | ||
| manifest.attributes( | ||
| "Gremlin-Main-Class" to mainClass.get(), | ||
| ) | ||
| super.copy() | ||
| } | ||
|
|
||
| fun nestJars(task: TaskProvider<out PrepareNestedJars>) { | ||
| from(task.flatMap { it.outputDir }) { | ||
| into("nested-jars") | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
gradle-plugin/src/main/kotlin/xyz/jpenilla/gremlin/gradle/PrepareNestedJars.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * gremlin | ||
| * | ||
| * Copyright (c) 2025 Jason Penilla | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package xyz.jpenilla.gremlin.gradle | ||
|
|
||
| import org.gradle.api.DefaultTask | ||
| import org.gradle.api.file.ConfigurableFileCollection | ||
| import org.gradle.api.file.DirectoryProperty | ||
| import org.gradle.api.tasks.InputFiles | ||
| import org.gradle.api.tasks.OutputDirectory | ||
| import org.gradle.api.tasks.TaskAction | ||
| import java.nio.file.Files | ||
| import kotlin.io.path.ExperimentalPathApi | ||
| import kotlin.io.path.deleteRecursively | ||
| import kotlin.io.path.writeText | ||
|
|
||
| @OptIn(ExperimentalPathApi::class) | ||
| abstract class PrepareNestedJars : DefaultTask() { | ||
| @get:OutputDirectory | ||
| abstract val outputDir: DirectoryProperty | ||
|
|
||
| @get:InputFiles | ||
| abstract val nestedJars: ConfigurableFileCollection | ||
|
|
||
| init { | ||
| init() | ||
| } | ||
|
|
||
| private fun init() { | ||
| outputDir.convention(project.layout.buildDirectory.dir("nested-jars/$name")) | ||
| } | ||
|
|
||
| @TaskAction | ||
| fun run() { | ||
| val outputPath = outputDir.path | ||
| outputPath.deleteRecursively() | ||
| Files.createDirectories(outputPath) | ||
|
|
||
| val index = mutableListOf<String>() | ||
| nestedJars.files.forEach { jar -> | ||
| Files.copy(jar.toPath(), outputPath.resolve(jar.name)) | ||
| index += jar.name | ||
| } | ||
| outputPath.resolve("index.txt").writeText(index.joinToString("\n")) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.