From ca1def4d6f5c829701e04f86dacb720bb57f036f Mon Sep 17 00:00:00 2001 From: Andrew Richards Date: Mon, 29 Jul 2019 13:56:01 +0100 Subject: add ability to define jar manifest (#634) * add capability to define jar manifest * Don't use the custom manifest for doc-only jars This is to pass test mill.scalalib.HelloWorldTests.scalaDocOptions * Add JarManifest.Default and fix the build rebase fix --- scalalib/src/JavaModule.scala | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'scalalib/src') diff --git a/scalalib/src/JavaModule.scala b/scalalib/src/JavaModule.scala index 7b373650..c7066d15 100644 --- a/scalalib/src/JavaModule.scala +++ b/scalalib/src/JavaModule.scala @@ -1,6 +1,9 @@ package mill package scalalib +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream + import coursier.Repository import mill.define.Task import mill.define.TaskModule @@ -256,6 +259,14 @@ trait JavaModule extends mill.Module with TaskModule { outer => upstreamAssemblyClasspath() } + /** + * Creates a manifest representation which can be modifed or replaced + * The default implementation just adds the `Manifest-Version`, `Main-Class` and `Created-By` attributes + */ + def manifest = T{ + Jvm.createManifest(finalMainClassOpt().toOption) + } + /** * Build the assembly for upstream dependencies separate from the current * classpath @@ -266,7 +277,7 @@ trait JavaModule extends mill.Module with TaskModule { outer => def upstreamAssembly = T{ createAssembly( upstreamAssemblyClasspath().map(_.path), - mainClass(), + manifest(), assemblyRules = assemblyRules ) } @@ -278,7 +289,7 @@ trait JavaModule extends mill.Module with TaskModule { outer => def assembly = T{ createAssembly( Agg.from(localClasspath().map(_.path)), - finalMainClassOpt().toOption, + manifest(), prependShellScript(), Some(upstreamAssembly().path), assemblyRules @@ -292,7 +303,7 @@ trait JavaModule extends mill.Module with TaskModule { outer => def jar = T{ createJar( localClasspath().map(_.path).filter(os.exists), - mainClass() + manifest() ) } @@ -345,7 +356,7 @@ trait JavaModule extends mill.Module with TaskModule { outer => * The source jar, containing only source code for publishing to Maven Central */ def sourceJar = T { - createJar((allSources() ++ resources()).map(_.path).filter(os.exists)) + createJar((allSources() ++ resources()).map(_.path).filter(os.exists), manifest()) } /** @@ -626,4 +637,3 @@ object TestModule{ } } } - -- cgit v1.2.3