Skip to content

Commit

Permalink
feat: allow setting extra manifest entries for bundler jars
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Nov 18, 2024
1 parent 6408556 commit d075ac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class BundlerJarTasks(

paperclip.from(configurations.named(PAPERCLIP_CONFIG))
mainClass.set(mainClassString)
extraManifestMainAttributes.convention(mapOf("Enable-Native-Access" to "ALL-UNNAMED"))

outputZip.set(layout.buildDirectory.file("libs/${jarName("bundler", classifier)}"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.gradle.api.artifacts.component.ProjectComponentIdentifier
import org.gradle.api.artifacts.result.ResolvedArtifactResult
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.*
Expand Down Expand Up @@ -72,6 +73,10 @@ abstract class CreateBundlerJar : ZippedTask() {
@get:Classpath
abstract val vanillaBundlerJar: RegularFileProperty

@get:Input
@get:Optional
abstract val extraManifestMainAttributes: MapProperty<String, String>

@get:OutputFile
abstract val libraryChangesJson: RegularFileProperty

Expand Down Expand Up @@ -106,6 +111,12 @@ abstract class CreateBundlerJar : ZippedTask() {
}
}

if (extraManifestMainAttributes.isPresent) {
modifyManifest(rootDir.resolve("META-INF/MANIFEST.MF")) {
extraManifestMainAttributes.get().forEach { (k, v) -> mainAttributes.putValue(k, v) }
}
}

rootDir.resolve("META-INF/main-class").writeText(mainClass.get())

// copy version.json file
Expand Down

0 comments on commit d075ac0

Please sign in to comment.