diff --git a/.travis.yml b/.travis.yml index b37d38b68..90017136e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,46 @@ language: java -os: - - osx -env: - - SCALA_VERSION=2.10.5 +os: linux + before_install: - if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then brew update; brew install xz; fi -script: - - ./sbt ++$SCALA_VERSION --warn update compile test:compile - - ./sbt ++$SCALA_VERSION test "scripted universal/* jar/* bash/* ash/*" - - if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then - ./sbt ++$SCALA_VERSION "scripted rpm/* debian/* docker/staging docker/entrypoint docker/ports docker/volumes"; - fi - - if [[ "$TRAVIS_JDK_VERSION" = "oraclejdk8" ]]; then - ./sbt ++$SCALA_VERSION "scripted jdkpackager/test-package-minimal jdkpackager/test-package-mappings"; - fi -notifications: - email: - - qbranch@typesafe.com +script: ./sbt "$SBT_TEST_CMD"; + +# We explicitly set the matrix to include oraclejdk8 because MacOS X has issues. See comment below +matrix: + include: + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validate" + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateUniversal" + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateJar" + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateBash" + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateAsh" + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateRpm" + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateDebian" + # for now we can't test the docker image generation on travis + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateDockerUnit" + # jdk packaging is only available on jdk8+ + - jdk: oraclejdk8 + env: SBT_TEST_CMD="^validateJdkPackagerTravis" + # oraclejdk8 is not yet available. + # see https://github.com/travis-ci/travis-ci/issues/2316 + - os: osx + env: SBT_VERSION_CMD="^validate ^validateUniversal" + osx_image: xcode8 + addons: apt: packages: - rpm -matrix: - include: - - os: linux - jdk: openjdk7 - - os: linux - jdk: oraclejdk8 sudo: false cache: diff --git a/build.sbt b/build.sbt index 5f18cdf59..3b6fce948 100644 --- a/build.sbt +++ b/build.sbt @@ -3,19 +3,56 @@ sbtPlugin := true name := "sbt-native-packager" organization := "com.typesafe.sbt" -scalaVersion in Global := "2.10.5" -scalacOptions in Compile ++= Seq("-deprecation", "-target:jvm-1.7") +scalaVersion in Global := "2.10.6" +// crossBuildingSettings +crossSbtVersions := Vector("0.13.16", "1.0.0-RC3") + +scalacOptions in Compile ++= Seq("-deprecation") +javacOptions ++= Seq("-source", "1.8", "-target", "1.8") + +// put jdeb on the classpath for scripted tests +classpathTypes += "maven-plugin" libraryDependencies ++= Seq( "org.apache.commons" % "commons-compress" % "1.4.1", // for jdkpackager "org.apache.ant" % "ant" % "1.9.6", - // these dependencies have to be explicitly added by the user - "com.spotify" % "docker-client" % "3.5.13" % "provided", - "org.vafer" % "jdeb" % "1.3" % "provided" artifacts (Artifact("jdeb", "jar", "jar")), "org.scalatest" %% "scalatest" % "3.0.3" % "test" ) +// sbt dependend libraries +libraryDependencies ++= { + (sbtVersion in pluginCrossBuild).value match { + case v if v.startsWith("1.") => + Seq( + "org.scala-sbt" %% "io" % "1.0.0-M13", + // these dependencies have to be explicitly added by the user + // FIXME temporary remove the 'provided' scope. SBT 1.0.0-M6 changed the resolving somehow + "com.spotify" % "docker-client" % "3.5.13" /* % "provided" */, + "org.vafer" % "jdeb" % "1.3" /*% "provided"*/ artifacts Artifact("jdeb", "jar", "jar") + ) + case _ => + Seq( + // these dependencies have to be explicitly added by the user + "com.spotify" % "docker-client" % "3.5.13" % "provided", + "org.vafer" % "jdeb" % "1.3" % "provided" artifacts Artifact("jdeb", "jar", "jar") + ) + } +} + +// scala version depended libraries +libraryDependencies ++= { + scalaBinaryVersion.value match { + case "2.10" => Nil + case _ => + Seq( + "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.6", + "org.scala-lang.modules" %% "scala-xml" % "1.0.6" + ) + } + +} + // configure github page enablePlugins(SphinxPlugin, SiteScaladocPlugin) @@ -34,12 +71,12 @@ import ReleaseTransformations._ releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, - runTest, - releaseStepInputTask(scripted, " universal/* debian/* rpm/* docker/* ash/* jar/* bash/* jdkpackager/*"), + releaseStepCommandAndRemaining("^ test"), + releaseStepCommandAndRemaining("^ scripted universal/* debian/* rpm/* docker/* ash/* jar/* bash/* jdkpackager/*"), setReleaseVersion, commitReleaseVersion, tagRelease, - publishArtifacts, + releaseStepCommandAndRemaining("^ publishSigned"), setNextVersion, commitNextVersion, pushChanges, @@ -50,8 +87,29 @@ releaseProcess := Seq[ReleaseStep]( bintrayOrganization := Some("sbt") bintrayRepository := "sbt-plugin-releases" -// scalafmt -scalafmtConfig := Some(file(".scalafmt.conf")) - // ci commands -addCommandAlias("validateWindows", ";test-only * -- -n windows;scripted universal/dist universal/stage windows/*") +addCommandAlias("validateFormatting", "; scalafmt::test ; test:scalafmt::test ; sbt:scalafmt::test") +addCommandAlias("validate", "; clean ; update ; test") + +// List all scripted test separately to schedule them in different travis-ci jobs. +// Travis-CI has hard timeouts for jobs, so we run them in smaller jobs as the scripted +// tests take quite some time to run. +// Ultimatley we should run only those tests that are necessary for a change +addCommandAlias("validateUniversal", "scripted universal/*") +addCommandAlias("validateJar", "scripted jar/*") +addCommandAlias("validateBash", "scripted bash/*") +addCommandAlias("validateAsh", "scripted ash/*") +addCommandAlias("validateRpm", "scripted rpm/*") +addCommandAlias("validateDebian", "scripted debian/*") +addCommandAlias("validateDocker", "scripted docker/*") +addCommandAlias("validateDockerUnit", "scripted docker/staging docker/entrypoint docker/ports docker/volumes") +addCommandAlias("validateJdkPackager", "scripted jdkpackager/*") +// travis ci's jdk8 version doesn't support nested association elements. +// error: Caused by: class com.sun.javafx.tools.ant.Info doesn't support the nested "association" element. +addCommandAlias( + "validateJdkPackagerTravis", + "scripted jdkpackager/test-package-minimal jdkpackager/test-package-mappings" +) + +// TODO check the cygwin scripted tests and run them on appveyor +addCommandAlias("validateWindows", "; test-only * -- -n windows;scripted universal/dist universal/stage windows/*") diff --git a/project/build.properties b/project/build.properties index 64317fdae..c091b86ca 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.15 +sbt.version=0.13.16 diff --git a/project/plugins.sbt b/project/plugins.sbt index a91cecbcf..db3fc01f0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.0") +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value @@ -12,4 +12,4 @@ libraryDependencies += "jline" % "jline" % "2.11" addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") // For code formatting -addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.4.8") +addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.10") diff --git a/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/Compat.scala b/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/Compat.scala new file mode 100644 index 000000000..733137bf3 --- /dev/null +++ b/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/Compat.scala @@ -0,0 +1,46 @@ +package com.typesafe.sbt.packager + +import sbt.{Artifact, BufferedLogger, FullLogger, Logger} + +import scala.sys.process.ProcessLogger + +object Compat { + + /** + * Used in: + * + * - [[com.typesafe.sbt.packager.windows.WindowsPlugin]] + * - [[com.typesafe.sbt.packager.rpm.RpmHelper]] + * - [[com.typesafe.sbt.packager.docker.DockerPlugin]] + * - [[com.typesafe.sbt.packager.debian.DebianNativePackaging]] + * - [[com.typesafe.sbt.packager.rpm.RpmPlugin]] + * + * @param log + * @return turns a Logger into a ProcessLogger + */ + implicit def log2ProcessLogger(log: Logger): sys.process.ProcessLogger = + new BufferedLogger(new FullLogger(log)) with sys.process.ProcessLogger { + def err(s: => String): Unit = error(s) + def out(s: => String): Unit = info(s) + } + + /** + * Used in + * + * - [[com.typesafe.sbt.packager.docker.DockerPlugin]] + * + * @param logger The sbt.ProcessLogger that should be wrapped + * @return A scala ProcessLogger + */ + implicit def sbtProcessLogger2ScalaProcessLogger(logger: sbt.ProcessLogger): sys.process.ProcessLogger = + ProcessLogger(msg => logger.info(msg), err => logger.error(err)) + + /** + * Use in the scripted `universal/multiproject-classifiers` test. + * @param artifact polyfill new methods + */ + implicit class CompatArtifact(artifact: Artifact) { + def withClassifier(classifier: Option[String]): Artifact = + artifact.copy(classifier = classifier) + } +} diff --git a/src/main/scala/com/typesafe/sbt/packager/MappingsHelper.scala b/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/MappingsHelper.scala similarity index 97% rename from src/main/scala/com/typesafe/sbt/packager/MappingsHelper.scala rename to src/main/scala-sbt-0.13/com/typesafe/sbt/packager/MappingsHelper.scala index ca5b69d6c..0db096bbf 100644 --- a/src/main/scala/com/typesafe/sbt/packager/MappingsHelper.scala +++ b/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/MappingsHelper.scala @@ -1,8 +1,6 @@ -package com.typesafe.sbt -package packager +package com.typesafe.sbt.packager import sbt._ -import com.typesafe.sbt.packager.archetypes.JavaAppPackaging /** A set of helper methods to simplify the writing of mappings */ object MappingsHelper { diff --git a/src/main/scala/com/typesafe/sbt/packager/SettingsHelper.scala b/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/SettingsHelper.scala similarity index 98% rename from src/main/scala/com/typesafe/sbt/packager/SettingsHelper.scala rename to src/main/scala-sbt-0.13/com/typesafe/sbt/packager/SettingsHelper.scala index ba15bc15d..75f59c226 100644 --- a/src/main/scala/com/typesafe/sbt/packager/SettingsHelper.scala +++ b/src/main/scala-sbt-0.13/com/typesafe/sbt/packager/SettingsHelper.scala @@ -1,8 +1,7 @@ -package com.typesafe.sbt -package packager +package com.typesafe.sbt.packager -import sbt._ import sbt.Keys._ +import sbt._ object SettingsHelper { diff --git a/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/Compat.scala b/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/Compat.scala new file mode 100644 index 000000000..1cdc5ca1d --- /dev/null +++ b/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/Compat.scala @@ -0,0 +1,39 @@ +package com.typesafe.sbt.packager + +import sbt.{PathFinder, librarymanagement => lm} +import sbt.internal.{librarymanagement => ilm, BuildDependencies => InternalBuildDependencies} +import sbt.util.CacheStore + +object Compat { + val IvyActions = ilm.IvyActions + type IvySbt = ilm.IvySbt + type IvyScala = sbt.librarymanagement.ScalaModuleInfo + val IvyScala = sbt.librarymanagement.ScalaModuleInfo + + type UpdateConfiguration = lm.UpdateConfiguration + + /** + * Used in + * - [[com.typesafe.sbt.packager.archetypes.JavaAppPackaging]] + */ + type BuildDependencies = InternalBuildDependencies + + /** + * + */ + type Process = sys.process.Process + + /** + * Used in + * - [[com.typesafe.sbt.packager.docker.DockerPlugin]] + */ + type ProcessLogger = sys.process.ProcessLogger + + /** + * Used in + * - [[com.typesafe.sbt.packager.Stager]] + * @param file + * @return a CacheStore + */ + implicit def fileToCacheStore(file: java.io.File): CacheStore = CacheStore(file) +} diff --git a/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/MappingsHelper.scala b/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/MappingsHelper.scala new file mode 100644 index 000000000..afb0ee012 --- /dev/null +++ b/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/MappingsHelper.scala @@ -0,0 +1,84 @@ +package com.typesafe.sbt.packager + +import sbt._ +import sbt.io._ + +/** A set of helper methods to simplify the writing of mappings */ +object MappingsHelper extends Mapper { + + /** + * It lightens the build file if one wants to give a string instead of file. + * + * @example + * {{{ + * mappings in Universal ++= directory("extra") + * }}} + * + * @param sourceDir + * @return mappings + */ + def directory(sourceDir: String): Seq[(File, String)] = + directory(file(sourceDir)) + + /** + * It lightens the build file if one wants to give a string instead of file. + * + * @example + * {{{ + * mappings in Universal ++= sourceDir("extra") + * }}} + * + * @param sourceDir as string representation + * @return mappings + */ + def contentOf(sourceDir: String): Seq[(File, String)] = + contentOf(file(sourceDir)) + + /** + * Create mappings from your classpath. For example if you want to add additional + * dependencies, like test or model. + * + * + * @example Add all test artifacts to a separated test folder + * {{{ + * mappings in Universal ++= fromClasspath((managedClasspath in Test).value, target = "test") + * }}} + * + * @param entries + * @param target + * @return a list of mappings + */ + def fromClasspath(entries: Seq[Attributed[File]], target: String): Seq[(File, String)] = + fromClasspath(entries, target, _ => true) + + /** + * Create mappings from your classpath. For example if you want to add additional + * dependencies, like test or model. You can also filter the artifacts that should + * be mapped to mappings. + * + * @example Filter all osgi bundles + * {{{ + * mappings in Universal ++= fromClasspath( + * (managedClasspath in Runtime).value, + * "osgi", + * artifact => artifact.`type` == "bundle" + * ) + * }}} + * + * + * @param entries from where mappings should be created from + * @param target folder, e.g. `model`. Must not end with a slash + * @param includeArtifact function to determine if an artifact should result in a mapping + * @param includeOnNoArtifact default is false. When there's no Artifact meta data remove it + */ + def fromClasspath(entries: Seq[Attributed[File]], + target: String, + includeArtifact: Artifact => Boolean, + includeOnNoArtifact: Boolean = false): Seq[(File, String)] = + entries.filter(attr => attr.get(sbt.Keys.artifact.key) map includeArtifact getOrElse includeOnNoArtifact).map { + attribute => + val file = attribute.data + file -> s"$target/${file.getName}" + } + +} diff --git a/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/SettingsHelper.scala b/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/SettingsHelper.scala new file mode 100644 index 000000000..565dfdc60 --- /dev/null +++ b/src/main/scala-sbt-1.0/com/typesafe/sbt/packager/SettingsHelper.scala @@ -0,0 +1,69 @@ +package com.typesafe.sbt.packager + +import sbt._ +import sbt.Keys._ +import sbt.librarymanagement.{IvyFileConfiguration, PublishConfiguration} +import com.typesafe.sbt.packager.Compat._ + +/** + * TODO write tests for the SettingsHelper + * TODO document methods properly + * TODO document the sbt internal stuff that is used + */ +object SettingsHelper { + + def addPackage(config: Configuration, + packageTask: TaskKey[File], + extension: String, + classifier: Option[String] = None): Seq[Setting[_]] = inConfig(config)( + addArtifact( + name apply (Artifact( + _, + extension, + extension, + classifier = classifier, + configurations = Vector.empty, + url = None + )), + packageTask + ) + ) + + def makeDeploymentSettings(config: Configuration, + packageTask: TaskKey[File], + extension: String, + classifier: Option[String] = None): Seq[Setting[_]] = + // Why do we need the ivyPublishSettings and jvmPublishSettings ? + inConfig(config)(Classpaths.ivyPublishSettings ++ Classpaths.jvmPublishSettings) ++ inConfig(config)( + Seq( + artifacts := Seq.empty, + packagedArtifacts := Map.empty, + projectID := ModuleID(organization.value, name.value, version.value), + // Custom module settings to skip the ivy XmlModuleDescriptorParser + moduleSettings := ModuleDescriptorConfiguration(projectID.value, projectInfo.value) + .withScalaModuleInfo(scalaModuleInfo.value), + ivyModule := { + val ivy = ivySbt.value + new ivy.Module(moduleSettings.value) + }, + // Where have these settings gone? + // ------------------------------- + // deliverLocalConfiguration := Classpaths.deliverConfig(crossTarget.value, logging = ivyLoggingLevel.value) + // deliverConfiguration := deliverLocalConfiguration.value, + // ------------------------------- + publishConfiguration := PublishConfiguration() + .withResolverName(Classpaths.getPublishTo(publishTo.value).name) + .withArtifacts(packagedArtifacts.value.toVector) + .withChecksums(checksums.value.toVector) + .withOverwrite(isSnapshot.value) + .withLogging(UpdateLogging.DownloadOnly), + publishLocalConfiguration := PublishConfiguration() + .withResolverName("local") + .withArtifacts(packagedArtifacts.value.toVector) + .withChecksums(checksums.value.toVector) + .withOverwrite(isSnapshot.value) + .withLogging(UpdateLogging.DownloadOnly) + ) + ) ++ addPackage(config, packageTask, extension, classifier) + +} diff --git a/src/main/scala/com/typesafe/sbt/packager/Stager.scala b/src/main/scala/com/typesafe/sbt/packager/Stager.scala index c4fbd2c67..b909951cc 100644 --- a/src/main/scala/com/typesafe/sbt/packager/Stager.scala +++ b/src/main/scala/com/typesafe/sbt/packager/Stager.scala @@ -4,6 +4,8 @@ import sbt._ import sbt.Keys.TaskStreams import java.io.File +import com.typesafe.sbt.packager.Compat._ + object Stager { /** diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala index db716d3c1..7dd71df09 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala @@ -7,6 +7,7 @@ import com.typesafe.sbt.packager._ import com.typesafe.sbt.packager.Keys.packageName import com.typesafe.sbt.packager.linux.{LinuxFileMetaData, LinuxPackageMapping} import com.typesafe.sbt.packager.linux.LinuxPlugin.autoImport.{defaultLinuxInstallLocation, linuxPackageMappings} +import com.typesafe.sbt.packager.Compat._ /** * == Java Application == @@ -102,14 +103,18 @@ object JavaAppPackaging extends AutoPlugin { // ivy metadata if available. private def getJarFullFilename(dep: Attributed[File]): String = { val filename: Option[String] = for { - module <- dep.metadata.get(AttributeKey[ModuleID]("module-id")) + module <- dep.metadata + // sbt 0.13.x key + .get(AttributeKey[ModuleID]("module-id")) + // sbt 1.x key + .orElse(dep.metadata.get(AttributeKey[ModuleID]("moduleID"))) artifact <- dep.metadata.get(AttributeKey[Artifact]("artifact")) } yield makeJarName(module.organization, module.name, module.revision, artifact.name, artifact.classifier) filename.getOrElse(dep.data.getName) } // Here we grab the dependencies... - private def dependencyProjectRefs(build: sbt.BuildDependencies, thisProject: ProjectRef): Seq[ProjectRef] = + private def dependencyProjectRefs(build: BuildDependencies, thisProject: ProjectRef): Seq[ProjectRef] = build.classpathTransitive.getOrElse(thisProject, Nil) // TODO - Should we pull in more than just JARs? How do native packages come in? @@ -120,22 +125,24 @@ object JavaAppPackaging extends AutoPlugin { } private def findProjectDependencyArtifacts: Def.Initialize[Task[Seq[Attributed[File]]]] = - Def.task { - val stateTask = state.taskValue - val refs = thisProjectRef.value +: dependencyProjectRefs(buildDependencies.value, thisProjectRef.value) - // Dynamic lookup of dependencies... - val artTasks = refs map { ref => - extractArtifacts(stateTask, ref) - } - val allArtifactsTask: Task[Seq[Attributed[File]]] = - artTasks.fold[Task[Seq[Attributed[File]]]](task(Nil)) { (previous, next) => - for { - p <- previous - n <- next - } yield p ++ n.filter(isRuntimeArtifact) + Def + .task { + val stateTask = state.taskValue + val refs = thisProjectRef.value +: dependencyProjectRefs(buildDependencies.value, thisProjectRef.value) + // Dynamic lookup of dependencies... + val artTasks = refs map { ref => + extractArtifacts(stateTask, ref) } - allArtifactsTask - }.flatMap(identity) + val allArtifactsTask: Task[Seq[Attributed[File]]] = + artTasks.fold[Task[Seq[Attributed[File]]]](task(Nil)) { (previous, next) => + for { + p <- previous + n <- next + } yield p ++ n.filter(isRuntimeArtifact) + } + allArtifactsTask + } + .flatMap(identity) private def extractArtifacts(stateTask: Task[State], ref: ProjectRef): Task[Seq[Attributed[File]]] = stateTask.flatMap { state => diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala index 929139eef..c551614ea 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -158,12 +158,14 @@ object JavaServerAppPackaging extends AutoPlugin { */ private[this] def getEtcTemplateSource(sourceDirectory: File, loader: Option[ServerLoader]): java.net.URL = { val defaultTemplate = getClass.getResource(ETC_DEFAULT + "-template") - val (suffix, default) = loader.map { - case Upstart => ("-upstart", defaultTemplate) - case SystemV => ("-systemv", defaultTemplate) - case Systemd => - ("-systemd", getClass.getResource(ETC_DEFAULT + "-systemd-template")) - }.getOrElse(("", defaultTemplate)) + val (suffix, default) = loader + .map { + case Upstart => ("-upstart", defaultTemplate) + case SystemV => ("-systemv", defaultTemplate) + case Systemd => + ("-systemd", getClass.getResource(ETC_DEFAULT + "-systemd-template")) + } + .getOrElse(("", defaultTemplate)) val overrides = List[File](sourceDirectory / "templates" / (ETC_DEFAULT + suffix), sourceDirectory / "templates" / ETC_DEFAULT) diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/AshScriptPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/AshScriptPlugin.scala index 678769fb8..e8a4da4d0 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/AshScriptPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/AshScriptPlugin.scala @@ -97,9 +97,11 @@ object AshScriptPlugin extends AutoPlugin { (configFile map configFileDefine).toSeq ++ Seq(makeClasspathDefine(appClasspath)) private[this] def makeClasspathDefine(cp: Seq[String]): String = { - val fullString = cp map (n => - if (n.startsWith(File.separator)) n - else "$lib_dir/" + n) mkString ":" + val fullString = cp map ( + n => + if (n.startsWith(File.separator)) n + else "$lib_dir/" + n + ) mkString ":" "app_classpath=\"" + fullString + "\"\n" } diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/BashStartScriptPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/BashStartScriptPlugin.scala index c383a0fc2..d47652b2a 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/BashStartScriptPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/BashStartScriptPlugin.scala @@ -90,24 +90,26 @@ object BashStartScriptPlugin extends AutoPlugin { bashScriptConfigLocation: Option[String], tmpDir: File, log: Logger): Seq[(File, String)] = - bashScriptConfigLocation.collect { - case location if javaOptions.nonEmpty => - val configFile = tmpDir / "tmp" / "conf" / "application.ini" - //Do not use writeLines here because of issue #637 - IO.write(configFile, ("# options from build" +: javaOptions).mkString("\n")) - val filteredMappings = universalMappings.filter { - case (file, path) => path != appIniLocation - } - // Warn the user if he tries to specify options - if (filteredMappings.size < universalMappings.size) { - log.warn("--------!!! JVM Options are defined twice !!!-----------") - log.warn( - "application.ini is already present in output package. Will be overridden by 'javaOptions in Universal'" - ) - } - (configFile -> cleanApplicationIniPath(location)) +: filteredMappings - - }.getOrElse(universalMappings) + bashScriptConfigLocation + .collect { + case location if javaOptions.nonEmpty => + val configFile = tmpDir / "tmp" / "conf" / "application.ini" + //Do not use writeLines here because of issue #637 + IO.write(configFile, ("# options from build" +: javaOptions).mkString("\n")) + val filteredMappings = universalMappings.filter { + case (file, path) => path != appIniLocation + } + // Warn the user if he tries to specify options + if (filteredMappings.size < universalMappings.size) { + log.warn("--------!!! JVM Options are defined twice !!!-----------") + log.warn( + "application.ini is already present in output package. Will be overridden by 'javaOptions in Universal'" + ) + } + (configFile -> cleanApplicationIniPath(location)) +: filteredMappings + + } + .getOrElse(universalMappings) private[this] def generateStartScripts(config: BashScriptConfig, mainClass: Option[String], @@ -170,9 +172,11 @@ object BashStartScriptPlugin extends AutoPlugin { (configFile map configFileDefine).toSeq ++ Seq(makeClasspathDefine(appClasspath)) private[this] def makeClasspathDefine(cp: Seq[String]): String = { - val fullString = cp map (n => - if (n.startsWith(File.separator)) n - else "$lib_dir/" + n) mkString ":" + val fullString = cp map ( + n => + if (n.startsWith(File.separator)) n + else "$lib_dir/" + n + ) mkString ":" "declare -r app_classpath=\"" + fullString + "\"\n" } diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/DebianNativePackaging.scala b/src/main/scala/com/typesafe/sbt/packager/debian/DebianNativePackaging.scala index 39b013f9c..b816744ca 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/DebianNativePackaging.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/DebianNativePackaging.scala @@ -3,6 +3,7 @@ package com.typesafe.sbt.packager.debian import com.typesafe.sbt.SbtNativePackager.Debian import com.typesafe.sbt.packager.Keys._ import com.typesafe.sbt.packager.linux.LinuxFileMetaData +import com.typesafe.sbt.packager.Compat._ import sbt.Keys._ import sbt._ @@ -49,7 +50,7 @@ trait DebianNativePackaging extends DebianPluginLike { val deb = packageBin.value val role = debianSignRole.value val log = streams.value.log - Process(Seq("dpkg-sig", "-s", role, deb.getAbsolutePath), Some(deb.getParentFile)) ! log match { + sys.process.Process(Seq("dpkg-sig", "-s", role, deb.getAbsolutePath), Some(deb.getParentFile)) ! log match { case 0 => () case x => sys.error("Failed to sign debian package! exit code: " + x) @@ -58,7 +59,7 @@ trait DebianNativePackaging extends DebianPluginLike { }, lintian := { val file = packageBin.value - Process(Seq("lintian", "-c", "-v", file.getName), Some(file.getParentFile)).! + sys.process.Process(Seq("lintian", "-c", "-v", file.getName), Some(file.getParentFile)).! }, /** Implementation of the actual packaging */ packageBin := buildPackage( @@ -88,7 +89,7 @@ trait DebianNativePackaging extends DebianPluginLike { val changesFileName = debFile.getName.replaceAll("deb$", "changes") val changesFile: File = targetDir / ".." / changesFileName try { - val changes = Process(Seq("dpkg-genchanges", "-b"), Some(targetDir / "../tmp")).!! + val changes = sys.process.Process(Seq("dpkg-genchanges", "-b"), Some(targetDir / "../tmp")).!! val allChanges = List(changes) IO.writeLines(changesFile, allChanges) } catch { @@ -108,7 +109,7 @@ trait DebianNativePackaging extends DebianPluginLike { log.info("Building debian package with native implementation") // Make the package. We put this in fakeroot, so we can build the package with root owning files. val archive = archiveFilename(name, version, arch) - Process( + sys.process.Process( Seq("fakeroot", "--", "dpkg-deb", "--build") ++ buildOptions ++ Seq(stageDir.getAbsolutePath, "../" + archive), Some(stageDir) ) ! log match { diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala index e9a2d7c2a..9d3eb4fe7 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala @@ -134,13 +134,13 @@ object DebianPlugin extends AutoPlugin with DebianNativePackaging { // override and merge with the user defined scripts. Will change in the future val controlScriptsDir = debianControlScriptsDirectory.value val overridenScripts = scripts ++ readContent( - Seq( - scriptMapping(Names.Prerm, debianMakePrermScript.value, controlScriptsDir), - scriptMapping(Names.Preinst, debianMakePreinstScript.value, controlScriptsDir), - scriptMapping(Names.Postinst, debianMakePostinstScript.value, controlScriptsDir), - scriptMapping(Names.Postrm, debianMakePostrmScript.value, controlScriptsDir) - ).flatten - ) + Seq( + scriptMapping(Names.Prerm, debianMakePrermScript.value, controlScriptsDir), + scriptMapping(Names.Preinst, debianMakePreinstScript.value, controlScriptsDir), + scriptMapping(Names.Postinst, debianMakePostinstScript.value, controlScriptsDir), + scriptMapping(Names.Postrm, debianMakePostrmScript.value, controlScriptsDir) + ).flatten + ) // --- legacy ends // TODO remove the overridenScripts @@ -236,7 +236,7 @@ object DebianPlugin extends AutoPlugin with DebianNativePackaging { private[this] def createMD5SumFile(stageDir: File): File = { val md5file = stageDir / Names.DebianMaintainerScripts / "md5sums" val md5sums = for { - (file, name) <- stageDir.*** --- stageDir pair relativeTo(stageDir) + (file, name) <- (stageDir ** AllPassFilter) --- stageDir pair (file => IO.relativize(stageDir, file)) if file.isFile if !(name startsWith Names.DebianMaintainerScripts) if !(name contains "debian-binary") @@ -426,21 +426,25 @@ trait DebianPluginLike { val header = "# Chown definitions created by SBT Native Packager\n" // Check for non root user/group and create chown commands // filter all root mappings, map to (user,group) key, group by, append everything - val chowns = mappings.filter { - case LinuxPackageMapping(_, LinuxFileMetaData(Users.Root, Users.Root, _, _, _), _) => - false - case _ => true - }.map { - case LinuxPackageMapping(paths, meta, _) => - (meta.user, meta.group) -> paths - }.groupBy(_._1).map { - case ((user, group), pathList) => - validateUserGroupNames(user, streams) - validateUserGroupNames(group, streams) - val chown = chownCmd(user, group) _ - // remove key, flatten it and then use mapping path (_.2) to create chown command - pathList.flatMap(_._2).map(m => chown(m._2)) - } + val chowns = mappings + .filter { + case LinuxPackageMapping(_, LinuxFileMetaData(Users.Root, Users.Root, _, _, _), _) => + false + case _ => true + } + .map { + case LinuxPackageMapping(paths, meta, _) => + (meta.user, meta.group) -> paths + } + .groupBy(_._1) + .map { + case ((user, group), pathList) => + validateUserGroupNames(user, streams) + validateUserGroupNames(group, streams) + val chown = chownCmd(user, group) _ + // remove key, flatten it and then use mapping path (_.2) to create chown command + pathList.flatMap(_._2).map(m => chown(m._2)) + } val replacement = header :: chowns.flatten.toList mkString "\n" DebianPlugin.CHOWN_REPLACEMENT -> replacement } diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala b/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala index 7af1c5dfb..2f8f28eee 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala @@ -6,10 +6,10 @@ import sbt._ import sbt.Keys.{classpathTypes, normalizedName, packageBin, streams, target, version} import com.typesafe.sbt.packager.linux.{LinuxFileMetaData, LinuxPackageMapping, LinuxSymlink} import com.typesafe.sbt.packager.linux.LinuxPlugin.autoImport.{ -linuxPackageMappings, -linuxPackageSymlinks, -linuxScriptReplacements, -packageArchitecture + linuxPackageMappings, + linuxPackageSymlinks, + linuxScriptReplacements, + packageArchitecture } import scala.collection.JavaConversions._ import org.vafer.jdeb.{DataProducer, DebMaker} diff --git a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala index 83795f51a..b64c96fef 100644 --- a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala @@ -1,27 +1,17 @@ -package com.typesafe.sbt -package packager -package docker +package com.typesafe.sbt.packager.docker import java.io.File import java.util.concurrent.atomic.AtomicBoolean + import sbt._ -import sbt.Keys.{ - cacheDirectory, - clean, - mappings, - name, - publish, - publishArtifact, - publishLocal, - sourceDirectory, - streams, - target, - version -} -import packager.Keys._ -import linux.LinuxPlugin.autoImport.{daemonUser, defaultLinuxInstallLocation} -import universal.UniversalPlugin.autoImport.stage -import SbtNativePackager.{Linux, Universal} +import sbt.Keys.{clean, mappings, name, publish, publishLocal, sourceDirectory, streams, target, version} +import com.typesafe.sbt.packager.Keys._ +import com.typesafe.sbt.packager.linux.LinuxPlugin.autoImport.{daemonUser, defaultLinuxInstallLocation} +import com.typesafe.sbt.packager.universal.UniversalPlugin +import com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport.stage +import com.typesafe.sbt.SbtNativePackager.Universal +import com.typesafe.sbt.packager.Compat._ +import com.typesafe.sbt.packager.{MappingsHelper, Stager} /** * == Docker Plugin == @@ -68,37 +58,37 @@ object DockerPlugin extends AutoPlugin { */ val UnixSeparatorChar = '/' - override def requires = universal.UniversalPlugin + override def requires = UniversalPlugin override def projectConfigurations: Seq[Configuration] = Seq(Docker) override lazy val projectSettings: Seq[Setting[_]] = Seq( - dockerBaseImage := "openjdk:latest", - dockerExposedPorts := Seq(), - dockerExposedUdpPorts := Seq(), - dockerExposedVolumes := Seq(), - dockerLabels := Map(), - dockerRepository := None, - dockerUsername := None, - dockerAlias := DockerAlias( - dockerRepository.value, - dockerUsername.value, - (packageName in Docker).value, - Some((version in Docker).value) - ), - dockerUpdateLatest := false, - dockerEntrypoint := Seq("bin/%s" format executableScriptName.value), - dockerCmd := Seq(), - dockerExecCommand := Seq("docker"), - dockerBuildOptions := Seq("--force-rm") ++ Seq("-t", dockerAlias.value.versioned) ++ ( - if (dockerUpdateLatest.value) - Seq("-t", dockerAlias.value.latest) - else - Seq() - ), - dockerRmiCommand := dockerExecCommand.value ++ Seq("rmi"), - dockerBuildCommand := dockerExecCommand.value ++ Seq("build") ++ dockerBuildOptions.value ++ Seq("."), - dockerCommands := { + dockerBaseImage := "openjdk:latest", + dockerExposedPorts := Seq(), + dockerExposedUdpPorts := Seq(), + dockerExposedVolumes := Seq(), + dockerLabels := Map(), + dockerRepository := None, + dockerUsername := None, + dockerAlias := DockerAlias( + dockerRepository.value, + dockerUsername.value, + (packageName in Docker).value, + Some((version in Docker).value) + ), + dockerUpdateLatest := false, + dockerEntrypoint := Seq("bin/%s" format executableScriptName.value), + dockerCmd := Seq(), + dockerExecCommand := Seq("docker"), + dockerBuildOptions := Seq("--force-rm") ++ Seq("-t", dockerAlias.value.versioned) ++ ( + if (dockerUpdateLatest.value) + Seq("-t", dockerAlias.value.latest) + else + Seq() + ), + dockerRmiCommand := dockerExecCommand.value ++ Seq("rmi"), + dockerBuildCommand := dockerExecCommand.value ++ Seq("build") ++ dockerBuildOptions.value ++ Seq("."), + dockerCommands := { val dockerBaseDirectory = (defaultLinuxInstallLocation in Docker).value val user = (daemonUser in Docker).value val group = (daemonGroup in Docker).value @@ -112,46 +102,52 @@ object DockerPlugin extends AutoPlugin { makeVolumes(dockerExposedVolumes.value, user, group) ++ Seq(makeUser(user), makeEntrypoint(dockerEntrypoint.value), makeCmd(dockerCmd.value)) } - ) ++ mapGenericFilesToDocker ++ inConfig(Docker)( - Seq( - executableScriptName := executableScriptName.value, - mappings ++= dockerPackageMappings.value, - mappings ++= Seq(dockerGenerateConfig.value) pair relativeTo(target.value), - name := name.value, - packageName := packageName.value, - publishLocal := { + ) ++ mapGenericFilesToDocker ++ inConfig(Docker)( + Seq( + executableScriptName := executableScriptName.value, + mappings ++= dockerPackageMappings.value, + mappings ++= { + val baseDir = target.value + Seq(dockerGenerateConfig.value) pair (file => IO.relativize(baseDir, file)) + }, + name := name.value, + packageName := packageName.value, + publishLocal := { val log = streams.value.log publishLocalDocker(stage.value, dockerBuildCommand.value, log) log.info(s"Built image ${dockerAlias.value.versioned}") }, - publish := { + publish := { val _ = publishLocal.value val alias = dockerAlias.value val log = streams.value.log - publishDocker(dockerExecCommand.value, alias.versioned, log) + val execCommand = dockerExecCommand.value + publishDocker(execCommand, alias.versioned, log) if (dockerUpdateLatest.value) { - publishDocker(dockerExecCommand.value, alias.latest, log) + publishDocker(execCommand, alias.latest, log) } }, - clean := { + clean := { val alias = dockerAlias.value val log = streams.value.log - rmiDocker(dockerRmiCommand.value, alias.versioned, log) + val rmiCommand = dockerRmiCommand.value + // clean up images + rmiDocker(rmiCommand, alias.versioned, log) if (dockerUpdateLatest.value) { - rmiDocker(dockerRmiCommand.value, alias.latest, log) + rmiDocker(rmiCommand, alias.latest, log) } }, - sourceDirectory := sourceDirectory.value / "docker", - stage := Stager.stage(Docker.name)(streams.value, stagingDirectory.value, mappings.value), - stagingDirectory := (target in Docker).value / "stage", - target := target.value / "docker", - daemonUser := "daemon", - daemonGroup := daemonUser.value, - defaultLinuxInstallLocation := "/opt/docker", - dockerPackageMappings := MappingsHelper.contentOf(sourceDirectory.value), - dockerGenerateConfig := generateDockerConfig(dockerCommands.value, target.value) - ) + sourceDirectory := sourceDirectory.value / "docker", + stage := Stager.stage(Docker.name)(streams.value, stagingDirectory.value, mappings.value), + stagingDirectory := (target in Docker).value / "stage", + target := target.value / "docker", + daemonUser := "daemon", + daemonGroup := daemonUser.value, + defaultLinuxInstallLocation := "/opt/docker", + dockerPackageMappings := MappingsHelper.contentOf(sourceDirectory.value), + dockerGenerateConfig := generateDockerConfig(dockerCommands.value, target.value) ) + ) /** * @param maintainer (optional) @@ -296,8 +292,8 @@ object DockerPlugin extends AutoPlugin { } private[docker] def publishLocalLogger(log: Logger) = - new ProcessLogger { - def error(err: => String): Unit = + new sys.process.ProcessLogger { + override def err(err: => String): Unit = err match { case s if s.startsWith("Uploading context") => log.debug(s) // pre-1.0 @@ -307,40 +303,40 @@ object DockerPlugin extends AutoPlugin { case s => } - def info(inf: => String): Unit = inf match { + override def out(inf: => String): Unit = inf match { case s if !s.trim.isEmpty => log.info(s) case s => } - def buffer[T](f: => T): T = f + override def buffer[T](f: => T): T = f } def publishLocalDocker(context: File, buildCommand: Seq[String], log: Logger): Unit = { log.debug("Executing Native " + buildCommand.mkString(" ")) log.debug("Working directory " + context.toString) - val ret = Process(buildCommand, context) ! publishLocalLogger(log) + val ret = sys.process.Process(buildCommand, context) ! publishLocalLogger(log) if (ret != 0) throw new RuntimeException("Nonzero exit value: " + ret) } def rmiDocker(execCommand: Seq[String], tag: String, log: Logger): Unit = { - def rmiDockerLogger(log: Logger) = new ProcessLogger { - def error(err: => String): Unit = err match { + def rmiDockerLogger(log: Logger) = new sys.process.ProcessLogger { + override def err(err: => String): Unit = err match { case s if !s.trim.isEmpty => log.error(s) case s => } - def info(inf: => String): Unit = log.info(inf) + override def out(inf: => String): Unit = log.info(inf) - def buffer[T](f: => T): T = f + override def buffer[T](f: => T): T = f } log.debug(s"Removing ${tag}") val cmd = execCommand :+ tag - val ret = Process(cmd) ! rmiDockerLogger(log) + val ret = sys.process.Process(cmd) ! rmiDockerLogger(log) if (ret != 0) sys.error(s"Nonzero exit value: ${ret}") @@ -352,14 +348,14 @@ object DockerPlugin extends AutoPlugin { val loginRequired = new AtomicBoolean(false) def publishLogger(log: Logger) = - new ProcessLogger { + new sys.process.ProcessLogger { - def error(err: => String): Unit = err match { + override def err(err: => String): Unit = err match { case s if !s.trim.isEmpty => log.error(s) case s => } - def info(inf: => String): Unit = + override def out(inf: => String): Unit = inf match { case s if s.startsWith("Please login") => loginRequired.compareAndSet(false, true) @@ -367,14 +363,14 @@ object DockerPlugin extends AutoPlugin { case s => } - def buffer[T](f: => T): T = f + override def buffer[T](f: => T): T = f } val cmd = execCommand ++ Seq("push", tag) log.debug("Executing " + cmd.mkString(" ")) - val ret = Process(cmd) ! publishLogger(log) + val ret = sys.process.Process(cmd) ! publishLogger(log) if (loginRequired.get) sys.error("""No credentials for repository, please run "docker login"""") diff --git a/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala index 134726a49..26aba10dd 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala @@ -23,23 +23,23 @@ object ClasspathJarPlugin extends AutoPlugin { override def requires = JavaAppPackaging override lazy val projectSettings: Seq[Setting[_]] = Defaults - .packageTaskSettings(packageJavaClasspathJar, mappings in packageJavaClasspathJar) ++ Seq( - mappings in packageJavaClasspathJar := Nil, - artifactClassifier in packageJavaClasspathJar := Option("classpath"), - packageOptions in packageJavaClasspathJar := { + .packageTaskSettings(packageJavaClasspathJar, mappings in packageJavaClasspathJar) ++ Seq( + mappings in packageJavaClasspathJar := Nil, + artifactClassifier in packageJavaClasspathJar := Option("classpath"), + packageOptions in packageJavaClasspathJar := { val classpath = (scriptClasspath in packageJavaClasspathJar).value val manifestClasspath = Attributes.Name.CLASS_PATH -> classpath.mkString(" ") Seq(ManifestAttributes(manifestClasspath)) }, - artifactName in packageJavaClasspathJar := { (scalaVersion, moduleId, artifact) => + artifactName in packageJavaClasspathJar := { (scalaVersion, moduleId, artifact) => moduleId.organization + "." + artifact.name + "-" + moduleId.revision + artifact.classifier.fold("")("-" + _) + "." + artifact.extension }, - scriptClasspath in bashScriptDefines := Seq((artifactPath in packageJavaClasspathJar).value.getName), - scriptClasspath in batScriptReplacements := Seq((artifactPath in packageJavaClasspathJar).value.getName), - mappings in Universal += { + scriptClasspath in bashScriptDefines := Seq((artifactPath in packageJavaClasspathJar).value.getName), + scriptClasspath in batScriptReplacements := Seq((artifactPath in packageJavaClasspathJar).value.getName), + mappings in Universal += { val classpathJar = packageJavaClasspathJar.value classpathJar -> ("lib/" + classpathJar.getName) } - ) + ) } diff --git a/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala index edd244b9b..8db6e42ef 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala @@ -24,31 +24,31 @@ object LauncherJarPlugin extends AutoPlugin { override def requires = JavaAppPackaging override lazy val projectSettings: Seq[Setting[_]] = Defaults - .packageTaskSettings(packageJavaLauncherJar, mappings in packageJavaLauncherJar) ++ Seq( - mappings in packageJavaLauncherJar := Nil, - artifactClassifier in packageJavaLauncherJar := Option("launcher"), - packageOptions in packageJavaLauncherJar := { + .packageTaskSettings(packageJavaLauncherJar, mappings in packageJavaLauncherJar) ++ Seq( + mappings in packageJavaLauncherJar := Nil, + artifactClassifier in packageJavaLauncherJar := Option("launcher"), + packageOptions in packageJavaLauncherJar := { val classpath = (scriptClasspath in packageJavaLauncherJar).value val manifestClasspath = Attributes.Name.CLASS_PATH -> classpath.mkString(" ") val manifestMainClass = (mainClass in (Compile, packageJavaLauncherJar)).value.map(Attributes.Name.MAIN_CLASS -> _) Seq(ManifestAttributes(manifestMainClass.toSeq :+ manifestClasspath: _*)) }, - artifactName in packageJavaLauncherJar := { (scalaVersion, moduleId, artifact) => + artifactName in packageJavaLauncherJar := { (scalaVersion, moduleId, artifact) => moduleId.organization + "." + artifact.name + "-" + moduleId.revision + artifact.classifier.fold("")("-" + _) + "." + artifact.extension }, - mainClass in (Compile, bashScriptDefines) := { + mainClass in (Compile, bashScriptDefines) := { Some("-jar $lib_dir/" + (artifactPath in packageJavaLauncherJar).value.getName) }, - scriptClasspath in bashScriptDefines := Nil, - mainClass in (Compile, batScriptReplacements) := { + scriptClasspath in bashScriptDefines := Nil, + mainClass in (Compile, batScriptReplacements) := { Some("-jar %APP_LIB_DIR%\\" + (artifactPath in packageJavaLauncherJar).value.getName) }, - scriptClasspath in batScriptReplacements := Nil, - mappings in Universal += { + scriptClasspath in batScriptReplacements := Nil, + mappings in Universal += { val javaLauncher = packageJavaLauncherJar.value javaLauncher -> ("lib/" + javaLauncher.getName) } - ) + ) } diff --git a/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerAntHelper.scala b/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerAntHelper.scala index 736eca1d7..9ef90b516 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerAntHelper.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerAntHelper.scala @@ -31,7 +31,7 @@ object JDKPackagerAntHelper { sys.env.get("JDK_HOME").map(file), sys.env.get("JAVA_HOME").map(file), // MacOS X - Try("/usr/libexec/java_home".!!.trim).toOption.map(file), + Try(sys.process.Process("/usr/libexec/java_home").!!.trim).toOption.map(file), // From system properties sys.props.get("java.home").map(file) ) diff --git a/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerPlugin.scala index 856573178..b41943202 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jdkpackager/JDKPackagerPlugin.scala @@ -33,59 +33,53 @@ object JDKPackagerPlugin extends AutoPlugin { override def projectConfigurations: Seq[Configuration] = Seq(JDKPackager) override lazy val projectSettings: Seq[Setting[_]] = Seq( - jdkAppIcon := None, - jdkPackagerType := "installer", - jdkPackagerBasename := packageName.value + "-pkg", - jdkPackagerToolkit := JavaFXToolkit, - jdkPackagerJVMArgs := Seq("-Xmx768m"), - jdkPackagerAppArgs := Seq.empty, - jdkPackagerProperties := Map.empty, - jdkPackagerAssociations := Seq.empty - ) ++ inConfig(JDKPackager)( - Seq( - sourceDirectory := sourceDirectory.value / "deploy", - target := target.value / dirname, - mainClass := (mainClass in Runtime).value, - name := name.value, - packageName := packageName.value, - maintainer := maintainer.value, - packageSummary := packageSummary.value, - packageDescription := packageDescription.value, - mappings := (mappings in Universal).value, - antPackagerTasks := locateAntTasks(javaHome.value, sLog.value), - antExtraClasspath := Seq(sourceDirectory.value, target.value), - antBuildDefn := makeAntBuild( - antPackagerTasks.value, - antExtraClasspath.value, - name.value, - (stage in Universal).value, - mappings.value, - platformDOM(jdkPackagerJVMArgs.value, jdkPackagerProperties.value), - applicationDOM( + jdkAppIcon := None, + jdkPackagerType := "installer", + jdkPackagerBasename := packageName.value + "-pkg", + jdkPackagerToolkit := JavaFXToolkit, + jdkPackagerJVMArgs := Seq("-Xmx768m"), + jdkPackagerAppArgs := Seq.empty, + jdkPackagerProperties := Map.empty, + jdkPackagerAssociations := Seq.empty + ) ++ inConfig(JDKPackager)( + Seq( + sourceDirectory := sourceDirectory.value / "deploy", + target := target.value / dirname, + mainClass := (mainClass in Runtime).value, + name := name.value, + packageName := packageName.value, + maintainer := maintainer.value, + packageSummary := packageSummary.value, + packageDescription := packageDescription.value, + mappings := (mappings in Universal).value, + antPackagerTasks := locateAntTasks(javaHome.value, sLog.value), + antExtraClasspath := Seq(sourceDirectory.value, target.value), + antBuildDefn := makeAntBuild( + antPackagerTasks.value, + antExtraClasspath.value, + name.value, + (stage in Universal).value, + mappings.value, + platformDOM(jdkPackagerJVMArgs.value, jdkPackagerProperties.value), + applicationDOM(name.value, version.value, mainClass.value, jdkPackagerToolkit.value, jdkPackagerAppArgs.value), + deployDOM( + jdkPackagerBasename.value, + jdkPackagerType.value, + (artifactPath in LauncherJarPlugin.autoImport.packageJavaLauncherJar).value, + target.value, + infoDOM( name.value, - version.value, - mainClass.value, - jdkPackagerToolkit.value, - jdkPackagerAppArgs.value - ), - deployDOM( - jdkPackagerBasename.value, - jdkPackagerType.value, - (artifactPath in LauncherJarPlugin.autoImport.packageJavaLauncherJar).value, - target.value, - infoDOM( - name.value, - packageDescription.value, - maintainer.value, - jdkAppIcon.value, - jdkPackagerAssociations.value - ) + packageDescription.value, + maintainer.value, + jdkAppIcon.value, + jdkPackagerAssociations.value ) - ), - writeAntBuild := writeAntFile(target.value, antBuildDefn.value, streams.value), - packageBin := buildPackageWithAnt(writeAntBuild.value, target.value, streams.value) - ) + ) + ), + writeAntBuild := writeAntFile(target.value, antBuildDefn.value, streams.value), + packageBin := buildPackageWithAnt(writeAntBuild.value, target.value, streams.value) ) + ) } diff --git a/src/main/scala/com/typesafe/sbt/packager/linux/LinuxMappingDSL.scala b/src/main/scala/com/typesafe/sbt/packager/linux/LinuxMappingDSL.scala index 39d974be2..175e03fa0 100644 --- a/src/main/scala/com/typesafe/sbt/packager/linux/LinuxMappingDSL.scala +++ b/src/main/scala/com/typesafe/sbt/packager/linux/LinuxMappingDSL.scala @@ -30,7 +30,7 @@ trait LinuxMappingDSL { def mapDirectoryAndContents(dirs: (File, String)*): Seq[(File, String)] = for { (src, dest) <- dirs - path <- (src ***).get + path <- (src ** AllPassFilter).get } yield path -> path.toString.replaceFirst(src.toString, dest) /** diff --git a/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPackageMapping.scala b/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPackageMapping.scala index 7e3354243..66ce1b0df 100644 --- a/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPackageMapping.scala +++ b/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPackageMapping.scala @@ -44,9 +44,9 @@ object LinuxSymlink { val partsTo: Seq[String] = to split "/" filterNot (_.isEmpty) val prefixAndOne = (1 to partsFrom.length) - .map(partsFrom.take) - .dropWhile(seq => partsTo.startsWith(seq)) - .headOption getOrElse sys.error("Cannot symlink to yourself!") + .map(partsFrom.take) + .dropWhile(seq => partsTo.startsWith(seq)) + .headOption getOrElse sys.error("Cannot symlink to yourself!") val prefix = prefixAndOne dropRight 1 if (prefix.length > 0) { val escapeCount = (partsTo.length - 1) - prefix.length @@ -77,7 +77,7 @@ object LinuxSymlink { // from ln man page // -f --force remove existing destination files if (!to.exists) - Process(Seq("ln", "-sf", linkFinal, name), linkDir).! match { + sys.process.Process(Seq("ln", "-sf", linkFinal, name), linkDir).! match { case 0 => () case n => sys.error("Failed to symlink " + link.destination + " to " + to) diff --git a/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPlugin.scala index 0d9b35ed7..7638ff9a7 100644 --- a/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPlugin.scala @@ -192,7 +192,7 @@ object LinuxPlugin extends AutoPlugin { /** Create a ascii friendly string for a man page. */ final def makeMan(file: File): String = - Process("groff -man -Tascii " + file.getAbsolutePath).!! + sys.process.Process("groff -man -Tascii " + file.getAbsolutePath).!! // This method wires a lot of hand-coded generalities about how to map directories // into linux, and the conventions we expect. diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala index 8bfc35d63..b6d40c95f 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala @@ -1,15 +1,13 @@ -package com.typesafe.sbt -package packager -package rpm +package com.typesafe.sbt.packager.rpm import sbt._ -import com.typesafe.sbt.packager.linux.LinuxSymlink +import com.typesafe.sbt.packager.Compat._ object RpmHelper { /** Returns the host vendor for an rpm. */ def hostVendor = - Process(Seq("rpm", "-E", "%{_host_vendor}")) !! + sys.process.Process(Seq("rpm", "-E", "%{_host_vendor}")) !! /** * Prepares the staging directory for the rpm build command. @@ -104,7 +102,7 @@ object RpmHelper { else Seq.empty ) ++ Seq(spec.meta.name + ".spec") log.debug("Executing rpmbuild with: " + args.mkString(" ")) - (Process(args, Some(specsDir)) ! log) match { + (sys.process.Process(args, Some(specsDir)) ! log) match { case 0 => () case code => sys.error("Unable to run rpmbuild, check output for details. Errorcode " + code) @@ -126,5 +124,5 @@ object RpmHelper { } def evalMacro(mcro: String): String = - Process(Seq("rpm", "--eval", '%' + mcro)).!! + sys.process.Process(Seq("rpm", "--eval", '%' + mcro)).!! } diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala index 779eea4a5..9d3f6fdf1 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala @@ -301,9 +301,11 @@ case class RpmSpec(meta: RpmMetadata, if (symlinks.isEmpty) None else { - val relocateLinks = symlinks.map { symlink => - s"""rm -rf $$(relocateLink ${symlink.link} $installDir $appName $$RPM_INSTALL_PREFIX) && ln -s $$(relocateLink ${symlink.destination} $installDir $appName $$RPM_INSTALL_PREFIX) $$(relocateLink ${symlink.link} $installDir $appName $$RPM_INSTALL_PREFIX)""" - }.mkString("\n") + val relocateLinks = symlinks + .map { symlink => + s"""rm -rf $$(relocateLink ${symlink.link} $installDir $appName $$RPM_INSTALL_PREFIX) && ln -s $$(relocateLink ${symlink.destination} $installDir $appName $$RPM_INSTALL_PREFIX) $$(relocateLink ${symlink.link} $installDir $appName $$RPM_INSTALL_PREFIX)""" + } + .mkString("\n") Some(relocateLinkFunction + "\n" + relocateLinks) } @@ -315,9 +317,11 @@ case class RpmSpec(meta: RpmMetadata, val checkUninstall = "if [ $1 -eq 0 ] ;\nthen" val sourceAppConfig = s""" [ -e /etc/sysconfig/$appName ] && . /etc/sysconfig/$appName""" - val cleanupLinks = symlinks.map { symlink => - s""" rm -rf $$(relocateLink ${symlink.link} $installDir $appName $$PACKAGE_PREFIX)""" - }.mkString("\n") + val cleanupLinks = symlinks + .map { symlink => + s""" rm -rf $$(relocateLink ${symlink.link} $installDir $appName $$PACKAGE_PREFIX)""" + } + .mkString("\n") Some(relocateLinkFunction + "\n" + checkUninstall + "\n" + sourceAppConfig + "\n" + cleanupLinks + "\nfi") } diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala index 21d233530..c15fbd8a3 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala @@ -1,13 +1,14 @@ package com.typesafe.sbt.packager.rpm import sbt._ -import sbt.Keys.{name, packageBin, sourceDirectory, streams, target, version, isSnapshot} +import sbt.Keys.{isSnapshot, name, packageBin, sourceDirectory, streams, target, version} import java.nio.charset.Charset import com.typesafe.sbt.SbtNativePackager.Linux import com.typesafe.sbt.packager.SettingsHelper import com.typesafe.sbt.packager.Keys._ import com.typesafe.sbt.packager.linux._ +import com.typesafe.sbt.packager.Compat._ /** * Plugin containing all generic values used for packaging rpms. @@ -157,7 +158,7 @@ object RpmPlugin extends AutoPlugin { stage in Rpm := RpmHelper.stage(rpmSpecConfig.value, (target in Rpm).value, streams.value.log), packageBin in Rpm := RpmHelper.buildRpm(rpmSpecConfig.value, (stage in Rpm).value, streams.value.log), rpmLint := { - Process(Seq("rpmlint", "-v", (packageBin in Rpm).value.getAbsolutePath)) ! streams.value.log match { + sys.process.Process(Seq("rpmlint", "-v", (packageBin in Rpm).value.getAbsolutePath)) ! streams.value.log match { case 0 => () case x => sys.error("Failed to run rpmlint, exit status: " + x) } diff --git a/src/main/scala/com/typesafe/sbt/packager/universal/Archives.scala b/src/main/scala/com/typesafe/sbt/packager/universal/Archives.scala index 52fa86708..bf2e20bb4 100644 --- a/src/main/scala/com/typesafe/sbt/packager/universal/Archives.scala +++ b/src/main/scala/com/typesafe/sbt/packager/universal/Archives.scala @@ -134,10 +134,12 @@ object Archives { val neededMegabytes = math.ceil((sizeBytes * 1.05) / (1024 * 1024)).toLong // Create the DMG file: - Process( - Seq("hdiutil", "create", "-megabytes", "%d" format neededMegabytes, "-fs", "HFS+", "-volname", name, name), - Some(target) - ).! match { + sys.process + .Process( + Seq("hdiutil", "create", "-megabytes", "%d" format neededMegabytes, "-fs", "HFS+", "-volname", name, name), + Some(target) + ) + .! match { case 0 => () case n => sys.error("Error creating dmg: " + dmg + ". Exit code " + n) } @@ -146,7 +148,9 @@ object Archives { val mountPoint = (t / name) if (!mountPoint.isDirectory) IO.createDirectory(mountPoint) val mountedPath = mountPoint.getAbsolutePath - Process(Seq("hdiutil", "attach", dmg.getAbsolutePath, "-readwrite", "-mountpoint", mountedPath), Some(target)).! match { + sys.process + .Process(Seq("hdiutil", "attach", dmg.getAbsolutePath, "-readwrite", "-mountpoint", mountedPath), Some(target)) + .! match { case 0 => () case n => sys.error("Unable to mount dmg: " + dmg + ". Exit code " + n) } @@ -161,7 +165,7 @@ object Archives { } to.setExecutable(true, true) // Now unmount - Process(Seq("hdiutil", "detach", mountedPath), Some(target)).! match { + sys.process.Process(Seq("hdiutil", "detach", mountedPath), Some(target)).! match { case 0 => () case n => sys.error("Unable to dismount dmg: " + dmg + ". Exit code " + n) @@ -177,7 +181,7 @@ object Archives { */ def gzip(f: File): File = { val par = f.getParentFile - Process(Seq("gzip", "-9", f.getAbsolutePath), Some(par)).! match { + sys.process.Process(Seq("gzip", "-9", f.getAbsolutePath), Some(par)).! match { case 0 => () case n => sys.error("Error gziping " + f + ". Exit code: " + n) } @@ -190,7 +194,7 @@ object Archives { */ def xz(f: File): File = { val par = f.getParentFile - Process(Seq("xz", "-9e", "-S", ".xz", f.getAbsolutePath), Some(par)).! match { + sys.process.Process(Seq("xz", "-9e", "-S", ".xz", f.getAbsolutePath), Some(par)).! match { case 0 => () case n => sys.error("Error xz-ing " + f + ". Exit code: " + n) } @@ -240,7 +244,7 @@ object Archives { IO.copy(m2) // TODO - Is this enough? - for ( (from, to) <- m2 if (to.getAbsolutePath contains "/bin/") || from.canExecute ) { + for ((from, to) <- m2 if (to.getAbsolutePath contains "/bin/") || from.canExecute) { println("Making " + to.getAbsolutePath + " executable") to.setExecutable(true, false) } @@ -256,7 +260,7 @@ object Archives { val cmd = Seq("tar") ++ options ++ Seq(tmptar.getAbsolutePath) ++ distdirs println("Running with " + cmd.mkString(" ")) - Process(cmd, Some(rdir)).! match { + sys.process.Process(cmd, Some(rdir)).! match { case 0 => () case n => sys.error("Error tarballing " + tarball + ". Exit code: " + n) diff --git a/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala index 9e821297f..e37bc6b6e 100644 --- a/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala @@ -47,22 +47,22 @@ object UniversalPlugin extends AutoPlugin { /** The basic settings for the various packaging types. */ override lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( - // For now, we provide delegates from dist/stage to universal... - dist := (dist in Universal).value, - stage := (stage in Universal).value, - // TODO - New default to naming, is this right? - // TODO - We may need to do this for UniversalSrcs + UnviersalDocs - name in Universal := name.value, - name in UniversalDocs := (name in Universal).value, - name in UniversalSrc := (name in Universal).value, - packageName in Universal := packageName.value, - topLevelDirectory := Some((packageName in Universal).value), - executableScriptName in Universal := executableScriptName.value - ) ++ - makePackageSettingsForConfig(Universal) ++ - makePackageSettingsForConfig(UniversalDocs) ++ - makePackageSettingsForConfig(UniversalSrc) ++ - defaultUniversalArchiveOptions + // For now, we provide delegates from dist/stage to universal... + dist := (dist in Universal).value, + stage := (stage in Universal).value, + // TODO - New default to naming, is this right? + // TODO - We may need to do this for UniversalSrcs + UnviersalDocs + name in Universal := name.value, + name in UniversalDocs := (name in Universal).value, + name in UniversalSrc := (name in Universal).value, + packageName in Universal := packageName.value, + topLevelDirectory := Some((packageName in Universal).value), + executableScriptName in Universal := executableScriptName.value + ) ++ + makePackageSettingsForConfig(Universal) ++ + makePackageSettingsForConfig(UniversalDocs) ++ + makePackageSettingsForConfig(UniversalSrc) ++ + defaultUniversalArchiveOptions /** Creates all package types for a given configuration */ private[this] def makePackageSettingsForConfig(config: Configuration): Seq[Setting[_]] = @@ -128,7 +128,7 @@ object UniversalPlugin extends AutoPlugin { /** Finds all sources in a source directory. */ private[this] def findSources(sourceDir: File): Seq[(File, String)] = - sourceDir.*** --- sourceDir pair relativeTo(sourceDir) + ((PathFinder(sourceDir) ** AllPassFilter) --- sourceDir).pair(file => IO.relativize(sourceDir, file)) } diff --git a/src/main/scala/com/typesafe/sbt/packager/universal/ZipHelper.scala b/src/main/scala/com/typesafe/sbt/packager/universal/ZipHelper.scala index 6c32b4da4..4a0cbe0a5 100644 --- a/src/main/scala/com/typesafe/sbt/packager/universal/ZipHelper.scala +++ b/src/main/scala/com/typesafe/sbt/packager/universal/ZipHelper.scala @@ -41,7 +41,7 @@ object ZipHelper { if src.canExecute } target.setExecutable(true, true) val dirFileNames = Option(zipDir.listFiles) getOrElse Array.empty[java.io.File] map (_.getName) - Process(Seq("zip", "-r", name) ++ dirFileNames, zipDir).! match { + sys.process.Process(Seq("zip", "-r", name) ++ dirFileNames, zipDir).! match { case 0 => () case n => sys.error("Failed to run native zip application!") } diff --git a/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala index e264fb908..0931297c2 100644 --- a/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala @@ -1,11 +1,12 @@ -package com.typesafe.sbt -package packager -package windows +package com.typesafe.sbt.packager.windows import sbt._ -import sbt.Keys.{mappings, name, normalizedName, packageBin, sourceDirectory, streams, target, version} -import packager.Keys.{maintainer, packageDescription, packageName, packageSummary} -import SbtNativePackager.Universal +import sbt.Keys.{mappings, name, packageBin, sourceDirectory, streams, target, version} +import com.typesafe.sbt.SbtNativePackager.Universal +import com.typesafe.sbt.packager.Keys.{maintainer, packageDescription, packageName, packageSummary} +import com.typesafe.sbt.packager.universal.UniversalPlugin +import com.typesafe.sbt.packager.Compat._ +import com.typesafe.sbt.packager.SettingsHelper /** * == Windows Plugin == @@ -37,7 +38,7 @@ object WindowsPlugin extends AutoPlugin { import autoImport._ override lazy val projectSettings: Seq[Setting[_]] = windowsSettings ++ mapGenericFilesToWindows - override def requires = universal.UniversalPlugin + override def requires = UniversalPlugin override def projectConfigurations: Seq[Configuration] = Seq(Windows) @@ -105,11 +106,11 @@ object WindowsPlugin extends AutoPlugin { IO.copy(for ((f, to) <- mappings.value) yield (f, target.value / to)) // Now compile WIX val wixdir = Option(System.getenv("WIX")) getOrElse sys.error( - "WIX environment not found. Please ensure WIX is installed on this computer." - ) + "WIX environment not found. Please ensure WIX is installed on this computer." + ) val candleCmd = Seq(wixdir + "\\bin\\candle.exe", wix.getAbsolutePath) ++ candleOptions.value streams.value.log.debug(candleCmd mkString " ") - Process(candleCmd, Some(target.value)) ! streams.value.log match { + sys.process.Process(candleCmd, Some(target.value)) ! streams.value.log match { case 0 => () case exitCode => sys.error(s"Unable to run WIX compilation to wixobj. Exited with ${exitCode}") } @@ -117,7 +118,7 @@ object WindowsPlugin extends AutoPlugin { val wixobj = target.value / (name.value + ".wixobj") val lightCmd = Seq(wixdir + "\\bin\\light.exe", wixobj.getAbsolutePath) ++ lightOptions.value streams.value.log.debug(lightCmd mkString " ") - Process(lightCmd, Some(target.value)) ! streams.value.log match { + sys.process.Process(lightCmd, Some(target.value)) ! streams.value.log match { case 0 => () case exitCode => sys.error(s"Unable to run build msi. Exited with ${exitCode}") } @@ -139,7 +140,7 @@ object WindowsPlugin extends AutoPlugin { * @param mappings - use to generate different features * @return windows features */ - def makeWindowsFeatures(name: String, mappings: Seq[(File, String)]): Seq[windows.WindowsFeature] = { + def makeWindowsFeatures(name: String, mappings: Seq[(File, String)]): Seq[WindowsFeature] = { // TODO select main script! Filter Config links! val files = diff --git a/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala b/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala index c79482a86..15b2c5f12 100644 --- a/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala +++ b/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala @@ -258,7 +258,7 @@ object WixHelper { */ def cleanStringForId(n: String) = { val x = n.replaceAll("[^0-9a-zA-Z_]", "_").takeRight(59) + (math.abs(n.hashCode).toString + "xxxxxxxxx") - .substring(0, 9) + .substring(0, 9) if (x startsWith "_") x else "_" + x } diff --git a/src/sbt-test/ash/memory-settings/build.sbt b/src/sbt-test/ash/memory-settings/build.sbt index 966f92642..e0c5aa259 100644 --- a/src/sbt-test/ash/memory-settings/build.sbt +++ b/src/sbt-test/ash/memory-settings/build.sbt @@ -6,16 +6,16 @@ version := "0.1.0" bashScriptExtraDefines ++= Seq("""addJava "-Xms64m"""", """addJava "-Xmx64m"""") -TaskKey[Unit]("script-check") := { +TaskKey[Unit]("scriptCheck") := { val startScript = (stagingDirectory in Universal).value / "bin" / executableScriptName.value val options = IO.read(startScript) assert(options contains """addJava "-Xms64m"""", "Script doesn't contain xmx setting:\n" + options) assert(options contains """addJava "-Xmx64m"""", "Script doesn't contain xms setting:\n" + options) } -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val cwd = (stagingDirectory in Universal).value val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath) - val memory = (Process(cmd, cwd).!!).replaceAll("\n", "") + val memory = (sys.process.Process(cmd, cwd).!!).replaceAll("\n", "") assert(memory.toLong <= 64, "Runtime memory is bigger then 64m < " + memory + "m") } diff --git a/src/sbt-test/ash/memory-settings/test b/src/sbt-test/ash/memory-settings/test index 10f7ae9c4..b2923955e 100644 --- a/src/sbt-test/ash/memory-settings/test +++ b/src/sbt-test/ash/memory-settings/test @@ -1,5 +1,5 @@ # Run the staging and check the script. > stage $ exists target/universal/stage/bin/simple-app -> script-check -> run-check \ No newline at end of file +> scriptCheck +> runCheck \ No newline at end of file diff --git a/src/sbt-test/ash/override-templates/build.sbt b/src/sbt-test/ash/override-templates/build.sbt index bc226f2c7..0d3f9c883 100644 --- a/src/sbt-test/ash/override-templates/build.sbt +++ b/src/sbt-test/ash/override-templates/build.sbt @@ -8,7 +8,7 @@ version := "0.1.0" bashScriptTemplateLocation := baseDirectory.value / "custom-templates" / "custom-ash-template" -TaskKey[Unit]("run-check-ash") := { +TaskKey[Unit]("runCheckAsh") := { val cwd = (stagingDirectory in Universal).value val source = scala.io.Source.fromFile((cwd / "bin" / packageName.value).getAbsolutePath) diff --git a/src/sbt-test/ash/override-templates/test b/src/sbt-test/ash/override-templates/test index aa3b5ad81..8298132fb 100644 --- a/src/sbt-test/ash/override-templates/test +++ b/src/sbt-test/ash/override-templates/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check-ash +> runCheckAsh diff --git a/src/sbt-test/ash/simple-app/build.sbt b/src/sbt-test/ash/simple-app/build.sbt index fc72c64e1..c0abd383e 100644 --- a/src/sbt-test/ash/simple-app/build.sbt +++ b/src/sbt-test/ash/simple-app/build.sbt @@ -1,12 +1,14 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(AshScriptPlugin) name := "simple-app" version := "0.1.0" -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val cwd = (stagingDirectory in Universal).value val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath) - val output = Process(cmd, cwd).!! + val output = sys.process.Process(cmd, cwd).!! assert(output contains "SUCCESS!", "Output didn't contain success: " + output) } diff --git a/src/sbt-test/ash/simple-app/test b/src/sbt-test/ash/simple-app/test index 877989c06..61dad9b64 100644 --- a/src/sbt-test/ash/simple-app/test +++ b/src/sbt-test/ash/simple-app/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check \ No newline at end of file +> runCheck \ No newline at end of file diff --git a/src/sbt-test/bash/absolute-path-in-bash/build.sbt b/src/sbt-test/bash/absolute-path-in-bash/build.sbt index e18051fb8..14889eb81 100644 --- a/src/sbt-test/bash/absolute-path-in-bash/build.sbt +++ b/src/sbt-test/bash/absolute-path-in-bash/build.sbt @@ -6,7 +6,7 @@ version := "0.1.0" scriptClasspath in bashScriptDefines ++= Seq("/dummy/absolute/path", "relative/path") -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val dir = (stagingDirectory in Universal).value val bash = IO.read(dir / "bin" / "absolute-path-in-bash") diff --git a/src/sbt-test/bash/absolute-path-in-bash/test b/src/sbt-test/bash/absolute-path-in-bash/test index 877989c06..61dad9b64 100644 --- a/src/sbt-test/bash/absolute-path-in-bash/test +++ b/src/sbt-test/bash/absolute-path-in-bash/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check \ No newline at end of file +> runCheck \ No newline at end of file diff --git a/src/sbt-test/bash/java-home-var-expansion/build.sbt b/src/sbt-test/bash/java-home-var-expansion/build.sbt index df397d08e..a4e6e7c5e 100644 --- a/src/sbt-test/bash/java-home-var-expansion/build.sbt +++ b/src/sbt-test/bash/java-home-var-expansion/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "java-home-override" @@ -6,11 +8,11 @@ version := "0.1.0" javaOptions in Universal ++= Seq("-java-home ${app_home}/../jre") -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val cwd = (stagingDirectory in Universal).value // Don't check for java but it will fail since the jre is not in place val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath, "-v", "-no-version-check") - val output = Process(cmd, cwd).lines_! + val output = sys.process.Process(cmd, cwd).lines_! val outStr = output.mkString("\n") // Check that ${app_home} has been substitued assert(outStr.contains("stage/bin/../jre/bin/java"), "Output didn't contain success: " + output) diff --git a/src/sbt-test/bash/java-home-var-expansion/test b/src/sbt-test/bash/java-home-var-expansion/test index 877989c06..61dad9b64 100644 --- a/src/sbt-test/bash/java-home-var-expansion/test +++ b/src/sbt-test/bash/java-home-var-expansion/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check \ No newline at end of file +> runCheck \ No newline at end of file diff --git a/src/sbt-test/bash/memory-settings/build.sbt b/src/sbt-test/bash/memory-settings/build.sbt index 7970d16b7..4006beaec 100644 --- a/src/sbt-test/bash/memory-settings/build.sbt +++ b/src/sbt-test/bash/memory-settings/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "simple-app" @@ -6,16 +8,16 @@ version := "0.1.0" javaOptions in Universal ++= Seq("-J-Xmx64m", "-J-Xms64m") -TaskKey[Unit]("jvmopts-check") := { +TaskKey[Unit]("jvmoptsCheck") := { val jvmopts = (stagingDirectory in Universal).value / "conf" / "application.ini" val options = IO.read(jvmopts) assert(options contains "-J-Xmx64m", "Options don't contain xmx setting:\n" + options) assert(options contains "-J-Xms64m", "Options don't contain xms setting:\n" + options) } -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val cwd = (stagingDirectory in Universal).value val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath) - val memory = (Process(cmd, cwd).!!).replaceAll("\n", "") + val memory = (sys.process.Process(cmd, cwd).!!).replaceAll("\n", "") assert(memory.toLong <= 64, "Runtime memory is bigger then 64m < " + memory + "m") } diff --git a/src/sbt-test/bash/memory-settings/test b/src/sbt-test/bash/memory-settings/test index a2fad512b..c50f2af5e 100644 --- a/src/sbt-test/bash/memory-settings/test +++ b/src/sbt-test/bash/memory-settings/test @@ -1,5 +1,5 @@ # Run the staging and check the script. > stage $ exists target/universal/stage/conf/application.ini -> jvmopts-check -> run-check \ No newline at end of file +> jvmoptsCheck +> runCheck \ No newline at end of file diff --git a/src/sbt-test/bash/multiple-apps/build.sbt b/src/sbt-test/bash/multiple-apps/build.sbt index 29b378a26..82bd84544 100644 --- a/src/sbt-test/bash/multiple-apps/build.sbt +++ b/src/sbt-test/bash/multiple-apps/build.sbt @@ -1,32 +1,34 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "test-project" version := "0.1.0" -TaskKey[Unit]("check-no-explicit-main") := { +TaskKey[Unit]("checkNoExplicitMain") := { val cwd = (stagingDirectory in Universal).value // check MainApp val cmd = Seq((cwd / "bin" / "main-app").getAbsolutePath) - val output = Process(cmd, cwd).!!.replaceAll("\n", "") + val output = sys.process.Process(cmd, cwd).!!.replaceAll("\n", "") assert(output == "MainApp", s"Output wasn't 'MainApp', but '$output'") // check SecondApp val cmdSecond = Seq((cwd / "bin" / "second-app").getAbsolutePath) - val outputSecond = Process(cmdSecond, cwd).!!.replaceAll("\n", "") + val outputSecond = sys.process.Process(cmdSecond, cwd).!!.replaceAll("\n", "") assert(outputSecond == "SecondApp", s"Output wasn't 'SecondApp': '$outputSecond'") } -TaskKey[Unit]("check-explicit-main") := { +TaskKey[Unit]("checkExplicitMain") := { val cwd = (stagingDirectory in Universal).value // check default start script val cmd = Seq((cwd / "bin" / executableScriptName.value).getAbsolutePath) - val output = Process(cmd, cwd).!!.replaceAll("\n", "") + val output = sys.process.Process(cmd, cwd).!!.replaceAll("\n", "") assert(output == "MainApp", s"Output wasn't 'MainApp', but '$output'") // check SecondApp val cmdSecond = Seq((cwd / "bin" / "second-app").getAbsolutePath) - val outputSecond = Process(cmdSecond, cwd).!!.replaceAll("\n", "") + val outputSecond = sys.process.Process(cmdSecond, cwd).!!.replaceAll("\n", "") assert(outputSecond == "SecondApp", s"Output wasn't 'SecondApp', but '$outputSecond'") } diff --git a/src/sbt-test/bash/multiple-apps/test b/src/sbt-test/bash/multiple-apps/test index 8da612206..ad1a3b65f 100644 --- a/src/sbt-test/bash/multiple-apps/test +++ b/src/sbt-test/bash/multiple-apps/test @@ -2,10 +2,10 @@ > stage $ exists target/universal/stage/bin/main-app $ exists target/universal/stage/bin/second-app -> check-no-explicit-main +> checkNoExplicitMain > clean > set mainClass in Compile := Some("com.example.MainApp") > stage $ exists target/universal/stage/bin/test-project $ exists target/universal/stage/bin/second-app -> check-explicit-main \ No newline at end of file +> checkExplicitMain \ No newline at end of file diff --git a/src/sbt-test/bash/override-templates/build.sbt b/src/sbt-test/bash/override-templates/build.sbt index c39b09d2a..ad357cbe2 100644 --- a/src/sbt-test/bash/override-templates/build.sbt +++ b/src/sbt-test/bash/override-templates/build.sbt @@ -10,7 +10,7 @@ bashScriptTemplateLocation := baseDirectory.value / "custom-templates" / "custom batScriptTemplateLocation := baseDirectory.value / "custom-templates" / "custom-bat-template" -TaskKey[Unit]("run-check-bash") := { +TaskKey[Unit]("runCheckBash") := { val cwd = (stagingDirectory in Universal).value val source = scala.io.Source.fromFile((cwd / "bin" / packageName.value).getAbsolutePath) @@ -22,7 +22,7 @@ TaskKey[Unit]("run-check-bash") := { ) } -TaskKey[Unit]("run-check-bat") := { +TaskKey[Unit]("runCheckBat") := { val cwd = (stagingDirectory in Universal).value val batFilename = packageName.value + ".bat" val source = diff --git a/src/sbt-test/bash/override-templates/test b/src/sbt-test/bash/override-templates/test index cdb9e6f43..b6c59d91d 100644 --- a/src/sbt-test/bash/override-templates/test +++ b/src/sbt-test/bash/override-templates/test @@ -1,4 +1,4 @@ # Run the staging and check the script. > stage -> run-check-bash -> run-check-bat \ No newline at end of file +> runCheckBash +> runCheckBat \ No newline at end of file diff --git a/src/sbt-test/bash/simple-app/build.sbt b/src/sbt-test/bash/simple-app/build.sbt index aa27edf06..ed77e00c9 100644 --- a/src/sbt-test/bash/simple-app/build.sbt +++ b/src/sbt-test/bash/simple-app/build.sbt @@ -1,12 +1,14 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "simple-app" version := "0.1.0" -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val cwd = (stagingDirectory in Universal).value val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath) - val output = Process(cmd, cwd).!! + val output = sys.process.Process(cmd, cwd).!! assert(output contains "SUCCESS!", "Output didn't contain success: " + output) } diff --git a/src/sbt-test/bash/simple-app/test b/src/sbt-test/bash/simple-app/test index 877989c06..61dad9b64 100644 --- a/src/sbt-test/bash/simple-app/test +++ b/src/sbt-test/bash/simple-app/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check \ No newline at end of file +> runCheck \ No newline at end of file diff --git a/src/sbt-test/cygwin/java-app-archetype/build.sbt b/src/sbt-test/cygwin/java-app-archetype/build.sbt index 53cd7e6e6..9a62f1cd9 100644 --- a/src/sbt-test/cygwin/java-app-archetype/build.sbt +++ b/src/sbt-test/cygwin/java-app-archetype/build.sbt @@ -1,10 +1,12 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging) name := "windows-test" version := "0.1.0" -TaskKey[Unit]("check-cygwin-script") := { +TaskKey[Unit]("checkCygwinScript") := { val dir = (stagingDirectory in Universal).value // TODO - FIx our cygwin detection! val cygwinBash = file("C:\\cygwin\\bin\\bash.exe") @@ -18,12 +20,12 @@ TaskKey[Unit]("check-cygwin-script") := { val pathEnv = "C:\\cygwin\\bin" val cmd = Seq(cygwinBash.getAbsolutePath, cygdriveScriptPath, "-d") val result = - Process(cmd, Some(dir), "PATH" -> pathEnv) ! streams.value.log match { + sys.process.Process(cmd, Some(dir), "PATH" -> pathEnv) ! streams.value.log match { case 0 => () case n => sys.error("Failed to run script: " + cygdriveScriptPath + " error code: " + n) } - val output = Process(cmd, Some(dir), "PATH" -> pathEnv).!! + val output = sys.process.Process(cmd, Some(dir), "PATH" -> pathEnv).!! val expected = "SUCCESS!" assert( output contains expected, diff --git a/src/sbt-test/cygwin/java-app-archetype/test b/src/sbt-test/cygwin/java-app-archetype/test index eaa29c548..55ca8cd07 100644 --- a/src/sbt-test/cygwin/java-app-archetype/test +++ b/src/sbt-test/cygwin/java-app-archetype/test @@ -1,4 +1,4 @@ # Run the staging and check the script. > stage $ exists target/universal/stage/bin/windows-test -> check-cygwin-script +> checkCygwinScript diff --git a/src/sbt-test/debian/daemon-group-gid-deb/build.sbt b/src/sbt-test/debian/daemon-group-gid-deb/build.sbt index f512f9c27..625843d1c 100644 --- a/src/sbt-test/debian/daemon-group-gid-deb/build.sbt +++ b/src/sbt-test/debian/daemon-group-gid-deb/build.sbt @@ -14,7 +14,7 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") val postrm = IO.read(debian / "postrm") diff --git a/src/sbt-test/debian/daemon-group-gid-deb/test b/src/sbt-test/debian/daemon-group-gid-deb/test index 967f7a260..73243d7f0 100644 --- a/src/sbt-test/debian/daemon-group-gid-deb/test +++ b/src/sbt-test/debian/daemon-group-gid-deb/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc @@ -9,4 +9,4 @@ $ exists target/debian-test-0.1.0/DEBIAN/prerm $ exists target/debian-test-0.1.0/DEBIAN/postinst # Check files for defaults -> check-control-files +> checkControlFiles diff --git a/src/sbt-test/debian/daemon-user-deb/build.sbt b/src/sbt-test/debian/daemon-user-deb/build.sbt index ecbd67f7e..01b6e19a8 100644 --- a/src/sbt-test/debian/daemon-user-deb/build.sbt +++ b/src/sbt-test/debian/daemon-user-deb/build.sbt @@ -13,7 +13,7 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") val postrm = IO.read(debian / "postrm") diff --git a/src/sbt-test/debian/daemon-user-deb/test b/src/sbt-test/debian/daemon-user-deb/test index b59d4d6be..003fb4e70 100644 --- a/src/sbt-test/debian/daemon-user-deb/test +++ b/src/sbt-test/debian/daemon-user-deb/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb # Check defaults @@ -7,4 +7,4 @@ $ exists target/debian-test-0.1.0/DEBIAN/prerm $ exists target/debian-test-0.1.0/DEBIAN/postinst # Check files for defaults -> check-control-files +> checkControlFiles diff --git a/src/sbt-test/debian/daemon-user-shell-deb/build.sbt b/src/sbt-test/debian/daemon-user-shell-deb/build.sbt index cbd02e9be..e6c1c139f 100644 --- a/src/sbt-test/debian/daemon-user-shell-deb/build.sbt +++ b/src/sbt-test/debian/daemon-user-shell-deb/build.sbt @@ -14,7 +14,7 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") val postrm = IO.read(debian / "postrm") diff --git a/src/sbt-test/debian/daemon-user-shell-deb/test b/src/sbt-test/debian/daemon-user-shell-deb/test index b59d4d6be..003fb4e70 100644 --- a/src/sbt-test/debian/daemon-user-shell-deb/test +++ b/src/sbt-test/debian/daemon-user-shell-deb/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb # Check defaults @@ -7,4 +7,4 @@ $ exists target/debian-test-0.1.0/DEBIAN/prerm $ exists target/debian-test-0.1.0/DEBIAN/postinst # Check files for defaults -> check-control-files +> checkControlFiles diff --git a/src/sbt-test/debian/daemon-user-uid-deb/build.sbt b/src/sbt-test/debian/daemon-user-uid-deb/build.sbt index b7462ec46..f582f1668 100644 --- a/src/sbt-test/debian/daemon-user-uid-deb/build.sbt +++ b/src/sbt-test/debian/daemon-user-uid-deb/build.sbt @@ -14,7 +14,7 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") val postrm = IO.read(debian / "postrm") diff --git a/src/sbt-test/debian/daemon-user-uid-deb/test b/src/sbt-test/debian/daemon-user-uid-deb/test index 2aaab684c..7202c351f 100644 --- a/src/sbt-test/debian/daemon-user-uid-deb/test +++ b/src/sbt-test/debian/daemon-user-uid-deb/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc @@ -9,4 +9,4 @@ $ exists target/debian-test-0.1.0/DEBIAN/prerm $ exists target/debian-test-0.1.0/DEBIAN/postinst # Check files for defaults -> check-control-files +> checkControlFiles diff --git a/src/sbt-test/debian/file-permissions/test b/src/sbt-test/debian/file-permissions/test index 5a0cd1e63..75cf6de15 100644 --- a/src/sbt-test/debian/file-permissions/test +++ b/src/sbt-test/debian/file-permissions/test @@ -1,3 +1,3 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb diff --git a/src/sbt-test/debian/gen-changes/test b/src/sbt-test/debian/gen-changes/test index 52747abec..8f0203842 100644 --- a/src/sbt-test/debian/gen-changes/test +++ b/src/sbt-test/debian/gen-changes/test @@ -1,4 +1,4 @@ # Run the debian packaging. -> debian:gen-changes +> debian:genChanges $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test_0.1.0_all.changes \ No newline at end of file diff --git a/src/sbt-test/debian/java-app-archetype/build.sbt b/src/sbt-test/debian/java-app-archetype/build.sbt index e3fbb961a..c523ece07 100644 --- a/src/sbt-test/debian/java-app-archetype/build.sbt +++ b/src/sbt-test/debian/java-app-archetype/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "debian-test" @@ -15,7 +17,7 @@ debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11) debianPackageRecommends in Debian += "git" -TaskKey[Unit]("check-script") := { +TaskKey[Unit]("checkScript") := { val dir = (stagingDirectory in Universal).value val script = dir / "bin" / name.value System.out.synchronized { @@ -23,24 +25,24 @@ TaskKey[Unit]("check-script") := { val scriptContents = IO.read(script) System.err.println(scriptContents) System.err.println("---END SCRIPT---") - for (file <- (dir.***).get) + for (file <- dir.**(AllPassFilter).get) System.err.println("\t" + file) } val cmd = "bash " + script.getAbsolutePath + " -d" val result = - Process(cmd) ! streams.value.log match { + sys.process.Process(cmd) ! streams.value.log match { case 0 => () case n => sys.error("Failed to run script: " + script.getAbsolutePath + " error code: " + n) } - val output = Process("bash " + script.getAbsolutePath).!! + val output = sys.process.Process("bash " + script.getAbsolutePath).!! val expected = "SUCCESS!" assert( output contains expected, "Failed to correctly run the main script!. Found [" + output + "] wanted [" + expected + "]" ) val expected2 = "Something with spaces" - val output2 = Process(Seq("bash", script.getAbsolutePath, "-Dresult.string=" + expected2)).!! + val output2 = sys.process.Process(Seq("bash", script.getAbsolutePath, "-Dresult.string=" + expected2)).!! assert( output2 contains expected2, "Failed to correctly run the main script with spaced java args!. Found [" + output2 + "] wanted [" + expected2 + "]" diff --git a/src/sbt-test/debian/java-app-archetype/src/main/scala/test/Test.scala b/src/sbt-test/debian/java-app-archetype/src/main/scala/test/Test.scala index b65353426..e7948961b 100644 --- a/src/sbt-test/debian/java-app-archetype/src/main/scala/test/Test.scala +++ b/src/sbt-test/debian/java-app-archetype/src/main/scala/test/Test.scala @@ -2,8 +2,8 @@ package test object Test extends App { Option(sys.props("result.string")) match { - case Some(value) => println(value) - case _ => println("SUCCESS!") + case Some(value) => println(value) + case _ => println("SUCCESS!") } - + } diff --git a/src/sbt-test/debian/java-app-archetype/test b/src/sbt-test/debian/java-app-archetype/test index f07dc43ce..b25902514 100644 --- a/src/sbt-test/debian/java-app-archetype/test +++ b/src/sbt-test/debian/java-app-archetype/test @@ -1,6 +1,6 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb > stage $ exists target/universal/stage/bin/debian-test -> check-script +> checkScript diff --git a/src/sbt-test/debian/jdeb-conflicts/build.sbt b/src/sbt-test/debian/jdeb-conflicts/build.sbt index 004dd944e..6b38fc1f6 100644 --- a/src/sbt-test/debian/jdeb-conflicts/build.sbt +++ b/src/sbt-test/debian/jdeb-conflicts/build.sbt @@ -13,9 +13,11 @@ packageDescription := """A fun package description of our software, debianPackageConflicts in Debian := Seq("debian-test-package") -TaskKey[Unit]("check-conflicts") := { +TaskKey[Unit]("checkConflicts") := { val extracted = target.value / "extracted" - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val control = IO.read(extracted / "DEBIAN" / "control") assert(control.contains("Conflicts:")) diff --git a/src/sbt-test/debian/jdeb-conflicts/test b/src/sbt-test/debian/jdeb-conflicts/test index 30995efd1..818f071f1 100644 --- a/src/sbt-test/debian/jdeb-conflicts/test +++ b/src/sbt-test/debian/jdeb-conflicts/test @@ -1,5 +1,5 @@ # Run the debian packaging. $ mkdir src/resources/empty -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb -> check-conflicts +> checkConflicts diff --git a/src/sbt-test/debian/jdeb-dependencies/build.sbt b/src/sbt-test/debian/jdeb-dependencies/build.sbt index 3e596ce12..70f4bbaaf 100644 --- a/src/sbt-test/debian/jdeb-dependencies/build.sbt +++ b/src/sbt-test/debian/jdeb-dependencies/build.sbt @@ -13,9 +13,11 @@ packageDescription := """A fun package description of our software, debianPackageDependencies in Debian := Seq() -TaskKey[Unit]("check-dependencies") := { +TaskKey[Unit]("checkDependencies") := { val extracted = target.value / "extracted" - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val control = IO.read(extracted / "DEBIAN" / "control") assert(!control.contains("Depends:")) diff --git a/src/sbt-test/debian/jdeb-dependencies/test b/src/sbt-test/debian/jdeb-dependencies/test index f3a2c1704..294a72b2b 100644 --- a/src/sbt-test/debian/jdeb-dependencies/test +++ b/src/sbt-test/debian/jdeb-dependencies/test @@ -1,5 +1,5 @@ # Run the debian packaging. $ mkdir src/resources/empty -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb -> check-dependencies +> checkDependencies diff --git a/src/sbt-test/debian/jdeb-dir-mappings/build.sbt b/src/sbt-test/debian/jdeb-dir-mappings/build.sbt index cd41a8c86..4b6ab058e 100644 --- a/src/sbt-test/debian/jdeb-dir-mappings/build.sbt +++ b/src/sbt-test/debian/jdeb-dir-mappings/build.sbt @@ -23,10 +23,12 @@ linuxPackageMappings in Debian += packageDirectoryAndContentsMapping( (baseDirectory.value / "src" / "resources" / "empty") -> "/var/empty" ) -TaskKey[Unit]("check-dir-mappings") := { +TaskKey[Unit]("checkDirMappings") := { // val tmpDir = java.nio.file.Files.createTempDirectory("jdeb") val extracted = file("/tmp/jdeb" + System.currentTimeMillis().toString) - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! assert((extracted / "usr/share/conf/application.conf").exists(), "File application.conf not exists") assert((extracted / "usr/share/conf/log4j.properties").exists(), "File log4j.properties not exists") assert((extracted / "var/empty").exists(), "Empty dir not exists") diff --git a/src/sbt-test/debian/jdeb-dir-mappings/test b/src/sbt-test/debian/jdeb-dir-mappings/test index eaac4b35b..acb8becd4 100644 --- a/src/sbt-test/debian/jdeb-dir-mappings/test +++ b/src/sbt-test/debian/jdeb-dir-mappings/test @@ -1,5 +1,5 @@ # Run the debian packaging. $ mkdir src/resources/empty -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb -> check-dir-mappings +> checkDirMappings diff --git a/src/sbt-test/debian/jdeb-provides/build.sbt b/src/sbt-test/debian/jdeb-provides/build.sbt index 376bcb205..13779921e 100644 --- a/src/sbt-test/debian/jdeb-provides/build.sbt +++ b/src/sbt-test/debian/jdeb-provides/build.sbt @@ -13,9 +13,11 @@ packageDescription := """A fun package description of our software, debianPackageProvides in Debian := Seq("debian-test-package") -TaskKey[Unit]("check-provides") := { +TaskKey[Unit]("checkProvides") := { val extracted = target.value / "extracted" - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val control = IO.read(extracted / "DEBIAN" / "control") assert(control.contains("Provides:")) diff --git a/src/sbt-test/debian/jdeb-provides/test b/src/sbt-test/debian/jdeb-provides/test index 5ccc924e2..50fd554cd 100644 --- a/src/sbt-test/debian/jdeb-provides/test +++ b/src/sbt-test/debian/jdeb-provides/test @@ -1,5 +1,5 @@ # Run the debian packaging. $ mkdir src/resources/empty -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb -> check-provides +> checkProvides diff --git a/src/sbt-test/debian/jdeb-script-replacements/build.sbt b/src/sbt-test/debian/jdeb-script-replacements/build.sbt index 2f94cd211..9460ad734 100644 --- a/src/sbt-test/debian/jdeb-script-replacements/build.sbt +++ b/src/sbt-test/debian/jdeb-script-replacements/build.sbt @@ -15,11 +15,13 @@ debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11) debianPackageRecommends in Debian += "git" -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val header = "#!/bin/sh" val extracted = target.value / "extracted" println(extracted.getAbsolutePath) - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val preinst = extracted / "DEBIAN/preinst" val postinst = extracted / "DEBIAN/postinst" val prerm = extracted / "DEBIAN/prerm" diff --git a/src/sbt-test/debian/jdeb-script-replacements/test b/src/sbt-test/debian/jdeb-script-replacements/test index a695d78a7..d8f8cdefb 100644 --- a/src/sbt-test/debian/jdeb-script-replacements/test +++ b/src/sbt-test/debian/jdeb-script-replacements/test @@ -1,5 +1,5 @@ # Run the debian packaging. $ mkdir src/resources/empty -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb -> check-control-files +> checkControlFiles diff --git a/src/sbt-test/debian/log-directory/build.sbt b/src/sbt-test/debian/log-directory/build.sbt index e0270d33c..580f330cc 100644 --- a/src/sbt-test/debian/log-directory/build.sbt +++ b/src/sbt-test/debian/log-directory/build.sbt @@ -17,13 +17,13 @@ packageDescription := """A fun package description of our software, defaultLinuxLogsLocation := "/non-standard/log" -InputKey[Unit]("check-softlink") := { +InputKey[Unit]("checkSoftlink") := { import complete.DefaultParsers._ val args = spaceDelimited("").parsed assert(args.size >= 2, "Usage: check-softlink link to target") val link = args(0) val target = args(args.size - 1) - val absolutePath = ("readlink -m " + link).!!.trim + val absolutePath = sys.process.Process("readlink -m " + link).!!.trim assert(link != absolutePath, "Expected symbolic link '" + link + "' does not exist") assert( target == absolutePath, diff --git a/src/sbt-test/debian/log-directory/test b/src/sbt-test/debian/log-directory/test index 8fc5d14f9..22bd113b5 100644 --- a/src/sbt-test/debian/log-directory/test +++ b/src/sbt-test/debian/log-directory/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb # Check defaults @@ -8,4 +8,4 @@ $ exists target/debian-test-0.1.0/DEBIAN/postinst # Check that the non-standard log directory was used $ exists target/debian-test-0.1.0/non-standard/log/debian-test -> check-softlink target/debian-test-0.1.0/usr/share/debian-test/logs points to /non-standard/log/debian-test +> checkSoftlink target/debian-test-0.1.0/usr/share/debian-test/logs points to /non-standard/log/debian-test diff --git a/src/sbt-test/debian/native-build-compress/build.sbt b/src/sbt-test/debian/native-build-compress/build.sbt index 0a13bb09e..6653a9d01 100644 --- a/src/sbt-test/debian/native-build-compress/build.sbt +++ b/src/sbt-test/debian/native-build-compress/build.sbt @@ -8,7 +8,8 @@ packageDescription := "Description" packageSummary := "Summary" -TaskKey[Unit]("check-deb-compression") := { +TaskKey[Unit]("checkDebCompression") := { val deb = target.value / s"${(name in Debian).value}_${(version in Debian).value}_all.deb" - assert(Seq("ar", "-t", deb.toString).lines.exists(_.startsWith("data.tar."))) // exact extension varies by dpkg-deb version + val output = sys.process.Process(Seq("ar", "-t", deb.toString)).lines + assert(output.exists(_.startsWith("data.tar."))) // exact extension varies by dpkg-deb version } diff --git a/src/sbt-test/debian/native-build-compress/test b/src/sbt-test/debian/native-build-compress/test index 7e578bfb4..17578066c 100644 --- a/src/sbt-test/debian/native-build-compress/test +++ b/src/sbt-test/debian/native-build-compress/test @@ -1,2 +1,2 @@ > debian:packageBin -> check-deb-compression +> checkDebCompression diff --git a/src/sbt-test/debian/native-build-default/build.sbt b/src/sbt-test/debian/native-build-default/build.sbt index 2edafe946..c7eba3928 100644 --- a/src/sbt-test/debian/native-build-default/build.sbt +++ b/src/sbt-test/debian/native-build-default/build.sbt @@ -6,7 +6,8 @@ packageDescription := "Description" packageSummary := "Summary" -TaskKey[Unit]("check-deb-compression") := { +TaskKey[Unit]("checkDebCompression") := { val deb = target.value / s"${(name in Debian).value}_${(version in Debian).value}_all.deb" - assert(Seq("ar", "-t", deb.toString).lines.contains("data.tar")) + val output = sys.process.Process(Seq("ar", "-t", deb.toString)).lines + assert(output.contains("data.tar")) } diff --git a/src/sbt-test/debian/native-build-default/test b/src/sbt-test/debian/native-build-default/test index 7e578bfb4..17578066c 100644 --- a/src/sbt-test/debian/native-build-default/test +++ b/src/sbt-test/debian/native-build-default/test @@ -1,2 +1,2 @@ > debian:packageBin -> check-deb-compression +> checkDebCompression diff --git a/src/sbt-test/debian/override-control-files/build.sbt b/src/sbt-test/debian/override-control-files/build.sbt index a943ee690..e4f78a2cc 100644 --- a/src/sbt-test/debian/override-control-files/build.sbt +++ b/src/sbt-test/debian/override-control-files/build.sbt @@ -24,7 +24,7 @@ maintainerScripts in Debian := maintainerScriptsFromDirectory( Seq(Preinst, Postinst, Prerm, Postrm) ) -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") val preinst = IO.read(debian / "preinst") diff --git a/src/sbt-test/debian/override-control-files/test b/src/sbt-test/debian/override-control-files/test index 0898e7661..4d45545c2 100644 --- a/src/sbt-test/debian/override-control-files/test +++ b/src/sbt-test/debian/override-control-files/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc @@ -13,4 +13,4 @@ $ exists target/debian-test-0.1.0/DEBIAN/postrm $ exists target/debian-test-0.1.0/DEBIAN/prerm # Check files for defaults -> check-control-files +> checkControlFiles diff --git a/src/sbt-test/debian/override-etc-default/build.sbt b/src/sbt-test/debian/override-etc-default/build.sbt index 5053e8d6b..d540b7d63 100644 --- a/src/sbt-test/debian/override-etc-default/build.sbt +++ b/src/sbt-test/debian/override-etc-default/build.sbt @@ -20,10 +20,12 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-etc-default") := { +TaskKey[Unit]("checkEtcDefault") := { val extracted = target.value / "tmp" / "extracted-package" extracted.mkdirs() - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val script = IO.read(extracted / "etc" / "default" / "debian-test") assert( diff --git a/src/sbt-test/debian/override-etc-default/test b/src/sbt-test/debian/override-etc-default/test index 8c5ab3e2c..e89ad9347 100644 --- a/src/sbt-test/debian/override-etc-default/test +++ b/src/sbt-test/debian/override-etc-default/test @@ -3,4 +3,4 @@ $ exists target/debian-test_0.1.0_all.deb # Check files for defaults -> check-etc-default +> checkEtcDefault diff --git a/src/sbt-test/debian/override-loader-functions/build.sbt b/src/sbt-test/debian/override-loader-functions/build.sbt index 51b804d05..6f616c8e9 100644 --- a/src/sbt-test/debian/override-loader-functions/build.sbt +++ b/src/sbt-test/debian/override-loader-functions/build.sbt @@ -14,10 +14,12 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-loader-functions") := { +TaskKey[Unit]("checkLoaderFunctions") := { val extracted = target.value / "tmp" / "extracted-package" extracted.mkdirs() - Seq("dpkg-deb", "-e", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-e", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val script = IO.read(extracted / "postinst") diff --git a/src/sbt-test/debian/override-loader-functions/test b/src/sbt-test/debian/override-loader-functions/test index e6a069cdc..43882b1e9 100644 --- a/src/sbt-test/debian/override-loader-functions/test +++ b/src/sbt-test/debian/override-loader-functions/test @@ -3,4 +3,4 @@ $ exists target/debian-test_0.1.0_all.deb # Check files for defaults -> check-loader-functions +> checkLoaderFunctions diff --git a/src/sbt-test/debian/override-start-script-systemd/build.sbt b/src/sbt-test/debian/override-start-script-systemd/build.sbt index af8065a0a..ed0a18ebe 100644 --- a/src/sbt-test/debian/override-start-script-systemd/build.sbt +++ b/src/sbt-test/debian/override-start-script-systemd/build.sbt @@ -14,10 +14,12 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val extracted = target.value / "tmp" / "extracted-package" extracted.mkdirs() - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val script = IO.read(extracted / "lib" / "systemd" / "system" / "debian-test.service") assert(script.startsWith("# right systemd template"), s"override script wasn't picked, script is\n$script") diff --git a/src/sbt-test/debian/override-start-script-systemd/test b/src/sbt-test/debian/override-start-script-systemd/test index baf9b1d9d..176396738 100644 --- a/src/sbt-test/debian/override-start-script-systemd/test +++ b/src/sbt-test/debian/override-start-script-systemd/test @@ -3,4 +3,4 @@ $ exists target/debian-test_0.1.0_all.deb # Check files for defaults -> check-startup-script +> checkStartupScript diff --git a/src/sbt-test/debian/override-start-script-systemv/build.sbt b/src/sbt-test/debian/override-start-script-systemv/build.sbt index 67de20462..f4c37ebde 100644 --- a/src/sbt-test/debian/override-start-script-systemv/build.sbt +++ b/src/sbt-test/debian/override-start-script-systemv/build.sbt @@ -14,10 +14,12 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val extracted = target.value / "tmp" / "extracted-package" extracted.mkdirs() - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val script = IO.read(extracted / "etc" / "init.d" / "debian-test") assert(script.startsWith("# right systemv template"), s"override script wasn't picked, script is\n$script") diff --git a/src/sbt-test/debian/override-start-script-systemv/test b/src/sbt-test/debian/override-start-script-systemv/test index baf9b1d9d..176396738 100644 --- a/src/sbt-test/debian/override-start-script-systemv/test +++ b/src/sbt-test/debian/override-start-script-systemv/test @@ -3,4 +3,4 @@ $ exists target/debian-test_0.1.0_all.deb # Check files for defaults -> check-startup-script +> checkStartupScript diff --git a/src/sbt-test/debian/override-start-script-upstart/build.sbt b/src/sbt-test/debian/override-start-script-upstart/build.sbt index 27fc1a50b..39d41c09a 100644 --- a/src/sbt-test/debian/override-start-script-upstart/build.sbt +++ b/src/sbt-test/debian/override-start-script-upstart/build.sbt @@ -14,10 +14,12 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val extracted = target.value / "tmp" / "extracted-package" extracted.mkdirs() - Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).! + sys.process + .Process(Seq("dpkg-deb", "-R", (target.value / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath)) + .! val script = IO.read(extracted / "etc" / "init" / "debian-test.conf") assert(script.startsWith("# right upstart template"), s"override script wasn't picked, script is\n$script") diff --git a/src/sbt-test/debian/override-start-script-upstart/test b/src/sbt-test/debian/override-start-script-upstart/test index baf9b1d9d..176396738 100644 --- a/src/sbt-test/debian/override-start-script-upstart/test +++ b/src/sbt-test/debian/override-start-script-upstart/test @@ -3,4 +3,4 @@ $ exists target/debian-test_0.1.0_all.deb # Check files for defaults -> check-startup-script +> checkStartupScript diff --git a/src/sbt-test/debian/simple-deb/test b/src/sbt-test/debian/simple-deb/test index 5a0cd1e63..75cf6de15 100644 --- a/src/sbt-test/debian/simple-deb/test +++ b/src/sbt-test/debian/simple-deb/test @@ -1,3 +1,3 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb diff --git a/src/sbt-test/debian/simple-jdeb/test b/src/sbt-test/debian/simple-jdeb/test index 5a0cd1e63..75cf6de15 100644 --- a/src/sbt-test/debian/simple-jdeb/test +++ b/src/sbt-test/debian/simple-jdeb/test @@ -1,3 +1,3 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb diff --git a/src/sbt-test/debian/systemd-deb/build.sbt b/src/sbt-test/debian/systemd-deb/build.sbt index 5c658d631..5265bb8b4 100644 --- a/src/sbt-test/debian/systemd-deb/build.sbt +++ b/src/sbt-test/debian/systemd-deb/build.sbt @@ -14,7 +14,7 @@ daemonUser in Linux := "testuser" systemdSuccessExitStatus in Debian += "1" -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val script = IO.read(target.value / "debian-test-0.1.0" / "lib" / "systemd" / "system" / "debian-test.service") assert(script.contains("Requires=network.target"), "script doesn't contain Default-Start header\n" + script) assert(script.contains("User=testuser"), "script doesn't contain `User` header\n" + script) @@ -27,14 +27,14 @@ TaskKey[Unit]("check-startup-script") := { () } -TaskKey[Unit]("check-etc-default") := { +TaskKey[Unit]("checkEtcDefault") := { val script = IO.read(target.value / "debian-test-0.1.0" / "etc" / "default" / "debian-test") assert(script.contains("systemd"), s"systemd etc-default template wasn't selected; contents are:\n" + script) () } -TaskKey[Unit]("check-autostart") := { +TaskKey[Unit]("checkAutostart") := { val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst") assert(script.contains("""addService debian-test || echo "debian-test could not be registered" |startService debian-test || echo "debian-test could not be started" @@ -42,7 +42,7 @@ TaskKey[Unit]("check-autostart") := { () } -TaskKey[Unit]("check-no-autostart") := { +TaskKey[Unit]("checkNoAutostart") := { val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst") assert(script.contains("""addService debian-test || echo "debian-test could not be registered" |""".stripMargin), "addService post install commands missing or incorrect") diff --git a/src/sbt-test/debian/systemd-deb/test b/src/sbt-test/debian/systemd-deb/test index 2b712f916..d60eb5712 100644 --- a/src/sbt-test/debian/systemd-deb/test +++ b/src/sbt-test/debian/systemd-deb/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/lib/systemd/system/debian-test.service @@ -7,13 +7,13 @@ $ exists target/debian-test-0.1.0/lib/systemd/system/debian-test.service > show debian:linuxStartScriptTemplate > plugins -> check-startup-script -> check-etc-default -> check-autostart +> checkStartupScript +> checkEtcDefault +> checkAutostart # Test that serviceAutostart can be disabled > set every NativePackagerKeys.serviceAutostart := false -> debian:package-bin -> check-no-autostart \ No newline at end of file +> debian:packageBin +> checkNoAutostart \ No newline at end of file diff --git a/src/sbt-test/debian/sysvinit-deb/build.sbt b/src/sbt-test/debian/sysvinit-deb/build.sbt index a97d4fd4b..8a62db3e0 100644 --- a/src/sbt-test/debian/sysvinit-deb/build.sbt +++ b/src/sbt-test/debian/sysvinit-deb/build.sbt @@ -21,7 +21,7 @@ requiredStartFacilities in Debian := Some("$test-deb-service") daemonStdoutLogFile := Some("test.log") -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val header = "#!/bin/sh" val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") @@ -34,7 +34,7 @@ TaskKey[Unit]("check-control-files") := { () } -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val script = IO.read(target.value / "debian-test-0.1.0" / "etc" / "init.d" / "debian-test") assert(script.contains("# Default-Start: 2 3 4 5"), "script doesn't contain Default-Start header\n" + script) @@ -59,7 +59,7 @@ TaskKey[Unit]("check-startup-script") := { () } -TaskKey[Unit]("check-autostart") := { +TaskKey[Unit]("checkAutostart") := { val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst") assert(script.contains("""addService debian-test || echo "debian-test could not be registered" |startService debian-test || echo "debian-test could not be started" @@ -67,7 +67,7 @@ TaskKey[Unit]("check-autostart") := { () } -TaskKey[Unit]("check-no-autostart") := { +TaskKey[Unit]("checkNoAutostart") := { val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst") assert(script.contains("""addService debian-test || echo "debian-test could not be registered" |""".stripMargin), "addService post install commands missing or incorrect") diff --git a/src/sbt-test/debian/sysvinit-deb/test b/src/sbt-test/debian/sysvinit-deb/test index d83fa8ad0..941f6cae4 100644 --- a/src/sbt-test/debian/sysvinit-deb/test +++ b/src/sbt-test/debian/sysvinit-deb/test @@ -1,17 +1,17 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc $ exists target/debian-test-0.1.0/etc/default/debian-test $ exists target/debian-test-0.1.0/etc/init.d/debian-test -> check-control-files -> check-startup-script -> check-autostart +> checkControlFiles +> checkStartupScript +> checkAutostart # Test that serviceAutostart can be disabled > set every NativePackagerKeys.serviceAutostart := false -> debian:package-bin -> check-no-autostart \ No newline at end of file +> debian:packageBin +> checkNoAutostart \ No newline at end of file diff --git a/src/sbt-test/debian/sysvinit-stoptimeouts-deb/build.sbt b/src/sbt-test/debian/sysvinit-stoptimeouts-deb/build.sbt index 27cf2ceac..cc6b8b919 100644 --- a/src/sbt-test/debian/sysvinit-stoptimeouts-deb/build.sbt +++ b/src/sbt-test/debian/sysvinit-stoptimeouts-deb/build.sbt @@ -23,7 +23,7 @@ termTimeout in Debian := 10 killTimeout in Debian := 20 -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val header = "#!/bin/sh" val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") @@ -36,7 +36,7 @@ TaskKey[Unit]("check-control-files") := { () } -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val script = IO.read(target.value / "debian-test-0.1.0" / "etc" / "init.d" / "debian-test") assert(script.contains("# Default-Start: 2 3 4 5"), "script doesn't contain Default-Start header\n" + script) diff --git a/src/sbt-test/debian/sysvinit-stoptimeouts-deb/test b/src/sbt-test/debian/sysvinit-stoptimeouts-deb/test index c52706fc7..d903aefa5 100644 --- a/src/sbt-test/debian/sysvinit-stoptimeouts-deb/test +++ b/src/sbt-test/debian/sysvinit-stoptimeouts-deb/test @@ -1,10 +1,10 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc $ exists target/debian-test-0.1.0/etc/default/debian-test $ exists target/debian-test-0.1.0/etc/init.d/debian-test -> check-control-files -> check-startup-script \ No newline at end of file +> checkControlFiles +> checkStartupScript \ No newline at end of file diff --git a/src/sbt-test/debian/test-executableScriptName/build.sbt b/src/sbt-test/debian/test-executableScriptName/build.sbt index d62b4a896..5d45bfb2d 100644 --- a/src/sbt-test/debian/test-executableScriptName/build.sbt +++ b/src/sbt-test/debian/test-executableScriptName/build.sbt @@ -17,7 +17,7 @@ debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11) debianPackageRecommends in Debian += "git" -TaskKey[Unit]("check-upstart-script") := { +TaskKey[Unit]("checkUpstartScript") := { val script = IO.read(target.value / "debian-test-0.1.0" / "etc" / "init" / "debian-test.conf") assert(script.contains("exec sudo -u debian-test bin/debian-exec"), "wrong exec call\n" + script) streams.value.log.success("Successfully tested control script") diff --git a/src/sbt-test/debian/test-executableScriptName/test b/src/sbt-test/debian/test-executableScriptName/test index 74b8ed1d0..4b9331db4 100644 --- a/src/sbt-test/debian/test-executableScriptName/test +++ b/src/sbt-test/debian/test-executableScriptName/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb # Testing the packageName configuration $ exists target/debian-test-0.1.0/DEBIAN @@ -14,4 +14,4 @@ $ exists target/debian-test-0.1.0/var/log/debian-test/ $ exists target/debian-test-0.1.0/etc/default/debian-test/ # -------------------------------------------- $ exists target/debian-test-0.1.0/etc/init/debian-test.conf -> check-upstart-script +> checkUpstartScript diff --git a/src/sbt-test/debian/test-mapping-helpers/test b/src/sbt-test/debian/test-mapping-helpers/test index f5d62277d..03594d109 100644 --- a/src/sbt-test/debian/test-mapping-helpers/test +++ b/src/sbt-test/debian/test-mapping-helpers/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb # Template directories diff --git a/src/sbt-test/debian/test-mapping/build.sbt b/src/sbt-test/debian/test-mapping/build.sbt index 00c2e65d6..845d9a4f5 100644 --- a/src/sbt-test/debian/test-mapping/build.sbt +++ b/src/sbt-test/debian/test-mapping/build.sbt @@ -19,7 +19,7 @@ debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11) debianPackageRecommends in Debian += "git" -TaskKey[Unit]("check-control-script") := { +TaskKey[Unit]("checkControlScript") := { val script = IO.read(target.value / "debian-test-override-0.1.0" / "DEBIAN" / "control") assert(script.contains("Package: debian-test-package\n"), "script doesn't [Package: debian-test-package]\n" + script) diff --git a/src/sbt-test/debian/test-mapping/test b/src/sbt-test/debian/test-mapping/test index c1c8150bd..bcf850219 100644 --- a/src/sbt-test/debian/test-mapping/test +++ b/src/sbt-test/debian/test-mapping/test @@ -1,10 +1,10 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test-override_0.1.0_all.deb # Testing the packageName configuration $ exists target/debian-test-override-0.1.0/DEBIAN $ exists target/debian-test-override-0.1.0/DEBIAN/control -> check-control-script +> checkControlScript $ exists target/debian-test-override-0.1.0/usr/ $ exists target/debian-test-override-0.1.0/usr/share/ $ exists target/debian-test-override-0.1.0/usr/share/debian-test-package/ diff --git a/src/sbt-test/debian/test-packageName/build.sbt b/src/sbt-test/debian/test-packageName/build.sbt index c202fb018..83c67049a 100644 --- a/src/sbt-test/debian/test-packageName/build.sbt +++ b/src/sbt-test/debian/test-packageName/build.sbt @@ -19,7 +19,7 @@ debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11) debianPackageRecommends in Debian += "git" -TaskKey[Unit]("check-control-script") := { +TaskKey[Unit]("checkControlScript") := { val script = IO.read(target.value / "debian-test-override-0.1.0" / "DEBIAN" / "control") assert(script.contains("Package: debian-test-package\n"), "script doesn't [Package: debian-test-package]\n" + script) diff --git a/src/sbt-test/debian/test-packageName/test b/src/sbt-test/debian/test-packageName/test index 9922aac8d..b3389f0ad 100644 --- a/src/sbt-test/debian/test-packageName/test +++ b/src/sbt-test/debian/test-packageName/test @@ -1,10 +1,10 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test-override_0.1.0_all.deb # Testing the packageName configuration $ exists target/debian-test-override-0.1.0/DEBIAN $ exists target/debian-test-override-0.1.0/DEBIAN/control -> check-control-script +> checkControlScript $ exists target/debian-test-override-0.1.0/usr/ $ exists target/debian-test-override-0.1.0/usr/share/ $ exists target/debian-test-override-0.1.0/usr/share/debian-test-package/ diff --git a/src/sbt-test/debian/upstart-deb-facilities/build.sbt b/src/sbt-test/debian/upstart-deb-facilities/build.sbt index 55850d1c4..fa3f1a18f 100644 --- a/src/sbt-test/debian/upstart-deb-facilities/build.sbt +++ b/src/sbt-test/debian/upstart-deb-facilities/build.sbt @@ -21,7 +21,7 @@ requiredStopFacilities in Debian := Some("[networking]") packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val script = IO.read(target.value / "debian-test-0.1.0" / "etc" / "init" / "debian-test.conf") assert(script.contains("start on runlevel [2345]"), "script doesn't contain start on runlevel header\n" + script) assert(script.contains("stop on runlevel [016]"), "script doesn't contain stop on runlevel header\n" + script) diff --git a/src/sbt-test/debian/upstart-deb-facilities/test b/src/sbt-test/debian/upstart-deb-facilities/test index 5eb51cfae..9d5fcfc9f 100644 --- a/src/sbt-test/debian/upstart-deb-facilities/test +++ b/src/sbt-test/debian/upstart-deb-facilities/test @@ -1,6 +1,6 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc/init/debian-test.conf -> check-startup-script +> checkStartupScript diff --git a/src/sbt-test/debian/upstart-deb/build.sbt b/src/sbt-test/debian/upstart-deb/build.sbt index ec89455f6..8fc8ced5e 100644 --- a/src/sbt-test/debian/upstart-deb/build.sbt +++ b/src/sbt-test/debian/upstart-deb/build.sbt @@ -14,7 +14,7 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -TaskKey[Unit]("check-control-files") := { +TaskKey[Unit]("checkControlFiles") := { val debian = target.value / "debian-test-0.1.0" / "DEBIAN" val postinst = IO.read(debian / "postinst") val prerm = IO.read(debian / "prerm") @@ -25,13 +25,13 @@ TaskKey[Unit]("check-control-files") := { () } -InputKey[Unit]("check-softlink") := { +InputKey[Unit]("checkSoftlink") := { import complete.DefaultParsers._ val args = spaceDelimited("").parsed assert(args.size >= 2, "Usage: check-softlink link to target") val link = args(0) val target = args(args.size - 1) - val absolutePath = ("readlink -m " + link).!!.trim + val absolutePath = sys.process.Process("readlink -m " + link).!!.trim assert(link != absolutePath, "Expected symbolic link '" + link + "' does not exist") assert( target == absolutePath, @@ -39,7 +39,7 @@ InputKey[Unit]("check-softlink") := { ) } -TaskKey[Unit]("check-startup-script") := { +TaskKey[Unit]("checkStartupScript") := { val script = IO.read(target.value / "debian-test-0.1.0" / "etc" / "init" / "debian-test.conf") assert(script.contains("start on runlevel [2345]"), "script doesn't contain start on runlevel header\n" + script) assert(script.contains("stop on runlevel [016]"), "script doesn't contain stop on runlevel header\n" + script) @@ -53,7 +53,7 @@ TaskKey[Unit]("check-startup-script") := { () } -TaskKey[Unit]("check-autostart") := { +TaskKey[Unit]("checkAutostart") := { val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst") assert(script.contains("""addService debian-test || echo "debian-test could not be registered" |startService debian-test || echo "debian-test could not be started" @@ -61,7 +61,7 @@ TaskKey[Unit]("check-autostart") := { () } -TaskKey[Unit]("check-no-autostart") := { +TaskKey[Unit]("checkNoAutostart") := { val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst") assert(script.contains("""addService debian-test || echo "debian-test could not be registered" |""".stripMargin), "addService post install commands missing or incorrect") diff --git a/src/sbt-test/debian/upstart-deb/test b/src/sbt-test/debian/upstart-deb/test index 2e520c9f9..cabffa65a 100644 --- a/src/sbt-test/debian/upstart-deb/test +++ b/src/sbt-test/debian/upstart-deb/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> debian:package-bin +> debian:packageBin $ exists target/debian-test_0.1.0_all.deb $ exists target/debian-test-0.1.0/etc @@ -11,14 +11,14 @@ $ exists target/debian-test-0.1.0/DEBIAN/prerm $ exists target/debian-test-0.1.0/DEBIAN/postinst # Check files for defaults -> check-control-files -> check-softlink target/debian-test-0.1.0/usr/bin/debian-test points to /usr/share/debian-test/bin/debian-test -> check-startup-script -> check-autostart +> checkControlFiles +> checkSoftlink target/debian-test-0.1.0/usr/bin/debian-test points to /usr/share/debian-test/bin/debian-test +> checkStartupScript +> checkAutostart # Test that serviceAutostart can be disabled > set every NativePackagerKeys.serviceAutostart := false -> debian:package-bin -> check-no-autostart \ No newline at end of file +> debian:packageBin +> checkNoAutostart \ No newline at end of file diff --git a/src/sbt-test/docker/test-executableScriptName/build.sbt b/src/sbt-test/docker/test-executableScriptName/build.sbt index 6160d488e..93086b161 100644 --- a/src/sbt-test/docker/test-executableScriptName/build.sbt +++ b/src/sbt-test/docker/test-executableScriptName/build.sbt @@ -10,7 +10,7 @@ version := "0.1.0" maintainer := "Gary Coady " -TaskKey[Unit]("check-dockerfile") := { +TaskKey[Unit]("checkDockerfile") := { val dockerfile = IO.read(target.value / "docker" / "Dockerfile") assert( dockerfile.contains("ENTRYPOINT [\"bin/docker-exec\"]\n"), diff --git a/src/sbt-test/docker/test-executableScriptName/test b/src/sbt-test/docker/test-executableScriptName/test index e04834785..eb43db833 100644 --- a/src/sbt-test/docker/test-executableScriptName/test +++ b/src/sbt-test/docker/test-executableScriptName/test @@ -2,5 +2,5 @@ > docker:publishLocal $ exists target/docker/stage/Dockerfile $ exists target/docker/stage/opt/docker/bin/docker-exec -> check-dockerfile +> checkDockerfile $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' \ No newline at end of file diff --git a/src/sbt-test/docker/test-packageName-universal/build.sbt b/src/sbt-test/docker/test-packageName-universal/build.sbt index 7a0add09b..17c214855 100644 --- a/src/sbt-test/docker/test-packageName-universal/build.sbt +++ b/src/sbt-test/docker/test-packageName-universal/build.sbt @@ -8,7 +8,7 @@ version := "0.1.0" maintainer := "Gary Coady " -TaskKey[Unit]("check-dockerfile") := { +TaskKey[Unit]("checkDockerfile") := { val dockerfile = IO.read(target.value / "docker" / "Dockerfile") assert( dockerfile.contains("ENTRYPOINT [\"bin/docker-test\"]\n"), diff --git a/src/sbt-test/docker/test-packageName-universal/test b/src/sbt-test/docker/test-packageName-universal/test index 96a9d94d2..a14902398 100644 --- a/src/sbt-test/docker/test-packageName-universal/test +++ b/src/sbt-test/docker/test-packageName-universal/test @@ -2,5 +2,5 @@ > docker:publishLocal $ exists target/docker/stage/Dockerfile $ exists target/docker/stage/opt/docker/bin/docker-test -> check-dockerfile +> checkDockerfile $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' \ No newline at end of file diff --git a/src/sbt-test/docker/test-packageName/build.sbt b/src/sbt-test/docker/test-packageName/build.sbt index d86fab96c..f855ea17b 100644 --- a/src/sbt-test/docker/test-packageName/build.sbt +++ b/src/sbt-test/docker/test-packageName/build.sbt @@ -9,7 +9,7 @@ version := "0.1.0" maintainer := "Gary Coady " -TaskKey[Unit]("check-dockerfile") := { +TaskKey[Unit]("checkDockerfile") := { val dockerfile = IO.read(target.value / "docker" / "Dockerfile") assert( dockerfile.contains("ENTRYPOINT [\"bin/docker-test\"]\n"), diff --git a/src/sbt-test/docker/test-packageName/test b/src/sbt-test/docker/test-packageName/test index 96a9d94d2..a14902398 100644 --- a/src/sbt-test/docker/test-packageName/test +++ b/src/sbt-test/docker/test-packageName/test @@ -2,5 +2,5 @@ > docker:publishLocal $ exists target/docker/stage/Dockerfile $ exists target/docker/stage/opt/docker/bin/docker-test -> check-dockerfile +> checkDockerfile $ exec bash -c 'docker run docker-package:0.1.0 | grep -q "Hello world"' \ No newline at end of file diff --git a/src/sbt-test/jar/classpath-jar/build.sbt b/src/sbt-test/jar/classpath-jar/build.sbt index 662c63305..798d57d0d 100644 --- a/src/sbt-test/jar/classpath-jar/build.sbt +++ b/src/sbt-test/jar/classpath-jar/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(ClasspathJarPlugin) name := "classpath-jar-test" @@ -5,25 +7,23 @@ name := "classpath-jar-test" version := "0.1.0" // test dependencies sample -libraryDependencies ++= Seq("com.typesafe.akka" %% "akka-kernel" % "2.3.4") +libraryDependencies += "com.typesafe" % "config" % "1.3.1" -TaskKey[Unit]("check-classspath") := { +TaskKey[Unit]("checkClasspath") := { val dir = (stagingDirectory in Universal).value val bat = IO.read(dir / "bin" / "classpath-jar-test.bat") assert(bat contains "set \"APP_CLASSPATH=%APP_LIB_DIR%\\classpath-jar-test.classpath-jar-test-0.1.0-classpath.jar\"") val jar = new java.util.jar.JarFile(dir / "lib" / "classpath-jar-test.classpath-jar-test-0.1.0-classpath.jar") - assert( - jar.getManifest().getMainAttributes().getValue("Class-Path").toString() contains "com.typesafe.akka.akka-actor" - ) + assert(jar.getManifest().getMainAttributes().getValue("Class-Path") contains "com.typesafe.config") jar close } -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val dir = (stagingDirectory in Universal).value val cmd = if (System.getProperty("os.name").contains("Windows")) { Seq("cmd", "/c", (dir / "bin" / "classpath-jar-test.bat").getAbsolutePath) } else { Seq((dir / "bin" / "classpath-jar-test").getAbsolutePath) } - assert(Process(cmd).!! contains "SUCCESS!") + assert(sys.process.Process(cmd).!! contains "SUCCESS!") } diff --git a/src/sbt-test/jar/classpath-jar/src/main/scala/test/Test.scala b/src/sbt-test/jar/classpath-jar/src/main/scala/test/Test.scala index 19b48f36e..5d7c8d7c5 100644 --- a/src/sbt-test/jar/classpath-jar/src/main/scala/test/Test.scala +++ b/src/sbt-test/jar/classpath-jar/src/main/scala/test/Test.scala @@ -1,29 +1,12 @@ package test // use dependency library - -import akka.actor._ -import akka.pattern._ -import akka.routing.RoundRobinRouter -import akka.util.Timeout -import scala.concurrent.duration._ - -class PrintActor extends Actor{ - def receive = { - case msg => - println(msg) - context.sender ! "ok" - } -} +import com.typesafe.config._ object Test extends App { - implicit val timeout = Timeout(3 seconds) - val system = ActorSystem("testSystem") - import system.dispatcher + val config = ConfigFactory.load() + + println("SUCCESS!") - val router = system.actorOf(Props[PrintActor]) - (router ? "SUCCESS!!").foreach { _ => - system.shutdown - } } diff --git a/src/sbt-test/jar/classpath-jar/test b/src/sbt-test/jar/classpath-jar/test index e9eaf3146..e55f12b4f 100644 --- a/src/sbt-test/jar/classpath-jar/test +++ b/src/sbt-test/jar/classpath-jar/test @@ -2,5 +2,5 @@ > stage $ exists target/universal/stage/lib/classpath-jar-test.classpath-jar-test-0.1.0-classpath.jar $ exists target/universal/stage/bin/classpath-jar-test.bat -> check-classspath -> run-check +> checkClasspath +> runCheck diff --git a/src/sbt-test/jar/launcher-jar with spaces/build.sbt b/src/sbt-test/jar/launcher-jar with spaces/build.sbt index aa424b7c9..58578eb9f 100644 --- a/src/sbt-test/jar/launcher-jar with spaces/build.sbt +++ b/src/sbt-test/jar/launcher-jar with spaces/build.sbt @@ -5,9 +5,9 @@ name := "launcher-jar-test" version := "0.1.0" // test dependencies sample -libraryDependencies ++= Seq("com.typesafe.akka" %% "akka-kernel" % "2.3.4") +libraryDependencies += "com.typesafe" % "config" % "1.3.1" -TaskKey[Unit]("check-classpath") := { +TaskKey[Unit]("checkClasspath") := { val dir = (stagingDirectory in Universal).value val bat = IO.read(dir / "bin" / "launcher-jar-test.bat") assert(bat contains "set \"APP_CLASSPATH=\"", "bat should set APP_CLASSPATH:\n" + bat) @@ -24,8 +24,8 @@ TaskKey[Unit]("check-classpath") := { val jar = new java.util.jar.JarFile(dir / "lib" / "launcher-jar-test.launcher-jar-test-0.1.0-launcher.jar") val attributes = jar.getManifest().getMainAttributes() assert( - attributes.getValue("Class-Path").toString() contains "com.typesafe.akka.akka-actor", - "MANIFEST Class-Path should contain akka-actor:\n" + attributes.getValue("Class-Path").toString() + attributes.getValue("Class-Path").toString() contains "com.typesafe.config", + "MANIFEST Class-Path should contain com.typesafe.config:\n" + attributes.getValue("Class-Path").toString() ) assert( attributes.getValue("Main-Class").toString() contains "test.Test", @@ -34,12 +34,12 @@ TaskKey[Unit]("check-classpath") := { jar close } -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val dir = (stagingDirectory in Universal).value val cmd = if (System.getProperty("os.name").contains("Windows")) { Seq("cmd", "/c", (dir / "bin" / "launcher-jar-test.bat").getAbsolutePath) } else { Seq((dir / "bin" / "launcher-jar-test").getAbsolutePath) } - assert(Process(cmd).!! contains "SUCCESS!") + assert(sys.process.Process(cmd).!! contains "SUCCESS!") } diff --git a/src/sbt-test/jar/launcher-jar with spaces/src/main/scala/test/Test.scala b/src/sbt-test/jar/launcher-jar with spaces/src/main/scala/test/Test.scala index 23a87b45e..5d7c8d7c5 100644 --- a/src/sbt-test/jar/launcher-jar with spaces/src/main/scala/test/Test.scala +++ b/src/sbt-test/jar/launcher-jar with spaces/src/main/scala/test/Test.scala @@ -1,19 +1,12 @@ package test // use dependency library +import com.typesafe.config._ -import akka.actor._ -import akka.routing.RoundRobinRouter +object Test extends App { -class PrintActor extends Actor{ - def receive = { - case msg => println(msg) - } -} + val config = ConfigFactory.load() + + println("SUCCESS!") -object Test extends App { - val system = ActorSystem("testSystem") - val router = system.actorOf(Props[PrintActor]) - router ! "SUCCESS!!" - system.shutdown } diff --git a/src/sbt-test/jar/launcher-jar with spaces/test b/src/sbt-test/jar/launcher-jar with spaces/test index 770be33d5..09c0d76d8 100644 --- a/src/sbt-test/jar/launcher-jar with spaces/test +++ b/src/sbt-test/jar/launcher-jar with spaces/test @@ -1,5 +1,5 @@ # Run the staging and check the script. > stage $ exists target/universal/stage/lib/launcher-jar-test.launcher-jar-test-0.1.0-launcher.jar -> check-classpath -> run-check +> checkClasspath +> runCheck diff --git a/src/sbt-test/jar/launcher-jar/build.sbt b/src/sbt-test/jar/launcher-jar/build.sbt index aa424b7c9..2a8c6c3ff 100644 --- a/src/sbt-test/jar/launcher-jar/build.sbt +++ b/src/sbt-test/jar/launcher-jar/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(LauncherJarPlugin) name := "launcher-jar-test" @@ -5,9 +7,9 @@ name := "launcher-jar-test" version := "0.1.0" // test dependencies sample -libraryDependencies ++= Seq("com.typesafe.akka" %% "akka-kernel" % "2.3.4") +libraryDependencies += "com.typesafe" % "config" % "1.3.1" -TaskKey[Unit]("check-classpath") := { +TaskKey[Unit]("checkClasspath") := { val dir = (stagingDirectory in Universal).value val bat = IO.read(dir / "bin" / "launcher-jar-test.bat") assert(bat contains "set \"APP_CLASSPATH=\"", "bat should set APP_CLASSPATH:\n" + bat) @@ -24,22 +26,22 @@ TaskKey[Unit]("check-classpath") := { val jar = new java.util.jar.JarFile(dir / "lib" / "launcher-jar-test.launcher-jar-test-0.1.0-launcher.jar") val attributes = jar.getManifest().getMainAttributes() assert( - attributes.getValue("Class-Path").toString() contains "com.typesafe.akka.akka-actor", - "MANIFEST Class-Path should contain akka-actor:\n" + attributes.getValue("Class-Path").toString() + attributes.getValue("Class-Path") contains "com.typesafe.config", + "MANIFEST Class-Path should contain 'com.typesafe.config':\n" + attributes.getValue("Class-Path") ) assert( - attributes.getValue("Main-Class").toString() contains "test.Test", - "MANIFEST Main-Class should contain test.Test:\n" + attributes.getValue("Main-Class").toString() + attributes.getValue("Main-Class") contains "test.Test", + "MANIFEST Main-Class should contain test.Test:\n" + attributes.getValue("Main-Class") ) jar close } -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val dir = (stagingDirectory in Universal).value val cmd = if (System.getProperty("os.name").contains("Windows")) { Seq("cmd", "/c", (dir / "bin" / "launcher-jar-test.bat").getAbsolutePath) } else { Seq((dir / "bin" / "launcher-jar-test").getAbsolutePath) } - assert(Process(cmd).!! contains "SUCCESS!") + assert(sys.process.Process(cmd).!! contains "SUCCESS!") } diff --git a/src/sbt-test/jar/launcher-jar/src/main/scala/test/Test.scala b/src/sbt-test/jar/launcher-jar/src/main/scala/test/Test.scala index 23a87b45e..5d7c8d7c5 100644 --- a/src/sbt-test/jar/launcher-jar/src/main/scala/test/Test.scala +++ b/src/sbt-test/jar/launcher-jar/src/main/scala/test/Test.scala @@ -1,19 +1,12 @@ package test // use dependency library +import com.typesafe.config._ -import akka.actor._ -import akka.routing.RoundRobinRouter +object Test extends App { -class PrintActor extends Actor{ - def receive = { - case msg => println(msg) - } -} + val config = ConfigFactory.load() + + println("SUCCESS!") -object Test extends App { - val system = ActorSystem("testSystem") - val router = system.actorOf(Props[PrintActor]) - router ! "SUCCESS!!" - system.shutdown } diff --git a/src/sbt-test/jar/launcher-jar/test b/src/sbt-test/jar/launcher-jar/test index 770be33d5..09c0d76d8 100644 --- a/src/sbt-test/jar/launcher-jar/test +++ b/src/sbt-test/jar/launcher-jar/test @@ -1,5 +1,5 @@ # Run the staging and check the script. > stage $ exists target/universal/stage/lib/launcher-jar-test.launcher-jar-test-0.1.0-launcher.jar -> check-classpath -> run-check +> checkClasspath +> runCheck diff --git a/src/sbt-test/jdkpackager/test-package-mappings/build.sbt b/src/sbt-test/jdkpackager/test-package-mappings/build.sbt index 59b60cde3..3bcea394f 100644 --- a/src/sbt-test/jdkpackager/test-package-mappings/build.sbt +++ b/src/sbt-test/jdkpackager/test-package-mappings/build.sbt @@ -20,7 +20,7 @@ mappings in Universal += baseDirectory.value / "src" / "deploy" / "README.md" -> mappings in Universal ++= { val dir = baseDirectory.value / "src" / "deploy" / "stuff" - (dir.*** --- dir) pair relativeTo(dir.getParentFile) + (dir.**(AllPassFilter) --- dir) pair (file => IO.relativize(dir.getParentFile, file)) } lazy val iconGlob = sys.props("os.name").toLowerCase match { diff --git a/src/sbt-test/rpm/changelog-test/build.sbt b/src/sbt-test/rpm/changelog-test/build.sbt index 497251183..e88f7357f 100644 --- a/src/sbt-test/rpm/changelog-test/build.sbt +++ b/src/sbt-test/rpm/changelog-test/build.sbt @@ -21,7 +21,7 @@ rpmLicense := Some("BSD") rpmChangelogFile := Some("conf/changelog") -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") // Check if the RPM writted the changelog tag on the task assert(spec contains "%changelog\n", "Spec doesn't contain %changelog tag on the SPEC") diff --git a/src/sbt-test/rpm/changelog-test/test b/src/sbt-test/rpm/changelog-test/test index 91f5a8c91..30f7e1fff 100644 --- a/src/sbt-test/rpm/changelog-test/test +++ b/src/sbt-test/rpm/changelog-test/test @@ -1,9 +1,9 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm $ exists target/rpm/SPECS/rpm-test.spec # Check files for defaults -> check-spec-file +> checkSpecFile > set NativePackagerKeys.rpmBrpJavaRepackJars := false -> check-spec-file +> checkSpecFile diff --git a/src/sbt-test/rpm/config-no-replace/build.sbt b/src/sbt-test/rpm/config-no-replace/build.sbt index fa29b6a6d..8da1e0a99 100644 --- a/src/sbt-test/rpm/config-no-replace/build.sbt +++ b/src/sbt-test/rpm/config-no-replace/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(RpmPlugin) name := "rpm-test" @@ -25,7 +27,7 @@ linuxPackageMappings := configWithNoReplace(linuxPackageMappings.value) TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log } TaskKey[Unit]("checkSpecFile") := { diff --git a/src/sbt-test/rpm/config-no-replace/test b/src/sbt-test/rpm/config-no-replace/test index e6620db76..440a1b58d 100644 --- a/src/sbt-test/rpm/config-no-replace/test +++ b/src/sbt-test/rpm/config-no-replace/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/x86_64/rpm-test-0.1.0-1.x86_64.rpm > unzip diff --git a/src/sbt-test/rpm/override-loader-functions/build.sbt b/src/sbt-test/rpm/override-loader-functions/build.sbt index cc961b784..65688f54d 100644 --- a/src/sbt-test/rpm/override-loader-functions/build.sbt +++ b/src/sbt-test/rpm/override-loader-functions/build.sbt @@ -23,9 +23,9 @@ rpmLicense := Some("BSD") rpmGroup := Some("test-group") -TaskKey[Unit]("check-loader-script") := { +TaskKey[Unit]("checkLoaderScript") := { val path = target.value / "rpm" / "RPMS" / "noarch" / "rpm-test-0.1.0-1.noarch.rpm" - val scripts = s"rpm -qp --scripts ${path.absolutePath}".!! + val scripts = sys.process.Process(s"rpm -qp --scripts ${path.absolutePath}").!! assert(scripts.contains("# right systemd template"), s"override script wasn't picked, scripts are\n$scripts") assert(!scripts.contains("wrong start template"), s"scripts contained wrong template, scripts are\n$scripts") diff --git a/src/sbt-test/rpm/override-loader-functions/test b/src/sbt-test/rpm/override-loader-functions/test index 9ec6e993c..04dcd43c5 100644 --- a/src/sbt-test/rpm/override-loader-functions/test +++ b/src/sbt-test/rpm/override-loader-functions/test @@ -1,5 +1,5 @@ # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm -> check-loader-script +> checkLoaderScript diff --git a/src/sbt-test/rpm/override-start-script-systemd/build.sbt b/src/sbt-test/rpm/override-start-script-systemd/build.sbt index df2fcee64..0a013d7bd 100644 --- a/src/sbt-test/rpm/override-start-script-systemd/build.sbt +++ b/src/sbt-test/rpm/override-start-script-systemd/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemdPlugin) name := "rpm-test" @@ -25,7 +27,7 @@ rpmGroup := Some("test-group") TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log () } diff --git a/src/sbt-test/rpm/override-start-script-systemd/test b/src/sbt-test/rpm/override-start-script-systemd/test index 6a04be025..996a6f2aa 100644 --- a/src/sbt-test/rpm/override-start-script-systemd/test +++ b/src/sbt-test/rpm/override-start-script-systemd/test @@ -1,5 +1,5 @@ # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm > unzip diff --git a/src/sbt-test/rpm/override-start-script-systemv/build.sbt b/src/sbt-test/rpm/override-start-script-systemv/build.sbt index 8f9c48a9d..53d393649 100644 --- a/src/sbt-test/rpm/override-start-script-systemv/build.sbt +++ b/src/sbt-test/rpm/override-start-script-systemv/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemVPlugin) name := "rpm-test" @@ -25,7 +27,7 @@ rpmGroup := Some("test-group") TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log () } diff --git a/src/sbt-test/rpm/override-start-script-systemv/test b/src/sbt-test/rpm/override-start-script-systemv/test index eca2e528d..2c6817a6b 100644 --- a/src/sbt-test/rpm/override-start-script-systemv/test +++ b/src/sbt-test/rpm/override-start-script-systemv/test @@ -1,5 +1,5 @@ # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm > unzip diff --git a/src/sbt-test/rpm/override-start-script-upstart/build.sbt b/src/sbt-test/rpm/override-start-script-upstart/build.sbt index 95047c749..80f1aaf85 100644 --- a/src/sbt-test/rpm/override-start-script-upstart/build.sbt +++ b/src/sbt-test/rpm/override-start-script-upstart/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, UpstartPlugin) name := "rpm-test" @@ -25,7 +27,7 @@ rpmGroup := Some("test-group") TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log () } diff --git a/src/sbt-test/rpm/override-start-script-upstart/test b/src/sbt-test/rpm/override-start-script-upstart/test index 6dc54d9e6..8d95f5912 100644 --- a/src/sbt-test/rpm/override-start-script-upstart/test +++ b/src/sbt-test/rpm/override-start-script-upstart/test @@ -1,5 +1,5 @@ # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm > unzip diff --git a/src/sbt-test/rpm/path-override-rpm/build.sbt b/src/sbt-test/rpm/path-override-rpm/build.sbt index 16a2dc213..dd7c11886 100644 --- a/src/sbt-test/rpm/path-override-rpm/build.sbt +++ b/src/sbt-test/rpm/path-override-rpm/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemVPlugin) name := "rpm-test" @@ -22,11 +24,11 @@ defaultLinuxLogsLocation := "/opt/test/log" TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log () } -TaskKey[Unit]("check-init-file") := { +TaskKey[Unit]("checkInitFile") := { val initd = IO.read(baseDirectory.value / "etc" / "init.d" / "rpm-test") assert(initd contains "/opt/test/rpm-test", "defaultLinuxInstallLocation not overriden in init.d\n" + initd) assert( diff --git a/src/sbt-test/rpm/path-override-rpm/test b/src/sbt-test/rpm/path-override-rpm/test index 5662e0959..a974bf720 100644 --- a/src/sbt-test/rpm/path-override-rpm/test +++ b/src/sbt-test/rpm/path-override-rpm/test @@ -1,10 +1,10 @@ # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm > unzip $ exists opt/test/rpm-test $ exists etc/init.d/rpm-test -> check-init-file +> checkInitFile diff --git a/src/sbt-test/rpm/scriplets-no-javarepack-rpm/build.sbt b/src/sbt-test/rpm/scriplets-no-javarepack-rpm/build.sbt index c0236f73d..6771f5a1b 100644 --- a/src/sbt-test/rpm/scriplets-no-javarepack-rpm/build.sbt +++ b/src/sbt-test/rpm/scriplets-no-javarepack-rpm/build.sbt @@ -22,7 +22,7 @@ rpmLicense := Some("BSD") rpmBrpJavaRepackJars := false -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test-no-repack.spec") assert(spec.contains("""%define __jar_repack %nil"""), "Missing java repack disabling in %pre") streams.value.log.success("Successfully tested rpm test file") diff --git a/src/sbt-test/rpm/scriplets-no-javarepack-rpm/test b/src/sbt-test/rpm/scriplets-no-javarepack-rpm/test index 6c6e1e1eb..4efb740eb 100644 --- a/src/sbt-test/rpm/scriplets-no-javarepack-rpm/test +++ b/src/sbt-test/rpm/scriplets-no-javarepack-rpm/test @@ -1,6 +1,6 @@ # Run the RPM packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-no-repack-0.1.0-2.noarch.rpm $ exists target/rpm/SPECS/rpm-test-no-repack.spec -> check-spec-file \ No newline at end of file +> checkSpecFile \ No newline at end of file diff --git a/src/sbt-test/rpm/scriplets-use-javarepack-rpm/build.sbt b/src/sbt-test/rpm/scriplets-use-javarepack-rpm/build.sbt index 6550e9ecd..f1049fbdc 100644 --- a/src/sbt-test/rpm/scriplets-use-javarepack-rpm/build.sbt +++ b/src/sbt-test/rpm/scriplets-use-javarepack-rpm/build.sbt @@ -22,7 +22,7 @@ rpmLicense := Some("BSD") rpmBrpJavaRepackJars := true -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test-with-repack.spec") assert(!spec.contains("""%define __jar_repack %nil"""), "%pre should not contain jar repack when set to true") streams.value.log.success("Successfully tested rpm test file") diff --git a/src/sbt-test/rpm/scriplets-use-javarepack-rpm/test b/src/sbt-test/rpm/scriplets-use-javarepack-rpm/test index f2060ebc9..25d91eb8d 100644 --- a/src/sbt-test/rpm/scriplets-use-javarepack-rpm/test +++ b/src/sbt-test/rpm/scriplets-use-javarepack-rpm/test @@ -1,6 +1,6 @@ # Run the RPM packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-with-repack-0.1.0-2.noarch.rpm $ exists target/rpm/SPECS/rpm-test-with-repack.spec -> check-spec-file \ No newline at end of file +> checkSpecFile \ No newline at end of file diff --git a/src/sbt-test/rpm/scriptlets-override-build-rpm/build.sbt b/src/sbt-test/rpm/scriptlets-override-build-rpm/build.sbt index e6e9b2dbd..2cdf94fd2 100644 --- a/src/sbt-test/rpm/scriptlets-override-build-rpm/build.sbt +++ b/src/sbt-test/rpm/scriptlets-override-build-rpm/build.sbt @@ -29,7 +29,7 @@ maintainerScripts in Rpm := Map( Postun -> Seq("""echo "post-uninstall"""") ) -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert(spec contains "%pre\necho \"pre-install\"", "Spec doesn't contain %pre scriptlet") assert(spec contains "%post\necho \"post-install\"", "Spec doesn't contain %post scriptlet") diff --git a/src/sbt-test/rpm/scriptlets-override-build-rpm/test b/src/sbt-test/rpm/scriptlets-override-build-rpm/test index 91f5a8c91..30f7e1fff 100644 --- a/src/sbt-test/rpm/scriptlets-override-build-rpm/test +++ b/src/sbt-test/rpm/scriptlets-override-build-rpm/test @@ -1,9 +1,9 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm $ exists target/rpm/SPECS/rpm-test.spec # Check files for defaults -> check-spec-file +> checkSpecFile > set NativePackagerKeys.rpmBrpJavaRepackJars := false -> check-spec-file +> checkSpecFile diff --git a/src/sbt-test/rpm/scriptlets-override-rpm/build.sbt b/src/sbt-test/rpm/scriptlets-override-rpm/build.sbt index 125acb57b..895831d8a 100644 --- a/src/sbt-test/rpm/scriptlets-override-rpm/build.sbt +++ b/src/sbt-test/rpm/scriptlets-override-rpm/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemVPlugin) name := "rpm-test" @@ -17,8 +19,8 @@ mainClass in (Compile, run) := Some("com.example.MainApp") TaskKey[Unit]("unzipAndCheck") := { val rpmFile = (packageBin in Rpm).value val rpmPath = Seq(rpmFile.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log - val scriptlets = Process("rpm -qp --scripts " + rpmFile.getAbsolutePath) !! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log + val scriptlets = sys.process.Process("rpm -qp --scripts " + rpmFile.getAbsolutePath) !! streams.value.log assert(scriptlets contains "echo postinst", "'echo 'postinst' not present in \n" + scriptlets) assert(scriptlets contains "echo preinst", "'echo 'preinst' not present in \n" + scriptlets) assert(scriptlets contains "echo postun", "'echo 'postun' not present in \n" + scriptlets) @@ -26,7 +28,7 @@ TaskKey[Unit]("unzipAndCheck") := { () } -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert(spec contains "echo postinst", "'echo 'postinst' not present in \n" + spec) assert(spec contains "echo preinst", "'echo 'preinst' not present in \n" + spec) @@ -41,7 +43,7 @@ def countSubstring(str: String, substr: String): Int = def isUnique(str: String, searchstr: String): Boolean = countSubstring(str, searchstr) == 1 -TaskKey[Unit]("unique-scripts-in-spec-file") := { +TaskKey[Unit]("uniqueSccriptsInSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert(isUnique(spec, "echo postinst"), "'echo 'postinst' not unique in \n" + spec) assert(isUnique(spec, "echo preinst"), "'echo 'preinst' not unique in \n" + spec) diff --git a/src/sbt-test/rpm/scriptlets-override-rpm/test b/src/sbt-test/rpm/scriptlets-override-rpm/test index f885a5382..15afea396 100644 --- a/src/sbt-test/rpm/scriptlets-override-rpm/test +++ b/src/sbt-test/rpm/scriptlets-override-rpm/test @@ -1,5 +1,5 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm # Check rpm contents @@ -19,8 +19,8 @@ $ exists var/run/rpm-test # TODO symlinks aren't checked -> check-spec-file +> checkSpecFile > set NativePackagerKeys.rpmBrpJavaRepackJars := false -> check-spec-file +> checkSpecFile -> unique-scripts-in-spec-file \ No newline at end of file +> uniqueSccriptsInSpecFile \ No newline at end of file diff --git a/src/sbt-test/rpm/scriptlets-rpm/build.sbt b/src/sbt-test/rpm/scriptlets-rpm/build.sbt index e8be87b92..70cc14f59 100644 --- a/src/sbt-test/rpm/scriptlets-rpm/build.sbt +++ b/src/sbt-test/rpm/scriptlets-rpm/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + import RpmConstants._ enablePlugins(RpmPlugin) @@ -30,7 +32,7 @@ maintainerScripts in Rpm := Map( Postun -> Seq("""echo "post-uninstall"""") ) -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert(spec contains "%pre\necho \"pre-install\"", "Spec doesn't contain %pre scriptlet") assert(spec contains "%post\necho \"post-install\"", "Spec doesn't contain %post scriptlet") @@ -85,8 +87,8 @@ TaskKey[Unit]("check-spec-file") := { () } -TaskKey[Unit]("check-rpm-version") := { - val fullRpmVersion = Process("rpm", Seq("--version")) !! +TaskKey[Unit]("checkRpmVersion") := { + val fullRpmVersion = sys.process.Process("rpm", Seq("--version")) !! val firstDigit = fullRpmVersion indexWhere Character.isDigit val rpmVersion = fullRpmVersion substring firstDigit streams.value.log.info("Found rpmVersion: " + rpmVersion) diff --git a/src/sbt-test/rpm/scriptlets-rpm/test b/src/sbt-test/rpm/scriptlets-rpm/test index 9c6826041..522171f60 100644 --- a/src/sbt-test/rpm/scriptlets-rpm/test +++ b/src/sbt-test/rpm/scriptlets-rpm/test @@ -1,10 +1,10 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm $ exists target/rpm/SPECS/rpm-test.spec # Check files for defaults -> check-spec-file -> check-rpm-version +> checkSpecFile +> checkRpmVersion > set NativePackagerKeys.rpmBrpJavaRepackJars := false -> check-spec-file +> checkSpecFile diff --git a/src/sbt-test/rpm/setarch-rpm/build.sbt b/src/sbt-test/rpm/setarch-rpm/build.sbt index 11fa77682..2cc6f4120 100644 --- a/src/sbt-test/rpm/setarch-rpm/build.sbt +++ b/src/sbt-test/rpm/setarch-rpm/build.sbt @@ -26,7 +26,7 @@ linuxPackageMappings := { linuxPackageMappings.value :+ helloMapping } -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-package.spec") streams.value.log.success(spec) assert( diff --git a/src/sbt-test/rpm/setarch-rpm/test b/src/sbt-test/rpm/setarch-rpm/test index dd859659d..4fccc8a78 100644 --- a/src/sbt-test/rpm/setarch-rpm/test +++ b/src/sbt-test/rpm/setarch-rpm/test @@ -1,7 +1,7 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/i386/rpm-package-0.1.0-1.i386.rpm $ exists target/rpm/SPECS/rpm-package.spec # Check files for defaults -> check-spec-file +> checkSpecFile diff --git a/src/sbt-test/rpm/simple-rpm/test b/src/sbt-test/rpm/simple-rpm/test index 3ed170d50..c44497912 100644 --- a/src/sbt-test/rpm/simple-rpm/test +++ b/src/sbt-test/rpm/simple-rpm/test @@ -2,5 +2,5 @@ $ exists target/rpm > checkSpecFile # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/x86_64/rpm-test-0.1.0-1.x86_64.rpm diff --git a/src/sbt-test/rpm/snapshot-override-rpm/build.sbt b/src/sbt-test/rpm/snapshot-override-rpm/build.sbt index 9eed1209e..fa3da01e4 100644 --- a/src/sbt-test/rpm/snapshot-override-rpm/build.sbt +++ b/src/sbt-test/rpm/snapshot-override-rpm/build.sbt @@ -19,7 +19,7 @@ rpmLicense := Some("BSD") version in Rpm := "1" -TaskKey[Unit]("check-snapshot") := { +TaskKey[Unit]("checkSnapshot") := { assert(rpmRelease.value == "SNAPSHOT", s"RPM has incorrect value ${rpmRelease.value}") assert(rpmMetadata.value.version == "1", s"RPM has incorrect value ${rpmMetadata.value.version}") assert((version in Rpm).value == "1", s"RPM has incorrect value ${(version in Rpm).value}") diff --git a/src/sbt-test/rpm/snapshot-override-rpm/test b/src/sbt-test/rpm/snapshot-override-rpm/test index dbd83ee21..35cf628d9 100644 --- a/src/sbt-test/rpm/snapshot-override-rpm/test +++ b/src/sbt-test/rpm/snapshot-override-rpm/test @@ -1,6 +1,6 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-1-SNAPSHOT.noarch.rpm #Check release and version configured correctly -> check-snapshot +> checkSnapshot diff --git a/src/sbt-test/rpm/snapshot-rpm/build.sbt b/src/sbt-test/rpm/snapshot-rpm/build.sbt index f4c09d6c7..ce6662a01 100644 --- a/src/sbt-test/rpm/snapshot-rpm/build.sbt +++ b/src/sbt-test/rpm/snapshot-rpm/build.sbt @@ -17,8 +17,7 @@ rpmUrl := Some("http://github.com/sbt/sbt-native-packager") rpmLicense := Some("BSD") -TaskKey[Unit]("check-snapshot") := { +TaskKey[Unit]("checkSnapshot") := { assert(rpmRelease.value == "SNAPSHOT", s"RPM has incorrect value ${rpmRelease.value}") assert(rpmMetadata.value.version == "0.1.0", s"RPM has incorrect value ${rpmMetadata.value.version}") } - diff --git a/src/sbt-test/rpm/snapshot-rpm/test b/src/sbt-test/rpm/snapshot-rpm/test index 53bc1d3f5..8959fb092 100644 --- a/src/sbt-test/rpm/snapshot-rpm/test +++ b/src/sbt-test/rpm/snapshot-rpm/test @@ -1,6 +1,6 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-SNAPSHOT.noarch.rpm #Check release and version configured correctly -> check-snapshot \ No newline at end of file +> checkSnapshot \ No newline at end of file diff --git a/src/sbt-test/rpm/systemd-rpm/build.sbt b/src/sbt-test/rpm/systemd-rpm/build.sbt index 22f1ab099..334d4ddf6 100644 --- a/src/sbt-test/rpm/systemd-rpm/build.sbt +++ b/src/sbt-test/rpm/systemd-rpm/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemdPlugin) name := "rpm-test" @@ -18,7 +20,7 @@ requiredStartFacilities in Rpm := Some("serviceA.service") TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log () } @@ -114,7 +116,7 @@ TaskKey[Unit]("checkSpecFile") := { () } -TaskKey[Unit]("check-spec-autostart") := { +TaskKey[Unit]("checkSpecAutostart") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") println(spec) @@ -134,7 +136,7 @@ TaskKey[Unit]("check-spec-autostart") := { () } -TaskKey[Unit]("check-spec-no-autostart") := { +TaskKey[Unit]("checkSpecNoAutostart") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") println(spec) diff --git a/src/sbt-test/rpm/systemd-rpm/test b/src/sbt-test/rpm/systemd-rpm/test index 120ba89c6..a470af8f9 100644 --- a/src/sbt-test/rpm/systemd-rpm/test +++ b/src/sbt-test/rpm/systemd-rpm/test @@ -8,7 +8,7 @@ $ exists usr/lib/systemd/system/rpm-test.service > checkStartupScript > checkSpecFile -> check-spec-autostart +> checkSpecAutostart # test that autostart can be disabled @@ -16,4 +16,4 @@ $ exists usr/lib/systemd/system/rpm-test.service > set every NativePackagerKeys.serviceAutostart := false > rpm:packageBin > checkSpecFile -> check-spec-no-autostart +> checkSpecNoAutostart diff --git a/src/sbt-test/rpm/sysvinit-rpm/build.sbt b/src/sbt-test/rpm/sysvinit-rpm/build.sbt index 4fa9fc80b..2b58ab488 100644 --- a/src/sbt-test/rpm/sysvinit-rpm/build.sbt +++ b/src/sbt-test/rpm/sysvinit-rpm/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemVPlugin) name := "rpm-test" @@ -18,8 +20,8 @@ mainClass in (Compile, run) := Some("com.example.MainApp") TaskKey[Unit]("unzipAndCheck") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log - val scriptlets = Process("rpm -qp --scripts " + (packageBin in Rpm).value.getAbsolutePath) !! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log + val scriptlets = sys.process.Process("rpm -qp --scripts " + (packageBin in Rpm).value.getAbsolutePath) !! streams.value.log assert(scriptlets contains "addGroup rpm-test", "addGroup not present in \n" + scriptlets) assert(scriptlets contains "addUser rpm-test", "Incorrect useradd command in \n" + scriptlets) assert(scriptlets contains "deleteGroup rpm-test", "deleteGroup not present in \n" + scriptlets) @@ -44,7 +46,7 @@ TaskKey[Unit]("unzipAndCheck") := { () } -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert(spec contains "addGroup rpm-test", "addGroup not present in \n" + spec) assert(spec contains "addUser rpm-test", "Incorrect useradd command in \n" + spec) @@ -144,7 +146,7 @@ TaskKey[Unit]("check-spec-file") := { () } -TaskKey[Unit]("check-spec-autostart") := { +TaskKey[Unit]("checkSpecAutostart") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert( spec contains @@ -163,7 +165,7 @@ TaskKey[Unit]("check-spec-autostart") := { () } -TaskKey[Unit]("check-spec-no-autostart") := { +TaskKey[Unit]("checkSpecNoAutostart") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert( spec contains diff --git a/src/sbt-test/rpm/sysvinit-rpm/test b/src/sbt-test/rpm/sysvinit-rpm/test index a8321338e..173691dd1 100644 --- a/src/sbt-test/rpm/sysvinit-rpm/test +++ b/src/sbt-test/rpm/sysvinit-rpm/test @@ -1,9 +1,9 @@ # Run the rpm packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm -> check-spec-file -> check-spec-autostart +> checkSpecFile +> checkSpecAutostart # Check rpm contents > unzipAndCheck @@ -24,12 +24,12 @@ $ exists var/run/rpm-test # TODO symlinks aren't checked > set NativePackagerKeys.rpmBrpJavaRepackJars := false -> check-spec-file -> check-spec-autostart +> checkSpecFile +> checkSpecAutostart # Test that serviceAutostart can be disabled > set every NativePackagerKeys.serviceAutostart := false -> rpm:package-bin -> check-spec-file -> check-spec-no-autostart \ No newline at end of file +> rpm:packageBin +> checkSpecFile +> checkSpecNoAutostart \ No newline at end of file diff --git a/src/sbt-test/rpm/test-executableScriptName/build.sbt b/src/sbt-test/rpm/test-executableScriptName/build.sbt index f733dde89..835ffa061 100644 --- a/src/sbt-test/rpm/test-executableScriptName/build.sbt +++ b/src/sbt-test/rpm/test-executableScriptName/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaServerAppPackaging, SystemVPlugin) name := "rpm-test" @@ -23,7 +25,7 @@ rpmLicense := Some("BSD") rpmGroup := Some("test-group") -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec") assert( spec contains "%attr(0644,root,root) /usr/share/rpm-test/lib/rpm-test.rpm-test-0.1.0.jar", @@ -39,7 +41,7 @@ TaskKey[Unit]("check-spec-file") := { TaskKey[Unit]("unzip") := { val rpmPath = Seq((packageBin in Rpm).value.getAbsolutePath) - Process("rpm2cpio", rpmPath) #| Process("cpio -i --make-directories") ! streams.value.log + sys.process.Process("rpm2cpio", rpmPath) #| sys.process.Process("cpio -i --make-directories") ! streams.value.log () } diff --git a/src/sbt-test/rpm/test-executableScriptName/test b/src/sbt-test/rpm/test-executableScriptName/test index fca66983e..0308344d4 100644 --- a/src/sbt-test/rpm/test-executableScriptName/test +++ b/src/sbt-test/rpm/test-executableScriptName/test @@ -1,10 +1,10 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm $ exists target/rpm/SPECS/rpm-test.spec # Check files for defaults -> check-spec-file +> checkSpecFile > unzip # Bootscript != executable Script diff --git a/src/sbt-test/rpm/test-packageName/build.sbt b/src/sbt-test/rpm/test-packageName/build.sbt index a5a15ceb3..98244de29 100644 --- a/src/sbt-test/rpm/test-packageName/build.sbt +++ b/src/sbt-test/rpm/test-packageName/build.sbt @@ -21,7 +21,7 @@ rpmUrl := Some("http://github.com/sbt/sbt-native-packager") rpmLicense := Some("BSD") -TaskKey[Unit]("check-spec-file") := { +TaskKey[Unit]("checkSpecFile") := { val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-package.spec") streams.value.log.success(spec) assert( diff --git a/src/sbt-test/rpm/test-packageName/test b/src/sbt-test/rpm/test-packageName/test index a4f4caa85..d2c7680c8 100644 --- a/src/sbt-test/rpm/test-packageName/test +++ b/src/sbt-test/rpm/test-packageName/test @@ -1,7 +1,7 @@ # Run the debian packaging. -> rpm:package-bin +> rpm:packageBin $ exists target/rpm/RPMS/noarch/rpm-package-0.1.0-1.noarch.rpm $ exists target/rpm/SPECS/rpm-package.spec # Check files for defaults -> check-spec-file +> checkSpecFile diff --git a/src/sbt-test/universal/absolute-path/build.sbt b/src/sbt-test/universal/absolute-path/build.sbt index 990a80bc6..f3b4c83c9 100644 --- a/src/sbt-test/universal/absolute-path/build.sbt +++ b/src/sbt-test/universal/absolute-path/build.sbt @@ -8,7 +8,7 @@ scriptClasspath in bashScriptDefines ++= Seq("/dummy/absolute/path", "relative/p scriptClasspath in batScriptReplacements ++= Seq("x:\\dummy\\absolute\\path", "relative\\path") -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("check") := { val dir = (stagingDirectory in Universal).value val bash = IO.read(dir / "bin" / "absolute-path") diff --git a/src/sbt-test/universal/absolute-path/test b/src/sbt-test/universal/absolute-path/test index 877989c06..68964d7c7 100644 --- a/src/sbt-test/universal/absolute-path/test +++ b/src/sbt-test/universal/absolute-path/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check \ No newline at end of file +> check \ No newline at end of file diff --git a/src/sbt-test/universal/multiproject-classifiers/build.sbt b/src/sbt-test/universal/multiproject-classifiers/build.sbt new file mode 100644 index 000000000..9d8c42d88 --- /dev/null +++ b/src/sbt-test/universal/multiproject-classifiers/build.sbt @@ -0,0 +1,44 @@ +import com.typesafe.sbt.packager.Compat._ + +lazy val appVersion = "1.0" + +lazy val mySettings: Seq[Setting[_]] = + Seq(organization := "org.test", version := appVersion, TaskKey[Unit]("showFiles") := { + System.out.synchronized { + println("Files in [" + name.value + "]") + val files = (target.value / "universal/stage").**(AllPassFilter).get + files foreach println + } + }) + +lazy val Assets = config("assets") + +lazy val sub = project + .in(file("sub")) + .enablePlugins(JavaAppPackaging) + .settings(mySettings) + .settings( + ivyConfigurations += Assets, + artifact in Assets := artifact.value.withClassifier(classifier = Some("assets")), + packagedArtifacts += { + val file = target.value / "assets.jar" + val assetsDir = baseDirectory.value / "src" / "main" / "assets" + val sources = assetsDir.**(AllPassFilter).filter(_.isFile) pair (file => IO.relativize(assetsDir, file)) + IO.zip(sources, file) + (artifact in Assets).value -> file + }, + exportedProducts in Assets := { + Seq( + Attributed + .blank(baseDirectory.value / "src" / "main" / "assets") + .put(artifact.key, (artifact in Assets).value) + .put(AttributeKey[ModuleID]("module-id"), projectID.value) + ) + } + ) + +lazy val root = project + .in(file(".")) + .enablePlugins(JavaAppPackaging) + .settings(mySettings) + .dependsOn(sub % "compile->compile;compile->assets") diff --git a/src/sbt-test/universal/multiproject-classifiers/project/Build.scala b/src/sbt-test/universal/multiproject-classifiers/project/Build.scala deleted file mode 100644 index 7dd296f0e..000000000 --- a/src/sbt-test/universal/multiproject-classifiers/project/Build.scala +++ /dev/null @@ -1,53 +0,0 @@ -import sbt._ -import Keys._ -import com.typesafe.sbt.SbtNativePackager._ -import com.typesafe.sbt.packager.Keys._ - -// FIXME replace Build with AutoPlugin -object MutliBuild extends Build { - - val appVersion = "1.0" - - val mySettings: Seq[Setting[_]] = - packageArchetype.java_application ++ - Seq(organization := "org.test", version := appVersion, TaskKey[Unit]("show-files") := { - System.out.synchronized { - println("Files in [" + name.value + "]") - val files = (target.value / "universal/stage").***.get - files foreach println - } - }) - - val assets = config("assets") - - lazy val sub = ( - Project("sub", file("sub")) - settings (mySettings: _*) - settings ( - ivyConfigurations += assets, - artifact in assets := artifact.value.copy(classifier = Some("assets")), - packagedArtifacts += { - val file = target.value / "assets.jar" - val assetsDir = baseDirectory.value / "src" / "main" / "assets" - val sources = assetsDir.***.filter(_.isFile) pair relativeTo(assetsDir) - IO.zip(sources, file) - (artifact in assets).value -> file - }, - exportedProducts in assets := { - Seq( - Attributed - .blank(baseDirectory.value / "src" / "main" / "assets") - .put(artifact.key, (artifact in assets).value) - .put(AttributeKey[ModuleID]("module-id"), projectID.value) - ) - } - ) - ) - - lazy val root = ( - Project("root", file(".")) - settings (mySettings: _*) - dependsOn (sub % "compile->compile;compile->assets") - ) - -} diff --git a/src/sbt-test/universal/multiproject-classifiers/test b/src/sbt-test/universal/multiproject-classifiers/test index 9854319b2..c47a0712e 100644 --- a/src/sbt-test/universal/multiproject-classifiers/test +++ b/src/sbt-test/universal/multiproject-classifiers/test @@ -1,5 +1,5 @@ # Run the staging and check the script. > stage -> show-files +> showFiles $ exists target/universal/stage/lib/org.test.sub-1.0.jar $ exists target/universal/stage/lib/org.test.sub-1.0-assets.jar diff --git a/src/sbt-test/universal/multiproject-java-app-archetype/project/Build.scala b/src/sbt-test/universal/multiproject-java-app-archetype/project/Build.scala deleted file mode 100644 index 87aa52f41..000000000 --- a/src/sbt-test/universal/multiproject-java-app-archetype/project/Build.scala +++ /dev/null @@ -1,45 +0,0 @@ -import sbt._ -import Keys._ -import com.typesafe.sbt.SbtNativePackager._ - -// FIXME replace Build with AutoPlugin -object MutliBuild extends Build { - - val appName = "play-bug-1499" - val appVersion = "1.0" - - val mySettings: Seq[Setting[_]] = - packageArchetype.java_application ++ - Seq(organization := "org.test", version := appVersion, TaskKey[Unit]("show-files") := { - System.out.synchronized { - println("Files in [" + name.value + "]") - val files = (target.value / "universal/stage").***.get - files foreach println - } - }) - - lazy val common = ( - Project(appName + "-common", file("module/common")) - settings (mySettings: _*) - ) - - lazy val foo = ( - Project(appName + "-foo", file("module/foo")) - settings (mySettings: _*) - dependsOn (common) - ) - - lazy val bar = ( - Project(appName + "-bar", file("module/bar")) - settings (mySettings: _*) - dependsOn (common) - ) - - lazy val aaMain = ( - Project(appName + "-main", file(".")) - settings (mySettings: _*) - dependsOn (common, foo, bar) - aggregate (foo, bar) - ) - -} diff --git a/src/sbt-test/universal/multiproject-java-app-archetype/project/plugins.sbt b/src/sbt-test/universal/multiproject-java-app-archetype/project/plugins.sbt deleted file mode 100644 index b53de154c..000000000 --- a/src/sbt-test/universal/multiproject-java-app-archetype/project/plugins.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) diff --git a/src/sbt-test/universal/multiproject-java-app-archetype/test b/src/sbt-test/universal/multiproject-java-app-archetype/test deleted file mode 100644 index e62a87154..000000000 --- a/src/sbt-test/universal/multiproject-java-app-archetype/test +++ /dev/null @@ -1,7 +0,0 @@ -# Run the staging and check the script. -> stage -> show-files -$ exists target/universal/stage/lib/org.test.play-bug-1499-foo-1.0.jar -$ exists target/universal/stage/lib/org.test.play-bug-1499-common-1.0.jar -$ exists target/universal/stage/lib/org.test.play-bug-1499-bar-1.0.jar -$ exists target/universal/stage/lib/org.test.play-bug-1499-main-1.0.jar \ No newline at end of file diff --git a/src/sbt-test/universal/publish/build.sbt b/src/sbt-test/universal/publish/build.sbt index 57388a01e..e0e838b6b 100644 --- a/src/sbt-test/universal/publish/build.sbt +++ b/src/sbt-test/universal/publish/build.sbt @@ -4,9 +4,10 @@ name := "simple-test" version := "0.1.0" -// Workarund for ivy configuration bug -resolvers += (publishTo in Universal).value.get - -publishTo in Universal := Some( +lazy val testResolver = Resolver.file("test", file("test-repo"))(Patterns("[module]/[revision]/[module]-[revision].[ext]")) -) + +// Workaround for ivy configuration bug +resolvers += testResolver + +publishTo in Universal := Some(testResolver) diff --git a/src/sbt-test/universal/staging-custom-main/build.sbt b/src/sbt-test/universal/staging-custom-main/build.sbt index 4d5f3359e..fe191717c 100644 --- a/src/sbt-test/universal/staging-custom-main/build.sbt +++ b/src/sbt-test/universal/staging-custom-main/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "stage-custom-main" @@ -8,12 +10,12 @@ mainClass in Compile := Some("Main") TaskKey[Unit]("unzip") := { val args = Seq((packageBin in Universal).value.getAbsolutePath) - Process("unzip", args) ! streams.value.log + sys.process.Process("unzip", args) ! streams.value.log } TaskKey[Unit]("check") := { val zipFile = (packageBin in Universal).value - val process = sbt.Process("stage-custom-main-0.1.0/bin/stage-custom-main", Seq("-main", "CustomMain")) + val process = sys.process.Process("stage-custom-main-0.1.0/bin/stage-custom-main", Seq("-main", "CustomMain")) val out = (process !!) if (out.trim != "A custom main method") sys.error("unexpected output: " + out) () diff --git a/src/sbt-test/universal/staging-custom-main/test b/src/sbt-test/universal/staging-custom-main/test index 79e8a783b..59ec0b5c5 100644 --- a/src/sbt-test/universal/staging-custom-main/test +++ b/src/sbt-test/universal/staging-custom-main/test @@ -1,5 +1,5 @@ # Stage the distribution and ensure main class can be run. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/stage-custom-main-0.1.0.zip > unzip $ exists stage-custom-main-0.1.0/bin/ diff --git a/src/sbt-test/universal/test-executableScriptName/build.sbt b/src/sbt-test/universal/test-executableScriptName/build.sbt index 5d5cb873a..8156c400a 100644 --- a/src/sbt-test/universal/test-executableScriptName/build.sbt +++ b/src/sbt-test/universal/test-executableScriptName/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "simple-test" @@ -8,5 +10,5 @@ version := "0.1.0" TaskKey[Unit]("unzip") := { val args = Seq((packageBin in Universal).value.getAbsolutePath) - Process("unzip", args) ! streams.value.log + sys.process.Process("unzip", args) ! streams.value.log } diff --git a/src/sbt-test/universal/test-executableScriptName/test b/src/sbt-test/universal/test-executableScriptName/test index f0589c769..dd820a7c9 100644 --- a/src/sbt-test/universal/test-executableScriptName/test +++ b/src/sbt-test/universal/test-executableScriptName/test @@ -1,5 +1,5 @@ # Run the zip packaging. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/simple-test-0.1.0.zip > unzip $ exists simple-test-0.1.0/bin/ diff --git a/src/sbt-test/universal/test-mapping-helpers/build.sbt b/src/sbt-test/universal/test-mapping-helpers/build.sbt index 12af5bd4e..1515cf4af 100644 --- a/src/sbt-test/universal/test-mapping-helpers/build.sbt +++ b/src/sbt-test/universal/test-mapping-helpers/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + import com.typesafe.sbt.packager.MappingsHelper._ enablePlugins(JavaAppPackaging) @@ -22,5 +24,5 @@ mappings in Universal += { TaskKey[Unit]("unzip") := { val args = Seq((packageBin in Universal).value.getAbsolutePath) - Process("unzip", args) ! streams.value.log + sys.process.Process("unzip", args) ! streams.value.log } diff --git a/src/sbt-test/universal/test-mapping-helpers/test b/src/sbt-test/universal/test-mapping-helpers/test index f6cfad758..3eaa5da82 100644 --- a/src/sbt-test/universal/test-mapping-helpers/test +++ b/src/sbt-test/universal/test-mapping-helpers/test @@ -1,5 +1,5 @@ # Run the universal packaging. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/simple-test-0.1.0.zip > unzip diff --git a/src/sbt-test/universal/test-native-zip/test b/src/sbt-test/universal/test-native-zip/test index d3f226f48..137147654 100644 --- a/src/sbt-test/universal/test-native-zip/test +++ b/src/sbt-test/universal/test-native-zip/test @@ -1,5 +1,5 @@ # Run the zip packaging. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/simple-test-0.1.0.zip # TODO - Check contents of zips. Ensure file permissions are preserved. diff --git a/src/sbt-test/universal/test-packageName/test b/src/sbt-test/universal/test-packageName/test index 27165bada..7c21d6604 100644 --- a/src/sbt-test/universal/test-packageName/test +++ b/src/sbt-test/universal/test-packageName/test @@ -1,11 +1,11 @@ # Run the zip packaging. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/simple-package.zip # Run the tgz packaging. -> universal:package-zip-tarball +> universal:packageZipTarball $ exists target/universal/simple-package.tgz # Run the txz packaging. -> universal:package-xz-tarball +> universal:packageXzTarball $ exists target/universal/simple-package.txz \ No newline at end of file diff --git a/src/sbt-test/universal/test-zips-no-top-level-dir/test b/src/sbt-test/universal/test-zips-no-top-level-dir/test index 72fdb39de..2dd300104 100644 --- a/src/sbt-test/universal/test-zips-no-top-level-dir/test +++ b/src/sbt-test/universal/test-zips-no-top-level-dir/test @@ -1,13 +1,13 @@ # Run the zip packaging. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/simple-test-0.1.0.zip # Run the tgz packaging. -> universal:package-zip-tarball +> universal:packageZipTarball $ exists target/universal/simple-test-0.1.0.tgz # Run the txz packaging. -> universal:package-xz-tarball +> universal:packageXzTarball $ exists target/universal/simple-test-0.1.0.txz diff --git a/src/sbt-test/universal/test-zips/test b/src/sbt-test/universal/test-zips/test index 1de8871ad..cd0caebb5 100644 --- a/src/sbt-test/universal/test-zips/test +++ b/src/sbt-test/universal/test-zips/test @@ -1,17 +1,17 @@ # Run the zip packaging. -> show universal:package-bin +> show universal:packageBin $ exists target/universal/simple-test-0.1.0.zip -> universal-docs:package-bin +> universal-docs:packageBin $ exists target/universal-docs/simple-test-0.1.0.zip -> universal-src:package-bin +> universal-src:packageBin $ exists target/universal-src/simple-test-0.1.0.zip # Run the tgz packaging. -> universal:package-zip-tarball +> universal:packageZipTarball $ exists target/universal/simple-test-0.1.0.tgz # Run the txz packaging. -> universal:package-xz-tarball +> universal:packageXzTarball $ exists target/universal/simple-test-0.1.0.txz diff --git a/src/sbt-test/windows/absolute-path-in-bat/build.sbt b/src/sbt-test/windows/absolute-path-in-bat/build.sbt index 12d06b2f1..a7ccbf37d 100644 --- a/src/sbt-test/windows/absolute-path-in-bat/build.sbt +++ b/src/sbt-test/windows/absolute-path-in-bat/build.sbt @@ -6,7 +6,7 @@ version := "0.1.0" scriptClasspath in batScriptReplacements ++= Seq("x:\\dummy\\absolute\\path", "relative\\path") -TaskKey[Unit]("run-check") := { +TaskKey[Unit]("runCheck") := { val dir = (stagingDirectory in Universal).value val bat = IO.read(dir / "bin" / "absolute-path-in-bat.bat") diff --git a/src/sbt-test/windows/absolute-path-in-bat/test b/src/sbt-test/windows/absolute-path-in-bat/test index 877989c06..61dad9b64 100644 --- a/src/sbt-test/windows/absolute-path-in-bat/test +++ b/src/sbt-test/windows/absolute-path-in-bat/test @@ -1,3 +1,3 @@ # Run the staging and check the script. > stage -> run-check \ No newline at end of file +> runCheck \ No newline at end of file diff --git a/src/sbt-test/windows/java-app-archetype/build.sbt b/src/sbt-test/windows/java-app-archetype/build.sbt index 15d26b195..b5b744ed1 100644 --- a/src/sbt-test/windows/java-app-archetype/build.sbt +++ b/src/sbt-test/windows/java-app-archetype/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "windows-test" @@ -14,16 +16,16 @@ wixProductId := "ce07be71-510d-414a-92d4-dff47631848a" wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424" -TaskKey[Unit]("check-script") := { +TaskKey[Unit]("checkScript") := { val script = (stagingDirectory in Universal).value / "bin" / (name.value + ".bat") val cmd = Seq("cmd", "/c", script.getAbsolutePath) val result = - Process(cmd) ! streams.value.log match { + sys.process.Process(cmd) ! streams.value.log match { case 0 => () case n => sys.error("Failed to run script: " + script.getAbsolutePath + " error code: " + n) } - val output = Process(cmd).!! + val output = sys.process.Process(cmd).!! val expected = "SUCCESS!" assert( output contains expected, diff --git a/src/sbt-test/windows/java-app-archetype/test b/src/sbt-test/windows/java-app-archetype/test index 7ad000daa..4f750d82e 100644 --- a/src/sbt-test/windows/java-app-archetype/test +++ b/src/sbt-test/windows/java-app-archetype/test @@ -1,6 +1,6 @@ # Run the windows packaging. -> windows:package-bin +> windows:packageBin $ exists target/windows/windows-test.msi > stage $ exists target/universal/stage/bin/windows-test.bat -> check-script +> checkScript diff --git a/src/sbt-test/windows/multiple-apps/build.sbt b/src/sbt-test/windows/multiple-apps/build.sbt index 2648b8a49..cbd61b2fc 100644 --- a/src/sbt-test/windows/multiple-apps/build.sbt +++ b/src/sbt-test/windows/multiple-apps/build.sbt @@ -1,32 +1,34 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "test-project" version := "0.1.0" -TaskKey[Unit]("check-no-explicit-main") := { +TaskKey[Unit]("checkNoExplicitMain") := { val cwd = (stagingDirectory in Universal).value // check MainApp val cmd = Seq((cwd / "bin" / "main-app.bat").getAbsolutePath) - val output = Process(cmd, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") + val output = sys.process.Process(cmd, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") assert(output == "MainApp", s"Output wasn't 'MainApp', but '$output'") // check SecondApp val cmdSecond = Seq((cwd / "bin" / "second-app.bat").getAbsolutePath) - val outputSecond = Process(cmdSecond, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") + val outputSecond = sys.process.Process(cmdSecond, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") assert(outputSecond == "SecondApp", s"Output wasn't 'SecondApp': '$outputSecond'") } -TaskKey[Unit]("check-explicit-main") := { +TaskKey[Unit]("checkExplicitMain") := { val cwd = (stagingDirectory in Universal).value // check default start script val cmd = Seq((cwd / "bin" / s"${executableScriptName.value}.bat").getAbsolutePath) - val output = Process(cmd, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") + val output = sys.process.Process(cmd, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") assert(output == "MainApp", s"Output wasn't 'MainApp', but '$output'") // check SecondApp val cmdSecond = Seq((cwd / "bin" / "second-app.bat").getAbsolutePath) - val outputSecond = Process(cmdSecond, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") + val outputSecond = sys.process.Process(cmdSecond, cwd).!!.replaceAll("\n", "").replaceAll("\r", "") assert(outputSecond == "SecondApp", s"Output wasn't 'SecondApp', but '$outputSecond'") } diff --git a/src/sbt-test/windows/multiple-apps/test b/src/sbt-test/windows/multiple-apps/test index bb4715e6c..e47f8e132 100644 --- a/src/sbt-test/windows/multiple-apps/test +++ b/src/sbt-test/windows/multiple-apps/test @@ -2,10 +2,10 @@ > stage $ exists target/universal/stage/bin/main-app.bat $ exists target/universal/stage/bin/second-app.bat -> check-no-explicit-main +> checkNoExplicitMain > clean > set mainClass in Compile := Some("com.example.MainApp") > stage $ exists target/universal/stage/bin/test-project.bat $ exists target/universal/stage/bin/second-app.bat -> check-explicit-main \ No newline at end of file +> checkExplicitMain \ No newline at end of file diff --git a/src/sbt-test/windows/test-bat-template/build.sbt b/src/sbt-test/windows/test-bat-template/build.sbt index 3bb3f02bb..339021ec8 100644 --- a/src/sbt-test/windows/test-bat-template/build.sbt +++ b/src/sbt-test/windows/test-bat-template/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "windows-test" @@ -33,7 +35,7 @@ batScriptExtraDefines += "exit /B" batScriptExtraDefines += ":print_args_end" -TaskKey[Unit]("check-script") := { +TaskKey[Unit]("checkScript") := { val dir = (stagingDirectory in Universal).value import scala.sys.process._ val fails = new StringBuilder() @@ -54,7 +56,7 @@ TaskKey[Unit]("check-script") := { val pr = new StringBuilder() val logger = ProcessLogger((o: String) => pr.append(o + "\n"), (e: String) => pr.append("error < " + e + "\n")) val cmd = Seq("cmd", "/c", script.getAbsolutePath + " " + args) - val result = Process(cmd, None, env.toSeq: _*) ! logger + val result = sys.process.Process(cmd, None, env.toSeq: _*) ! logger if (result != expectedRC) { pr.append("error code: " + result + "\n") } @@ -76,7 +78,7 @@ TaskKey[Unit]("check-script") := { fails.append(crlf2cr(pr.toString) + "\n") fails.append("\n--detail-------------------------------\n") pr.clear - Process(Seq("cmd", "/c", detailScript.getAbsolutePath + " " + args), None, env.toSeq: _*) ! logger + sys.process.Process(Seq("cmd", "/c", detailScript.getAbsolutePath + " " + args), None, env.toSeq: _*) ! logger fails.append(crlf2cr(pr.toString) + "\n") } if (debugOutFile.exists) { diff --git a/src/sbt-test/windows/test-bat-template/test b/src/sbt-test/windows/test-bat-template/test index 5d5185949..faaa3ec4b 100644 --- a/src/sbt-test/windows/test-bat-template/test +++ b/src/sbt-test/windows/test-bat-template/test @@ -1,4 +1,4 @@ # Run the windows batch. > stage $ exists target/universal/stage/bin/windows-test.bat -> check-script +> checkScript diff --git a/src/sbt-test/windows/test-custom-main/build.sbt b/src/sbt-test/windows/test-custom-main/build.sbt index 71f41098c..9797baa3f 100644 --- a/src/sbt-test/windows/test-custom-main/build.sbt +++ b/src/sbt-test/windows/test-custom-main/build.sbt @@ -1,3 +1,5 @@ +import com.typesafe.sbt.packager.Compat._ + enablePlugins(JavaAppPackaging) name := "test-custom-main" @@ -6,19 +8,19 @@ version := "0.1.0" mainClass in Compile := Some("Main") -TaskKey[Unit]("check-app-main") := { +TaskKey[Unit]("checkAppMain") := { val zipFile = (packageBin in Universal).value val process = - sbt.Process("target/universal/stage/bin/test-custom-main.bat") + sys.process.Process("target/universal/stage/bin/test-custom-main.bat") val out = (process !!) if (out.trim != "App Main Method") error("unexpected output: " + out) () } -TaskKey[Unit]("check-custom-main") := { +TaskKey[Unit]("checkCustomMain") := { val zipFile = (packageBin in Universal).value val process = - sbt.Process("target/universal/stage/bin/test-custom-main.bat", Seq("-main", "CustomMain")) + sys.process.Process("target/universal/stage/bin/test-custom-main.bat", Seq("-main", "CustomMain")) val out = (process !!) if (out.trim != "Custom Main Method") error("unexpected output: " + out) () diff --git a/src/sbt-test/windows/test-custom-main/test b/src/sbt-test/windows/test-custom-main/test index e5b91b2fe..3e67cf9e7 100644 --- a/src/sbt-test/windows/test-custom-main/test +++ b/src/sbt-test/windows/test-custom-main/test @@ -2,6 +2,6 @@ > stage $ exists target/universal/stage/bin/ $ exists target/universal/stage/bin/test-custom-main.bat -> check-app-main -> check-custom-main +> checkAppMain +> checkCustomMain diff --git a/version.sbt b/version.sbt index f318f440f..b4bf19689 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "1.2.2-SNAPSHOT" \ No newline at end of file +version in ThisBuild := "1.2.2-SNAPSHOT"