diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..c7698ac --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,23 @@ +name: Scalafmt + +permissions: {} + +on: + pull_request: + branches: ['**'] + +jobs: + build: + name: Code is formatted + runs-on: ubuntu-latest + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Check project is formatted + uses: jrouly/scalafmt-native-action@v3 + with: + arguments: '--list --mode diff-ref=origin/main' diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..75e1b1f --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,26 @@ +version = 3.7.17 +runner.dialect = scala212 +maxColumn = 120 +project.git = true + +# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style. +# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala +docstrings.style = Asterisk + +# This also seems more idiomatic to include whitespace in import x.{ yyy } +spaces.inImportCurlyBraces = true + +align.tokens."+" = [ + { + code = "%" + owners = [ + { regex = "Term.ApplyInfix" } + ] + }, + { + code = "%%" + owners = [ + { regex = "Term.ApplyInfix" } + ] + } +] diff --git a/build.sbt b/build.sbt index a3da2f1..5f3fa62 100644 --- a/build.sbt +++ b/build.sbt @@ -5,9 +5,9 @@ ThisBuild / dynverSonatypeSnapshots := true // So that publishLocal doesn't continuously create new versions def versionFmt(out: sbtdynver.GitDescribeOutput): String = { - val snapshotSuffix = if - (out.isSnapshot()) "-SNAPSHOT" - else "" + val snapshotSuffix = + if (out.isSnapshot()) "-SNAPSHOT" + else "" out.ref.dropPrefix + snapshotSuffix } @@ -55,7 +55,8 @@ scalacOptions ++= Seq( "-unchecked", "-deprecation", "-Xlint", - "-encoding", "UTF-8" + "-encoding", + "UTF-8" ) scriptedLaunchOpts += "-Xmx1024m" scriptedLaunchOpts ++= Seq("-Dplugin.version=" + version.value) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9c8c307..8c62872 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,14 +8,11 @@ object Library { // Libraries val bndLib = "biz.aQute.bnd" % "biz.aQute.bndlib" % bndVersion - val specs2 = "org.specs2" %% "specs2-core" % specs2Version + val specs2 = "org.specs2" %% "specs2-core" % specs2Version } object Dependencies { - import Library._ - val sbtOsgi = List( - bndLib, - specs2 % Test) + val sbtOsgi = List(bndLib, specs2 % Test) } diff --git a/project/plugins.sbt b/project/plugins.sbt index a8945ae..96bb0f7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.22.0") diff --git a/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala b/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala index 2d1e273..09d7c3e 100644 --- a/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala +++ b/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala @@ -35,42 +35,43 @@ import scala.language.implicitConversions private object Osgi { def cachedBundle( - headers: OsgiManifestHeaders, - additionalHeaders: Map[String, String], - fullClasspath: Seq[File], - artifactPath: File, - resourceDirectories: Seq[File], - embeddedJars: Seq[File], - explodedJars: Seq[File], - failOnUndecidedPackage: Boolean, - sourceDirectories: Seq[File], - packageOptions: scala.Seq[sbt.PackageOption], - useJVMJar: Boolean, - cacheStrategy: Option[CacheStrategy]): Option[File] = cacheStrategy.flatMap { strategy => - + headers: OsgiManifestHeaders, + additionalHeaders: Map[String, String], + fullClasspath: Seq[File], + artifactPath: File, + resourceDirectories: Seq[File], + embeddedJars: Seq[File], + explodedJars: Seq[File], + failOnUndecidedPackage: Boolean, + sourceDirectories: Seq[File], + packageOptions: scala.Seq[sbt.PackageOption], + useJVMJar: Boolean, + cacheStrategy: Option[CacheStrategy] + ): Option[File] = cacheStrategy.flatMap { strategy => def fileFootprint(file: File) = { def footprint(f: File) = strategy match { case CacheStrategy.LastModified => FileInfo.lastModified(f).lastModified.toString - case CacheStrategy.Hash => Hash.toHex(FileInfo.hash(f).hash.toArray) + case CacheStrategy.Hash => Hash.toHex(FileInfo.hash(f).hash.toArray) } if (!file.exists()) Seq() - else if (file.isDirectory) Files.walk(file.toPath).iterator().asScala.map(f => f.toAbsolutePath.toString -> footprint(f.toFile).toSeq) + else if (file.isDirectory) + Files.walk(file.toPath).iterator().asScala.map(f => f.toAbsolutePath.toString -> footprint(f.toFile).toSeq) else Seq(file.absolutePath -> footprint(file)) } def serialized = - s"""${headers} - |${additionalHeaders} + s"""$headers + |$additionalHeaders |${fullClasspath.flatMap(fileFootprint)} - |${artifactPath} + |$artifactPath |${resourceDirectories.flatMap(fileFootprint)} |${embeddedJars.flatMap(fileFootprint)} |${explodedJars.flatMap(fileFootprint)} |$failOnUndecidedPackage |${sourceDirectories.flatMap(fileFootprint)} - |${packageOptions} + |$packageOptions |$useJVMJar |""".stripMargin @@ -82,21 +83,23 @@ private object Osgi { if (!bundleCacheFootprint.exists() || IO.read(bundleCacheFootprint) != footprintValue) { IO.write(bundleCacheFootprint, footprintValue) None - } else if (artifactPath.exists()) Some(artifactPath) else None + } else if (artifactPath.exists()) Some(artifactPath) + else None } def withCache( - headers: OsgiManifestHeaders, - additionalHeaders: Map[String, String], - fullClasspath: Seq[File], - artifactPath: File, - resourceDirectories: Seq[File], - embeddedJars: Seq[File], - explodedJars: Seq[File], - failOnUndecidedPackage: Boolean, - sourceDirectories: Seq[File], - packageOptions: scala.Seq[sbt.PackageOption], - useJVMJar: Boolean, - cacheStrategy: Option[CacheStrategy])(produce: => File): File = + headers: OsgiManifestHeaders, + additionalHeaders: Map[String, String], + fullClasspath: Seq[File], + artifactPath: File, + resourceDirectories: Seq[File], + embeddedJars: Seq[File], + explodedJars: Seq[File], + failOnUndecidedPackage: Boolean, + sourceDirectories: Seq[File], + packageOptions: scala.Seq[sbt.PackageOption], + useJVMJar: Boolean, + cacheStrategy: Option[CacheStrategy] + )(produce: => File): File = cachedBundle( headers, additionalHeaders, @@ -113,20 +116,22 @@ private object Osgi { ).getOrElse(produce) def bundleTask( - headers: OsgiManifestHeaders, - additionalHeaders: Map[String, String], - fullClasspath: Seq[File], - artifactPath: File, - resourceDirectories: Seq[File], - embeddedJars: Seq[File], - explodedJars: Seq[File], - failOnUndecidedPackage: Boolean, - sourceDirectories: Seq[File], - packageOptions: scala.Seq[sbt.PackageOption], - useJVMJar: Boolean, - cacheStrategy: Option[CacheStrategy], - streams: TaskStreams): File = - withCache(headers, + headers: OsgiManifestHeaders, + additionalHeaders: Map[String, String], + fullClasspath: Seq[File], + artifactPath: File, + resourceDirectories: Seq[File], + embeddedJars: Seq[File], + explodedJars: Seq[File], + failOnUndecidedPackage: Boolean, + sourceDirectories: Seq[File], + packageOptions: scala.Seq[sbt.PackageOption], + useJVMJar: Boolean, + cacheStrategy: Option[CacheStrategy], + streams: TaskStreams + ): File = + withCache( + headers, additionalHeaders, fullClasspath, artifactPath, @@ -137,62 +142,67 @@ private object Osgi { sourceDirectories, packageOptions, useJVMJar, - cacheStrategy) { - val builder = new Builder - - if (failOnUndecidedPackage) { - streams.log.info("Validating all packages are set private or exported for OSGi explicitly...") - val internal = headers.privatePackage - val exported = headers.exportPackage - validateAllPackagesDecidedAbout(internal, exported, sourceDirectories) - } + cacheStrategy + ) { + val builder = new Builder + + if (failOnUndecidedPackage) { + streams.log.info("Validating all packages are set private or exported for OSGi explicitly...") + val internal = headers.privatePackage + val exported = headers.exportPackage + validateAllPackagesDecidedAbout(internal, exported, sourceDirectories) + } - builder.setClasspath(fullClasspath.toArray) - - val props = headersToProperties(headers, additionalHeaders) - addPackageOptions(props, packageOptions) - builder.setProperties(props) - - includeResourceProperty(resourceDirectories.filter(_.exists), embeddedJars, explodedJars) foreach (dirs => - builder.setProperty(INCLUDERESOURCE, dirs)) - bundleClasspathProperty(embeddedJars) foreach (jars => - builder.setProperty(BUNDLE_CLASSPATH, jars)) - // Write to a temporary file to prevent trying to simultaneously read from and write to the - // same jar file in exportJars mode (which causes a NullPointerException). - val tmpArtifactPath = file(artifactPath.absolutePath + ".tmp") - // builder.build is not thread-safe because it uses a static SimpleDateFormat. This ensures - // that all calls to builder.build are serialized. - val jar = synchronized { - builder.build - } - val log = streams.log - builder.getWarnings.asScala.foreach(s => log.warn(s"bnd: $s")) - builder.getErrors.asScala.foreach(s => log.error(s"bnd: $s")) - - if (!useJVMJar) jar.write(tmpArtifactPath) - else { - val tmpArtifactDirectoryPath = file(artifactPath.absolutePath + "_tmpdir") - IO.delete(tmpArtifactDirectoryPath) - tmpArtifactDirectoryPath.mkdirs() - - val manifest = jar.getManifest - jar.writeFolder(tmpArtifactDirectoryPath) - - def content = { - 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)) - .collect { case (f, p) if p != (file("META-INF") / "MANIFEST.MF").toPath => (f, p.toString) } - .toTraversable - } + builder.setClasspath(fullClasspath.toArray) + + val props = headersToProperties(headers, additionalHeaders) + addPackageOptions(props, packageOptions) + builder.setProperties(props) + + includeResourceProperty(resourceDirectories.filter(_.exists), embeddedJars, explodedJars) foreach (dirs => + builder.setProperty(INCLUDERESOURCE, dirs) + ) + bundleClasspathProperty(embeddedJars) foreach (jars => builder.setProperty(BUNDLE_CLASSPATH, jars)) + // Write to a temporary file to prevent trying to simultaneously read from and write to the + // same jar file in exportJars mode (which causes a NullPointerException). + val tmpArtifactPath = file(artifactPath.absolutePath + ".tmp") + // builder.build is not thread-safe because it uses a static SimpleDateFormat. This ensures + // that all calls to builder.build are serialized. + val jar = synchronized { + builder.build + } + val log = streams.log + builder.getWarnings.asScala.foreach(s => log.warn(s"bnd: $s")) + builder.getErrors.asScala.foreach(s => log.error(s"bnd: $s")) - IO.jar(content, tmpArtifactPath, manifest) - IO.delete(tmpArtifactDirectoryPath) + if (!useJVMJar) jar.write(tmpArtifactPath) + else { + val tmpArtifactDirectoryPath = file(artifactPath.absolutePath + "_tmpdir") + IO.delete(tmpArtifactDirectoryPath) + tmpArtifactDirectoryPath.mkdirs() + + val manifest = jar.getManifest + jar.writeFolder(tmpArtifactDirectoryPath) + + def content = { + 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)) + .collect { case (f, p) if p != (file("META-INF") / "MANIFEST.MF").toPath => (f, p.toString) } + .toTraversable } - IO.move(tmpArtifactPath, artifactPath) - artifactPath + IO.jar(content, tmpArtifactPath, manifest) + IO.delete(tmpArtifactDirectoryPath) + } + + IO.move(tmpArtifactPath, artifactPath) + artifactPath } private def addPackageOptions(props: Properties, packageOptions: Seq[PackageOption]) = { @@ -203,14 +213,21 @@ private object Osgi { props } - def validateAllPackagesDecidedAbout(internal: Seq[String], exported: Seq[String], sourceDirectories: Seq[File]): Unit = { + def validateAllPackagesDecidedAbout( + internal: Seq[String], + exported: Seq[String], + sourceDirectories: Seq[File] + ): Unit = { val allPackages = sourceDirectories.flatMap { baseFile => if (!baseFile.exists()) Nil else { val packages = - Files.walk(baseFile.toPath, FileVisitOption.FOLLOW_LINKS) + Files + .walk(baseFile.toPath, FileVisitOption.FOLLOW_LINKS) .filter((p: Path) => p.toFile.isDirectory) // uses conversions defined below to not look horrible - .filter((p: Path) => p.toFile.listFiles().exists(f => f.isFile)) // uses conversions defined below to not look horrible + .filter((p: Path) => + p.toFile.listFiles().exists(f => f.isFile) + ) // uses conversions defined below to not look horrible .map[String]((p: Path) => { val pack = p.toString.replace(baseFile.toString, "").replaceAll("/", ".") if (pack.startsWith(".")) pack.substring(1) else pack @@ -222,9 +239,15 @@ private object Osgi { } }.toSet - def validateAllPackagesDecidedAbout(internal: Seq[String], exported: Seq[String], realPackages: List[String]): Unit = + def validateAllPackagesDecidedAbout( + internal: Seq[String], + exported: Seq[String], + realPackages: List[String] + ): Unit = if (internal.isEmpty && exported.isEmpty && realPackages.nonEmpty) { - throw new RuntimeException(s"Remaining packages are undecided about (private or exported) for OSGi (this is rather dangerous!): ${realPackages}") + throw new RuntimeException( + s"Remaining packages are undecided about (private or exported) for OSGi (this is rather dangerous!): ${realPackages}" + ) } else realPackages match { case Nil => // OK! @@ -234,11 +257,14 @@ private object Osgi { if (startsWith(pack, internal) || startsWith(pack, exported)) { validateAllPackagesDecidedAbout(internal, exported, remainingPackages) - } else throw new RuntimeException(s"Unable to determine if [$pack] package is meant to be private or exported! " + - s"Please define what to do with this package for OSGi explicitly! \n" + - s" Private packages : $internal\n" + - s" Exported packages: $exported\n" + - s" Offending package: $pack\n") + } else + throw new RuntimeException( + s"Unable to determine if [$pack] package is meant to be private or exported! " + + s"Please define what to do with this package for OSGi explicitly! \n" + + s" Private packages : $internal\n" + + s" Exported packages: $exported\n" + + s" Offending package: $pack\n" + ) } val i = internal.map(_.replaceAll(".*", "")) @@ -261,8 +287,9 @@ private object Osgi { bundleActivator foreach (properties.put(BUNDLE_ACTIVATOR, _)) strToStrOpt(bundleDescription) foreach (properties.put(BUNDLE_DESCRIPTION, _)) bundleDocURL foreach (u => properties.put(BUNDLE_DOCURL, u.toString)) - bundleLicense.headOption foreach {case (license, url) => - properties.put(BUNDLE_LICENSE, s"${url.toString};description=$license")} + bundleLicense.headOption foreach { case (license, url) => + properties.put(BUNDLE_LICENSE, s"${url.toString};description=$license") + } strToStrOpt(bundleName) foreach (properties.put(BUNDLE_NAME, _)) seqToStrOpt(bundleRequiredExecutionEnvironment)(id) foreach (properties.put(BUNDLE_REQUIREDEXECUTIONENVIRONMENT, _)) strToStrOpt(bundleVendor) foreach (properties.put(BUNDLE_VENDOR, _)) @@ -296,7 +323,7 @@ private object Osgi { val nameParts = parts(name) val partsWithoutOverlap = (organizationParts.lastOption, nameParts.headOption) match { case (Some(last), Some(head)) if last == head => organizationParts ++ nameParts.tail - case _ => organizationParts ++ nameParts + case _ => organizationParts ++ nameParts } partsWithoutOverlap mkString "." } diff --git a/src/main/scala/com/typesafe/sbt/osgi/OsgiKeys.scala b/src/main/scala/com/typesafe/sbt/osgi/OsgiKeys.scala index f582587..04ab8ce 100644 --- a/src/main/scala/com/typesafe/sbt/osgi/OsgiKeys.scala +++ b/src/main/scala/com/typesafe/sbt/osgi/OsgiKeys.scala @@ -21,99 +21,82 @@ import sbt._ trait OsgiKeys { lazy val bundle: TaskKey[File] = - TaskKey[File]( - prefix("Bundle"), - "Create an OSGi bundle.") + TaskKey[File](prefix("Bundle"), "Create an OSGi bundle.") lazy val manifestHeaders: TaskKey[OsgiManifestHeaders] = - TaskKey[OsgiManifestHeaders]( - prefix("ManifestHeaders"), - "The aggregated manifest headers.") + TaskKey[OsgiManifestHeaders](prefix("ManifestHeaders"), "The aggregated manifest headers.") lazy val bundleActivator: SettingKey[Option[String]] = - SettingKey[Option[String]]( - prefix("BundleActivator"), - "Optional value for *Bundle-Activator* header.") + SettingKey[Option[String]](prefix("BundleActivator"), "Optional value for *Bundle-Activator* header.") lazy val bundleSymbolicName: SettingKey[String] = - SettingKey[String]( - prefix("BundleSymbolicName"), - "Value for *Bundle-SymbolicName* header.") + SettingKey[String](prefix("BundleSymbolicName"), "Value for *Bundle-SymbolicName* header.") lazy val bundleVersion: SettingKey[String] = - SettingKey[String]( - prefix("BundleVersion"), - "Value for *Bundle-Version* header.") + SettingKey[String](prefix("BundleVersion"), "Value for *Bundle-Version* header.") lazy val bundleRequiredExecutionEnvironment: SettingKey[Seq[String]] = SettingKey[Seq[String]]( prefix("BundleRequiredExecutionEnvironment"), - "Value for *Bundle-RequiredExecutionEnvironment* header.") + "Value for *Bundle-RequiredExecutionEnvironment* header." + ) lazy val dynamicImportPackage: SettingKey[Seq[String]] = - SettingKey[Seq[String]]( - prefix("DynamicImportPackage"), - "Values for *Dynamic-ImportPackage* header.") + SettingKey[Seq[String]](prefix("DynamicImportPackage"), "Values for *Dynamic-ImportPackage* header.") lazy val exportPackage: SettingKey[Seq[String]] = - SettingKey[Seq[String]]( - prefix("ExportPackage"), - "Values for *Export-Package* header.") + SettingKey[Seq[String]](prefix("ExportPackage"), "Values for *Export-Package* header.") lazy val importPackage: SettingKey[Seq[String]] = - SettingKey[Seq[String]]( - prefix("import-package"), - "Values for *Import-Package* header.") + SettingKey[Seq[String]](prefix("import-package"), "Values for *Import-Package* header.") lazy val fragmentHost: SettingKey[Option[String]] = - SettingKey[Option[String]]( - prefix("FragmentHost"), - "Optional value for *Fragment-Host* header.") + SettingKey[Option[String]](prefix("FragmentHost"), "Optional value for *Fragment-Host* header.") lazy val privatePackage: SettingKey[Seq[String]] = - SettingKey[Seq[String]]( - prefix("PrivatePackage"), - "Values for *Private-Package* header.") + SettingKey[Seq[String]](prefix("PrivatePackage"), "Values for *Private-Package* header.") lazy val requireBundle: SettingKey[Seq[String]] = - SettingKey[Seq[String]]( - prefix("RequireBundle"), - "Values for *Require-Bundle* header.") + SettingKey[Seq[String]](prefix("RequireBundle"), "Values for *Require-Bundle* header.") lazy val additionalHeaders: SettingKey[Map[String, String]] = - SettingKey[Map[String, String]]( - prefix("AdditionalHeaders"), - "Additional headers to pass to BND.") + SettingKey[Map[String, String]](prefix("AdditionalHeaders"), "Additional headers to pass to BND.") lazy val embeddedJars: TaskKey[Seq[File]] = - TaskKey[Seq[File]]( - prefix("EmbeddedJars"), - "Jar files to be embedded inside the bundle.") + TaskKey[Seq[File]](prefix("EmbeddedJars"), "Jar files to be embedded inside the bundle.") lazy val explodedJars: TaskKey[Seq[File]] = - TaskKey[Seq[File]]( - prefix("ExplodedJars"), - "Jar files to be exploded into the bundle.") + TaskKey[Seq[File]](prefix("ExplodedJars"), "Jar files to be exploded into the bundle.") lazy val requireCapability: TaskKey[String] = - TaskKey[String](prefix("RequireCapability"), "Value for *Require-Capability* header. If not" + - "specified defaults to 'osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=*PROJECT JAVA VERSION*))\"'.") + TaskKey[String]( + prefix("RequireCapability"), + "Value for *Require-Capability* header. If not" + + "specified defaults to 'osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=*PROJECT JAVA VERSION*))\"'." + ) lazy val failOnUndecidedPackage: SettingKey[Boolean] = - SettingKey[Boolean](prefix("FailOnUndecidedPackage"), "Fail the build if a package is neither exported or private." + - "Without this setting such classes might be just transparently removed from the resulting artifact!") + SettingKey[Boolean]( + prefix("FailOnUndecidedPackage"), + "Fail the build if a package is neither exported or private." + + "Without this setting such classes might be just transparently removed from the resulting artifact!" + ) lazy val packageWithJVMJar: SettingKey[Boolean] = - SettingKey[Boolean](prefix("PackageWithJVMJar"), "Use the JVM jar tools to craft the bundle instead of the one from BND." + - "Without this setting the produced bundle are detected as corrupted by recent JVMs") + SettingKey[Boolean]( + prefix("PackageWithJVMJar"), + "Use the JVM jar tools to craft the bundle instead of the one from BND." + + "Without this setting the produced bundle are detected as corrupted by recent JVMs" + ) lazy val cacheStrategy: SettingKey[Option[CacheStrategy]] = - SettingKey[Option[CacheStrategy]](prefix("CacheBundle"), "Do not build a new bundle if a bundle already exists and has been crafted from identical inputs") - + SettingKey[Option[CacheStrategy]]( + prefix("CacheBundle"), + "Do not build a new bundle if a bundle already exists and has been crafted from identical inputs" + ) private def prefix(key: String) = "osgi" + key - sealed trait CacheStrategy object CacheStrategy { diff --git a/src/main/scala/com/typesafe/sbt/osgi/OsgiManifestHeaders.scala b/src/main/scala/com/typesafe/sbt/osgi/OsgiManifestHeaders.scala index 6b64a91..1dd3fc8 100644 --- a/src/main/scala/com/typesafe/sbt/osgi/OsgiManifestHeaders.scala +++ b/src/main/scala/com/typesafe/sbt/osgi/OsgiManifestHeaders.scala @@ -19,19 +19,20 @@ package com.typesafe.sbt.osgi import sbt.URL final case class OsgiManifestHeaders( - bundleActivator: Option[String], - bundleDescription: String, - bundleDocURL: Option[URL], - bundleLicense: Seq[(String, URL)], - bundleName: String, - bundleRequiredExecutionEnvironment: Seq[String], - bundleVendor: String, - bundleSymbolicName: String, - bundleVersion: String, - dynamicImportPackage: Seq[String], - exportPackage: Seq[String], - importPackage: Seq[String], - fragmentHost: Option[String], - privatePackage: Seq[String], - requireBundle: Seq[String], - requireCapability: String) + bundleActivator: Option[String], + bundleDescription: String, + bundleDocURL: Option[URL], + bundleLicense: Seq[(String, URL)], + bundleName: String, + bundleRequiredExecutionEnvironment: Seq[String], + bundleVendor: String, + bundleSymbolicName: String, + bundleVersion: String, + dynamicImportPackage: Seq[String], + exportPackage: Seq[String], + importPackage: Seq[String], + fragmentHost: Option[String], + privatePackage: Seq[String], + requireBundle: Seq[String], + requireCapability: String +) diff --git a/src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala b/src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala index 127728a..da09e61 100644 --- a/src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala +++ b/src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala @@ -36,27 +36,30 @@ object SbtOsgi extends AutoPlugin { val OsgiKeys = com.typesafe.sbt.osgi.OsgiKeys lazy val osgiSettings: Seq[Setting[_]] = Seq( - Compile / packageBin / packagedArtifact := Scoped.mkTuple2((Compile / packageBin / artifact).value, OsgiKeys.bundle.value), - Compile / packageBin / artifact ~= (_.withType("bundle")) ) + Compile / packageBin / packagedArtifact := Scoped + .mkTuple2((Compile / packageBin / artifact).value, OsgiKeys.bundle.value), + Compile / packageBin / artifact ~= (_.withType("bundle")) + ) } lazy val defaultOsgiSettings: Seq[Setting[_]] = { import OsgiKeys._ Seq( bundle := Osgi.bundleTask( - manifestHeaders.value, - additionalHeaders.value, - (Compile / dependencyClasspathAsJars).value.map(_.data) ++ (Compile / products).value, - (Compile / packageBin / artifactPath).value, - (Compile / resourceDirectories).value, - embeddedJars.value, - explodedJars.value, - failOnUndecidedPackage.value, - (Compile / sourceDirectories).value, - (Compile / packageBin / packageOptions).value, - packageWithJVMJar.value, - cacheStrategy.value, - streams.value), + manifestHeaders.value, + additionalHeaders.value, + (Compile / dependencyClasspathAsJars).value.map(_.data) ++ (Compile / products).value, + (Compile / packageBin / artifactPath).value, + (Compile / resourceDirectories).value, + embeddedJars.value, + explodedJars.value, + failOnUndecidedPackage.value, + (Compile / sourceDirectories).value, + (Compile / packageBin / packageOptions).value, + packageWithJVMJar.value, + cacheStrategy.value, + streams.value + ), manifestHeaders := OsgiManifestHeaders( bundleActivator.value, description.value, @@ -73,7 +76,8 @@ object SbtOsgi extends AutoPlugin { fragmentHost.value, privatePackage.value, requireBundle.value, - requireCapability.value), + requireCapability.value + ), Compile / sbt.Keys.packageBin := bundle.value, bundleSymbolicName := Osgi.defaultBundleSymbolicName(organization.value, normalizedName.value), privatePackage := bundleSymbolicName(name => List(name + ".*")).value, @@ -101,6 +105,7 @@ object SbtOsgi extends AutoPlugin { embeddedJars := Nil, explodedJars := Nil, packageWithJVMJar := false, - cacheStrategy := None) + cacheStrategy := None + ) } } diff --git a/src/sbt-test/sbt-osgi/test-00-defaults/build.sbt b/src/sbt-test/sbt-osgi/test-00-defaults/build.sbt index 1ed89cd..579aeff 100644 --- a/src/sbt-test/sbt-osgi/test-00-defaults/build.sbt +++ b/src/sbt-test/sbt-osgi/test-00-defaults/build.sbt @@ -1,4 +1,4 @@ -lazy val test00 = (project in file ("")).enablePlugins(SbtOsgi) +lazy val test00 = (project in file("")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -12,7 +12,7 @@ osgiSettings TaskKey[Unit]("verifyBundleActivator") := { val activator = OsgiKeys.bundleActivator.value - if (activator.isDefined) + if (activator.isDefined) sys.error("Expected bundle-activator to be None, but was %s!" format activator) } @@ -24,7 +24,7 @@ TaskKey[Unit]("verifyBundleSymbolicName") := { TaskKey[Unit]("verifyBundleRequiredExecutionEnvironment") := { val re = OsgiKeys.bundleRequiredExecutionEnvironment.value - if (re.nonEmpty) + if (re.nonEmpty) sys.error("Expected bundleRequiredExecutionEnvironment to be Nil, but was %s!" format re) } diff --git a/src/sbt-test/sbt-osgi/test-00-defaults/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-00-defaults/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-00-defaults/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-00-defaults/project/plugins.sbt @@ -1,5 +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. + 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-01-contents/build.sbt b/src/sbt-test/sbt-osgi/test-01-contents/build.sbt index 63a7b72..3b623ab 100644 --- a/src/sbt-test/sbt-osgi/test-01-contents/build.sbt +++ b/src/sbt-test/sbt-osgi/test-01-contents/build.sbt @@ -1,4 +1,4 @@ -lazy val test01 = (project in file (".")).enablePlugins(SbtOsgi) +lazy val test01 = (project in file(".")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -22,14 +22,13 @@ apiURL := Some(url("http://typesafe.com")) licenses += ("license" -> url("http://license.license")) - -TaskKey[Unit]("verifyBundle") := { +TaskKey[Unit]("verifyBundle") := { import java.io.IOException import java.util.zip.ZipFile import scala.io.Source val file = OsgiKeys.bundle.value val newLine = System.getProperty("line.separator") - val zipFile = new ZipFile(file) + val zipFile = new ZipFile(file) // Verify manifest val manifestIn = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF")) try { @@ -59,7 +58,7 @@ TaskKey[Unit]("verifyBundle") := { if (!(lines exists (_ containsSlice "Export-Package: com.typesafe.sbt.osgi.test"))) sys.error("Expected 'Export-Package: com.typesafe.sbt.osgi.test' in manifest!" + butWas) if (!(lines exists (l => (l containsSlice "org.osgi.framework") && (l containsSlice "Import-Package: ")))) - sys.error("""Expected 'Import-Package: ' and 'org.osgi.framework' in manifest!""" + butWas) + sys.error("""Expected 'Import-Package: ' and 'org.osgi.framework' in manifest!""" + butWas) if (!(lines contains "Private-Package: com.typesafe.sbt.osgi.test.internal")) sys.error("Expected 'Private-Package: com.typesafe.sbt.osgi.test.internal' in manifest!" + butWas) } catch { diff --git a/src/sbt-test/sbt-osgi/test-01-contents/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-01-contents/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-01-contents/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-01-contents/project/plugins.sbt @@ -1,5 +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. + 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-02-includeresource/build.sbt b/src/sbt-test/sbt-osgi/test-02-includeresource/build.sbt index 689918e..2d9d6c5 100644 --- a/src/sbt-test/sbt-osgi/test-02-includeresource/build.sbt +++ b/src/sbt-test/sbt-osgi/test-02-includeresource/build.sbt @@ -1,4 +1,4 @@ -lazy val test02 = (project in file ("")).enablePlugins(SbtOsgi) +lazy val test02 = (project in file("")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -28,7 +28,10 @@ TaskKey[Unit]("verifyBundle") := { assert(manifest != null, "No MANIFEST.MF in JAR file") val attributes = manifest.getMainAttributes val includeResource = attributes.getValue("Include-Resource") - assert(includeResource == null, "MANIFEST.MF contains unexpected Include-Resource attribute; value=" + includeResource) + assert( + includeResource == null, + "MANIFEST.MF contains unexpected Include-Resource attribute; value=" + includeResource + ) } catch { case e: IOException => sys.error("Expected to be able to read the manifest, but got exception!" + newLine + e) } diff --git a/src/sbt-test/sbt-osgi/test-02-includeresource/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-02-includeresource/project/plugins.sbt index 2a8af5b..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-02-includeresource/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-02-includeresource/project/plugins.sbt @@ -1,6 +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. + 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-03-arbitraryHeaders/build.sbt b/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/build.sbt index f7ff973..be46715 100644 --- a/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/build.sbt +++ b/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/build.sbt @@ -1,4 +1,4 @@ -lazy val test03 = (project in file ("")).enablePlugins(SbtOsgi) +lazy val test03 = (project in file("")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -12,7 +12,7 @@ OsgiKeys.additionalHeaders := Map( "Main-Class" -> "com.typesafe.sbt.osgi.test.App" ) -TaskKey[Unit]("verifyBundle") := { +TaskKey[Unit]("verifyBundle") := { import java.io.IOException import java.util.zip.ZipFile import scala.io.Source diff --git a/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-03-arbitraryHeaders/project/plugins.sbt @@ -1,5 +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. + 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-04-embeddedJars/build.sbt b/src/sbt-test/sbt-osgi/test-04-embeddedJars/build.sbt index de638f0..5dc82b5 100644 --- a/src/sbt-test/sbt-osgi/test-04-embeddedJars/build.sbt +++ b/src/sbt-test/sbt-osgi/test-04-embeddedJars/build.sbt @@ -1,4 +1,4 @@ -lazy val test04 = (project in file ("")).enablePlugins(SbtOsgi) +lazy val test04 = (project in file("")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -8,12 +8,11 @@ version := "1.2.3" osgiSettings -OsgiKeys.embeddedJars := (Keys.externalDependencyClasspath in Compile).value map (_.data) filter ( - _.getName startsWith "junit") +OsgiKeys.embeddedJars := (Keys.externalDependencyClasspath in Compile).value map (_.data) filter (_.getName startsWith "junit") libraryDependencies += "junit" % "junit" % "4.11" // Not in test scope here! -TaskKey[Unit]("verifyBundle") := { +TaskKey[Unit]("verifyBundle") := { import java.io.IOException import java.util.zip.ZipFile import scala.io.Source @@ -22,7 +21,7 @@ TaskKey[Unit]("verifyBundle") := { val zipFile = new ZipFile(file) // Verify bundle content val sampleJar = zipFile.getEntry("junit-4.11.jar") - assert(sampleJar != null, "Expected 'junit-4.11.jar' inside of the bundle") + assert(sampleJar != null, "Expected 'junit-4.11.jar' inside of the bundle") // Verify manifest val manifestIn = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF")) try { diff --git a/src/sbt-test/sbt-osgi/test-04-embeddedJars/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-04-embeddedJars/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-04-embeddedJars/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-04-embeddedJars/project/plugins.sbt @@ -1,5 +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. + 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-05-exportJars/p1/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-05-exportJars/p1/project/plugins.sbt index 2a8af5b..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-05-exportJars/p1/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-05-exportJars/p1/project/plugins.sbt @@ -1,6 +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. + 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-05-exportJars/p2/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-05-exportJars/p2/project/plugins.sbt index 2a8af5b..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-05-exportJars/p2/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-05-exportJars/p2/project/plugins.sbt @@ -1,6 +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. + 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-05-exportJars/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-05-exportJars/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-05-exportJars/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-05-exportJars/project/plugins.sbt @@ -1,5 +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. + 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-06-explodedJars/build.sbt b/src/sbt-test/sbt-osgi/test-06-explodedJars/build.sbt index a603f6e..abeb576 100644 --- a/src/sbt-test/sbt-osgi/test-06-explodedJars/build.sbt +++ b/src/sbt-test/sbt-osgi/test-06-explodedJars/build.sbt @@ -1,4 +1,4 @@ -lazy val test06 = (project in file ("")).enablePlugins(SbtOsgi) +lazy val test06 = (project in file("")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -25,4 +25,3 @@ TaskKey[Unit]("verifyBundle") := { if (bundle.getManifest.getMainAttributes.getValue("Bundle-SymbolicName") == null) sys.error("Target manifest is incorrect.") } - diff --git a/src/sbt-test/sbt-osgi/test-06-explodedJars/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-06-explodedJars/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-06-explodedJars/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-06-explodedJars/project/plugins.sbt @@ -1,5 +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. + 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-07-failOnClassesExcludedFromJar/build.sbt b/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/build.sbt index 98e7d70..1a535e9 100644 --- a/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/build.sbt +++ b/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/build.sbt @@ -1,4 +1,4 @@ -lazy val test01 = (project in file (".")).enablePlugins(SbtOsgi) +lazy val test01 = (project in file(".")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -14,7 +14,6 @@ OsgiKeys.bundleActivator := Some("com.typesafe.sbt.osgi.test.internal.Activator" OsgiKeys.dynamicImportPackage := Seq("scala.*") - // we set an explicit internal package OsgiKeys.privatePackage := Seq("com.typesafe.sbt.osgi.internal") @@ -22,24 +21,22 @@ OsgiKeys.privatePackage := Seq("com.typesafe.sbt.osgi.internal") OsgiKeys.exportPackage := Seq("com.typesafe.sbt.osgi.test.exportme") // yet we "forget" on purpose to decide what to do about undecided! -// however we also enable the fail setting: +// however we also enable the fail setting: OsgiKeys.failOnUndecidedPackage := true - OsgiKeys.bundleRequiredExecutionEnvironment := Seq("JavaSE-1.7", "JavaSE-1.8") apiURL := Some(url("http://typesafe.com")) licenses += ("license" -> url("http://license.license")) - TaskKey[Unit]("verifyBundle") := { import java.io.IOException import java.util.zip.ZipFile import scala.io.Source val file = OsgiKeys.bundle.value val newLine = System.getProperty("line.separator") - val zipFile = new ZipFile(file) + val zipFile = new ZipFile(file) // Verify manifest val manifestIn = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF")) try { @@ -69,7 +66,7 @@ TaskKey[Unit]("verifyBundle") := { if (!(lines exists (_ containsSlice "Export-Package: com.typesafe.sbt.osgi.test"))) sys.error("Expected 'Export-Package: com.typesafe.sbt.osgi.test' in manifest!" + butWas) if (!(lines exists (l => (l containsSlice "org.osgi.framework") && (l containsSlice "Import-Package: ")))) - sys.error("""Expected 'Import-Package: ' and 'org.osgi.framework' in manifest!""" + butWas) + sys.error("""Expected 'Import-Package: ' and 'org.osgi.framework' in manifest!""" + butWas) if (!(lines contains "Private-Package: com.typesafe.sbt.osgi.test.internal")) sys.error("Expected 'Private-Package: com.typesafe.sbt.osgi.test.internal' in manifest!" + butWas) } catch { diff --git a/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-07-failOnClassesExcludedFromJar/project/plugins.sbt @@ -1,5 +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. + 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/build.sbt b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/build.sbt index 5a17371..cd48cd2 100644 --- a/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/build.sbt +++ b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/build.sbt @@ -1,4 +1,4 @@ -lazy val test08 = (project in file ("")).enablePlugins(SbtOsgi) +lazy val test08 = (project in file("")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -14,7 +14,7 @@ OsgiKeys.packageWithJVMJar := true TaskKey[Unit]("verifyBundleActivator") := { val activator = OsgiKeys.bundleActivator.value - if (activator.isDefined) + if (activator.isDefined) sys.error("Expected bundle-activator to be None, but was %s!" format activator) } @@ -26,7 +26,7 @@ TaskKey[Unit]("verifyBundleSymbolicName") := { TaskKey[Unit]("verifyBundleRequiredExecutionEnvironment") := { val re = OsgiKeys.bundleRequiredExecutionEnvironment.value - if (re.nonEmpty) + if (re.nonEmpty) sys.error("Expected bundleRequiredExecutionEnvironment to be Nil, but was %s!" format re) } 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 index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-08-packageWithJVMJar/project/plugins.sbt @@ -1,5 +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. + 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-09-automatic-module-name-in-opts/build.sbt b/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/build.sbt index 0f47445..ebf29b8 100644 --- a/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/build.sbt +++ b/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/build.sbt @@ -1,4 +1,4 @@ -lazy val test01 = (project in file (".")).enablePlugins(SbtOsgi) +lazy val test01 = (project in file(".")).enablePlugins(SbtOsgi) organization := "com.typesafe.sbt" @@ -26,8 +26,7 @@ apiURL := Some(url("http://typesafe.com")) licenses += ("license" -> url("http://license.license")) - -TaskKey[Unit]("verifyBundle") := { +TaskKey[Unit]("verifyBundle") := { import java.io.IOException import java.util.zip.ZipFile import scala.io.Source diff --git a/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-09-automatic-module-name-in-opts/project/plugins.sbt @@ -1,5 +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. + 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-10-multi-project-dependsOn-includePackage-versions/build.sbt b/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/build.sbt index 73dcad5..d42cd7e 100644 --- a/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/build.sbt +++ b/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/build.sbt @@ -1,30 +1,33 @@ import com.typesafe.sbt.osgi.SbtOsgi import com.typesafe.sbt.osgi.OsgiKeys +inThisBuild( + Seq( + organization := "com.typesafe.sbt", + homepage := Some(url("https://github.com/woq-blended/blended")), + version := "1.2.3", + libraryDependencies += "org.osgi" % "org.osgi.core" % "4.3.0" % "provided", + licenses += ("Apache 2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")), + scalaVersion := "2.12.6" + ) +) -inThisBuild(Seq( - organization := "com.typesafe.sbt", - homepage := Some(url("https://github.com/woq-blended/blended")), - version := "1.2.3", - libraryDependencies += "org.osgi" % "org.osgi.core" % "4.3.0" % "provided", - licenses += ("Apache 2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")), - scalaVersion := "2.12.6" -)) - -lazy val root = project.in(file(".")) +lazy val root = project + .in(file(".")) .aggregate(proj1, proj2) -lazy val proj1 = project.in(file("proj1")) +lazy val proj1 = project + .in(file("proj1")) .enablePlugins(SbtOsgi) .settings( name := "proj1", OsgiKeys.bundleSymbolicName := "proj1", OsgiKeys.bundleVersion := version.value, OsgiKeys.exportPackage := Seq("proj1") - ) -lazy val proj2 = project.in(file("proj2")) +lazy val proj2 = project + .in(file("proj2")) .enablePlugins(SbtOsgi) .dependsOn(proj1) .settings( @@ -34,7 +37,6 @@ lazy val proj2 = project.in(file("proj2")) OsgiKeys.exportPackage := Seq("proj2") ) - TaskKey[Unit]("verifyBundle") := { import java.io.IOException import java.util.zip.ZipFile diff --git a/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/project/plugins.sbt b/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/project/plugins.sbt index 8cd821d..0e9f6ed 100644 --- a/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/project/plugins.sbt +++ b/src/sbt-test/sbt-osgi/test-10-multi-project-dependsOn-includePackage-versions/project/plugins.sbt @@ -1,5 +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. + case _ => sys.error("""|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) } diff --git a/src/test/scala/com/typesafe/sbt/osgi/OsgiSpec.scala b/src/test/scala/com/typesafe/sbt/osgi/OsgiSpec.scala index 2977bfb..d73fcdf 100644 --- a/src/test/scala/com/typesafe/sbt/osgi/OsgiSpec.scala +++ b/src/test/scala/com/typesafe/sbt/osgi/OsgiSpec.scala @@ -53,7 +53,8 @@ class OsgiSpec extends Specification { None, Seq("privatePackage"), Nil, - "requireCapability") + "requireCapability" + ) val properties = headersToProperties(headers, Map.empty) properties.asScala must havePairs( BUNDLE_ACTIVATOR -> "bundleActivator", @@ -69,7 +70,8 @@ class OsgiSpec extends Specification { EXPORT_PACKAGE -> "exportPackage1,exportPackage2,exportPackage3", IMPORT_PACKAGE -> "importPackage", PRIVATE_PACKAGE -> "privatePackage", - REQUIRE_CAPABILITY → "requireCapability") + REQUIRE_CAPABILITY → "requireCapability" + ) properties.asScala must not(haveKey(FRAGMENT_HOST)) properties.asScala must not(haveKey(REQUIRE_BUNDLE)) } @@ -93,7 +95,9 @@ class OsgiSpec extends Specification { val jar = new File("/aJar.jar") val anotherJar = new File("/anotherJar.jar") val actual = includeResourceProperty(Seq(resourceDir), Seq(jar), Seq(anotherJar)) - actual must beEqualTo(Some(resourceDir.getAbsolutePath + "," + jar.getAbsolutePath + ",@" + anotherJar.getAbsolutePath)) + actual must beEqualTo( + Some(resourceDir.getAbsolutePath + "," + jar.getAbsolutePath + ",@" + anotherJar.getAbsolutePath) + ) } }