diff --git a/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala b/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala index 294ef7e..c8e5028 100644 --- a/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala +++ b/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala @@ -181,7 +181,9 @@ private object Osgi { import _root_.java.nio.file._ import _root_.scala.collection.JavaConverters._ val path = tmpArtifactDirectoryPath.toPath - Files.walk(path).iterator.asScala.map(f => f.toFile -> path.relativize(f).toString).filterNot { case (_, p) => p == "META-INF/MANIFEST.MF" }.toTraversable + Files.walk(path).iterator.asScala.map(f => f.toFile -> path.relativize(f)) + .collect { case (f, p) if p != (file("META-INF") / "MANIFEST.MF").toPath => (f, p.toString) } + .toTraversable } IO.jar(content, tmpArtifactPath, manifest) diff --git a/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/build.sbt b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/build.sbt new file mode 100644 index 0000000..5a17371 --- /dev/null +++ b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/build.sbt @@ -0,0 +1,73 @@ +lazy val test08 = (project in file ("")).enablePlugins(SbtOsgi) + +organization := "com.typesafe.sbt" + +name := "sbt-osgi-test" + +version := "1.2.3" + +libraryDependencies += "org.osgi" % "org.osgi.core" % "4.3.0" % "provided" + +osgiSettings + +OsgiKeys.packageWithJVMJar := true + +TaskKey[Unit]("verifyBundleActivator") := { + val activator = OsgiKeys.bundleActivator.value + if (activator.isDefined) + sys.error("Expected bundle-activator to be None, but was %s!" format activator) +} + +TaskKey[Unit]("verifyBundleSymbolicName") := { + val name = OsgiKeys.bundleSymbolicName.value + if (name != "com.typesafe.sbt.osgi.test") + sys.error("Expected bundle-symbolic-name to be %s, but was %s!".format("com.typesafe.sbt.osgi.test", name)) +} + +TaskKey[Unit]("verifyBundleRequiredExecutionEnvironment") := { + val re = OsgiKeys.bundleRequiredExecutionEnvironment.value + if (re.nonEmpty) + sys.error("Expected bundleRequiredExecutionEnvironment to be Nil, but was %s!" format re) +} + +TaskKey[Unit]("verifyBundleVerion") := { + val version = OsgiKeys.bundleVersion.value + if (version != "1.2.3") + sys.error("Expected bundle-version to be %s, but was %s!".format("1.2.3", version)) +} + +TaskKey[Unit]("verifyDynamicImportPackage") := { + val pkg = OsgiKeys.dynamicImportPackage.value + if (!pkg.isEmpty) + sys.error("Expected dynamic-import-package to be empty, but was %s!" format pkg) +} + +TaskKey[Unit]("verifyExportPackage") := { + val pkg = OsgiKeys.exportPackage.value + if (!pkg.isEmpty) + sys.error("Expected export-package to be empty, but was %s!" format pkg) +} + +TaskKey[Unit]("verifyImportPackage") := { + val pkg = OsgiKeys.importPackage.value + if (pkg != Seq("*")) + sys.error("Expected import-package to be %s, but was %s!".format(Seq("*"), pkg)) +} + +TaskKey[Unit]("verifyFragmentHost") := { + val host = OsgiKeys.fragmentHost.value + if (host != None) + sys.error("Expected fragment-host to be None, but was %s!" format host) +} + +TaskKey[Unit]("verifyPrivatePackage") := { + val pkg = OsgiKeys.privatePackage.value + if (pkg != Seq("com.typesafe.sbt.osgi.test.*")) + sys.error("Expected private-package to be %s, but was %s!".format(Seq("com.typesafe.sbt.osgi.test.*"), pkg)) +} + +TaskKey[Unit]("verifyRequireBundle") := { + val bundle = OsgiKeys.requireBundle.value + if (!bundle.isEmpty) + sys.error("Expected require-bundle to be empty, but was %s!" format bundle) +} diff --git a/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/project/plugins.sbt new file mode 100644 index 0000000..8cd821d --- /dev/null +++ b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/project/plugins.sbt @@ -0,0 +1,5 @@ +sys.props.get("plugin.version") match { + case Some(x) => addSbtPlugin("com.github.sbt" % "sbt-osgi" % x) + case _ => sys.error("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) +} diff --git a/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/test b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/test new file mode 100644 index 0000000..c63cd37 --- /dev/null +++ b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/test @@ -0,0 +1,15 @@ +# Default settings +> verifyBundleActivator +> verifyBundleSymbolicName +> verifyBundleVerion +> verifyBundleRequiredExecutionEnvironment +> verifyDynamicImportPackage +> verifyExportPackage +> verifyImportPackage +> verifyFragmentHost +> verifyPrivatePackage +> verifyRequireBundle + +# Existence of JAR file +> osgiBundle +$ exists target/scala-2.12/sbt-osgi-test_2.12-1.2.3.jar