diff options
author | rockjam <5min4eq.unity@gmail.com> | 2016-06-24 06:57:11 +0300 |
---|---|---|
committer | rockjam <5min4eq.unity@gmail.com> | 2016-06-24 07:27:36 +0300 |
commit | e709c5f02290680cd05c18e470b57decb931e62d (patch) | |
tree | 63d5015ff71cb464dbb430ffeff5caec304a1001 /stage2 | |
parent | 9768c740095672aaad55309ec9b1ce88f7f840be (diff) | |
download | cbt-e709c5f02290680cd05c18e470b57decb931e62d.tar.gz cbt-e709c5f02290680cd05c18e470b57decb931e62d.tar.bz2 cbt-e709c5f02290680cd05c18e470b57decb931e62d.zip |
update uber jar PR
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/Lib.scala | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 8dd6e72..2e3c0e5 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -214,15 +214,19 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } yield file } - def jarFile( jarFile: File, files: Seq[File] ): Option[File] = { + def jarFile( jarFile: File, files: Seq[File], mainClass: Option[String] = None ): Option[File] = { if( files.isEmpty ){ None } else { jarFile.getParentFile.mkdirs logger.lib("Start packaging "++jarFile.string) - val manifest = new Manifest - manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0") - val jar = new JarOutputStream(new FileOutputStream(jarFile.toString), manifest) + val manifest = new Manifest() + manifest.getMainAttributes.put(Attributes.Name.MANIFEST_VERSION, "1.0") + manifest.getMainAttributes.putValue("Created-By", + Option(System.getProperty("java.runtime.version")) getOrElse "1.7.0_06 (Oracle Corporation)") + mainClass foreach { className => manifest.getMainAttributes.put(Attributes.Name.MAIN_CLASS, className) + } + val jar = new JarOutputStream(new FileOutputStream(jarFile), manifest) try{ val names = for { base <- files.filter(_.exists).map(realpath) @@ -235,7 +239,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ entry.setTime(file.lastModified) jar.putNextEntry(entry) jar.write( readAllBytes( file.toPath ) ) - jar.closeEntry + jar.closeEntry() name } @@ -245,7 +249,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ s"Conflicting file names when trying to create $jarFile: "++duplicateFiles.mkString(", ") ) } finally { - jar.close + jar.close() } logger.lib("Done packaging " ++ jarFile.toString) |