diff options
-rw-r--r-- | build.sbt | 5 | ||||
-rw-r--r-- | build.xml | 14 | ||||
-rw-r--r-- | project/Osgi.scala | 13 |
3 files changed, 28 insertions, 4 deletions
@@ -346,6 +346,7 @@ lazy val library = configureAsSubproject(project) base ** "*.txt" pair relativeTo(base) }, Osgi.headers += "Import-Package" -> "sun.misc;resolution:=optional, *", + Osgi.jarlist := true, fixPom( "/project/name" -> <name>Scala Library</name>, "/project/description" -> <description>Standard library for the Scala Programming Language</description>, @@ -412,13 +413,15 @@ lazy val compiler = configureAsSubproject(project) scalacOptions in Compile in doc ++= Seq( "-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt" ), - Osgi.headers += + Osgi.headers ++= Seq( "Import-Package" -> ("jline.*;resolution:=optional," + "org.apache.tools.ant.*;resolution:=optional," + "scala.util.parsing.*;version=\"${range;[====,====];"+versionNumber("scala-parser-combinators")+"}\";resolution:=optional," + "scala.xml.*;version=\"${range;[====,====];"+versionNumber("scala-xml")+"}\";resolution:=optional," + "scala.*;version=\"${range;[==,=+);${ver}}\"," + "*"), + "Class-Path" -> "scala-reflect.jar scala-library.jar" + ), // Generate the ScriptEngineFactory service definition. The ant build does this when building // the JAR but sbt has no support for it and it is easier to do as a resource generator: generateServiceProviderResources("javax.script.ScriptEngineFactory" -> "scala.tools.nsc.interpreter.IMain$Factory"), @@ -273,6 +273,10 @@ TODO: <dependency groupId="org.pantsbuild" artifactId="jarjar" version="1.6.0"/> </artifact:dependencies> + <artifact:dependencies pathId="jarlister.classpath"> + <dependency groupId="com.github.rjolly" artifactId="jarlister_2.11" version="1.0"/> + </artifact:dependencies> + <!-- JUnit --> <property name="junit.version" value="4.12"/> <artifact:dependencies pathId="junit.classpath" filesetId="junit.fileset"> @@ -787,6 +791,11 @@ TODO: <path refid="aux.libs"/> </path> + <path id="pack.lib.path"> + <pathelement location="${library.jar}"/> + <path refid="jarlister.classpath"/> + </path> + <path id="pack.bin.tool.path"> <pathelement location="${library.jar}"/> <pathelement location="${xml.jar}"/> @@ -1138,7 +1147,10 @@ TODO: <!-- =========================================================================== PACKED QUICK BUILD (PACK) ============================================================================ --> - <target name="pack.lib" depends="quick.lib"> <staged-pack project="library"/></target> + <target name="pack.lib" depends="quick.lib"> <staged-pack project="library"/> + <taskdef resource="scala/tools/ant/antlib.xml" classpathref="pack.lib.path"/> + <jarlister file="${library.jar}"/> + </target> <target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target> diff --git a/project/Osgi.scala b/project/Osgi.scala index 36803c0e44..9b00379760 100644 --- a/project/Osgi.scala +++ b/project/Osgi.scala @@ -1,6 +1,7 @@ import aQute.bnd.osgi.Builder import aQute.bnd.osgi.Constants._ import java.util.Properties +import java.util.jar.Attributes import sbt._ import sbt.Keys._ import collection.JavaConverters._ @@ -16,6 +17,7 @@ object Osgi { val bundleName = SettingKey[String]("osgiBundleName", "The Bundle-Name for the manifest.") val bundleSymbolicName = SettingKey[String]("osgiBundleSymbolicName", "The Bundle-SymbolicName for the manifest.") val headers = SettingKey[Seq[(String, String)]]("osgiHeaders", "Headers and processing instructions for BND.") + val jarlist = SettingKey[Boolean]("osgiJarlist", "List classes in manifest.") def settings: Seq[Setting[_]] = Seq( bundleName := description.value, @@ -33,9 +35,10 @@ object Osgi { "-eclipse" -> "false" ) }, + jarlist := false, bundle <<= Def.task { val res = (products in Compile in packageBin).value - bundleTask(headers.value.toMap, (products in Compile in packageBin).value, + bundleTask(headers.value.toMap, jarlist.value, (products in Compile in packageBin).value, (artifactPath in (Compile, packageBin)).value, res, streams.value) }, packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), bundle).identityMap, @@ -48,7 +51,7 @@ object Osgi { ) ) - def bundleTask(headers: Map[String, String], fullClasspath: Seq[File], artifactPath: File, + def bundleTask(headers: Map[String, String], jarlist: Boolean, fullClasspath: Seq[File], artifactPath: File, resourceDirectories: Seq[File], streams: TaskStreams): File = { val log = streams.log val builder = new Builder @@ -63,6 +66,12 @@ object Osgi { builder.getWarnings.asScala.foreach(s => log.warn(s"bnd: $s")) builder.getErrors.asScala.foreach(s => log.error(s"bnd: $s")) IO.createDirectory(artifactPath.getParentFile) + if (jarlist) { + val entries = jar.getManifest.getEntries + for ((name, resource) <- jar.getResources.asScala if name.endsWith(".class")) { + entries.put(name, new Attributes) + } + } jar.write(artifactPath) artifactPath } |