com-lihaoyi / mill

Your shiny new Java/Scala build tool!
https://mill-build.com/
MIT License
2k stars 308 forks source link

How to add `Premain-Class` attribute to JAR manifest? #3133

Closed amordahl closed 2 months ago

amordahl commented 2 months ago

I am new to using Mill, and I am trying to build an instrumentation agent, but I can't figure out how to generate a manifest file that includes a Premain-Class attribute. I noticed issue 624 said that "You can overwrite the def manifest: T[JarManifest] target and append any manifest entry you want" but I'm not really sure how to achieve this. Thanks!

lefou commented 2 months ago

You can add a Premain-Class entry to the manifest by overriding the manifest target of your JavaModule or ScalaModule:

def manifest = T {
  super.manifest().add("Premain-Class" -> "org.example.PremainAgent")
}