Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross build with sbt 1.0 #1000

Merged
merged 47 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2853b98
Cross build with sbt 1.0
muuki88 Jun 17, 2017
78b97ad
Fix travis.yml
muuki88 Jun 24, 2017
3fdb0d6
Fix Build.scala scripted tests
muuki88 Jun 24, 2017
fcf08b8
Remove 'provided' scope for jdeb temporarily
muuki88 Jun 24, 2017
db68a33
Fix dependencies for scripted tests
muuki88 Jun 24, 2017
507694c
Fix scripted test calls by using packageBin instead of package-bin
muuki88 Jun 24, 2017
a43c3eb
Fix multiproject-classifiers test by using new `withClassifier` method.
muuki88 Jul 1, 2017
85b2c12
Replace all *** PathFilter calls in scripted tests
muuki88 Jul 1, 2017
e38eaf2
Replace Process with sys.process.Process and add Compat.io import
muuki88 Jul 9, 2017
6c4ee4f
Fixing all remaining scripted tests
muuki88 Jul 9, 2017
c52a67d
Fix jdk-packager script tests
muuki88 Jul 9, 2017
40ddcdb
Fix travis osx oraclejdk8 issue: travis-ci/travis-ci/issues/2316
muuki88 Jul 9, 2017
36e756d
Reduce travis ci test matrix
muuki88 Jul 10, 2017
4163bf0
Update out-dated akka dependency in scripted test
muuki88 Jul 10, 2017
ef2c512
Replace akka with typesafe config as a dependency test
muuki88 Jul 11, 2017
cbb412b
Fix wrong task names
muuki88 Jul 12, 2017
51d0b23
Replace akka with typesafe config as a dependency test
muuki88 Jul 12, 2017
abc5590
Polyfill new method `withClassifier` on sbt.Artifact
muuki88 Jul 12, 2017
e3cc742
Remove jdk definition
muuki88 Jul 12, 2017
4dfcbc5
List every test setup explicitly for travis
muuki88 Jul 12, 2017
b5c528a
Also set env for the osx build
muuki88 Jul 12, 2017
5767bcf
Only use java8 for testing and output scripted buffer
muuki88 Jul 12, 2017
ef89e31
Another approach for travis
muuki88 Jul 16, 2017
d9ffbaa
Fix rpm scripted tests
muuki88 Jul 17, 2017
209e7b8
Rebase and fix newly added test
muuki88 Jul 17, 2017
b0516b1
Fix debian scripted tests
muuki88 Jul 17, 2017
61869e0
Run only the script docker tests which don't require docker
muuki88 Jul 17, 2017
bad8d19
Fix validateJdkPackager and actually run the jdkpackacker scripts
muuki88 Jul 17, 2017
1b2b692
Explicitly include all the different envs in travis
muuki88 Jul 17, 2017
0876ed5
Remove jdkpackager/test-package-image scripted test on travis
muuki88 Jul 18, 2017
79a53b8
Upgrade to sbt-1.0.0-RC2 and use crossbuil
muuki88 Jul 18, 2017
46c6f2d
Go back to M6 and switch-case the provided dependencies
muuki88 Jul 19, 2017
37657f6
Run actual tests on MacOS X
muuki88 Jul 19, 2017
4c7e4bf
use sbtVersion in pluginCrossBuild and downgrade to sbt-io M11
muuki88 Jul 22, 2017
0d1934a
Fix scripted camelCase jdkpackager
muuki88 Jul 22, 2017
441fb67
Try to upgrade to 1.0.0-RC2
muuki88 Jul 24, 2017
65622f3
Build with 0.13.16
muuki88 Jul 27, 2017
558ea28
Upgrade sbt-io
muuki88 Jul 28, 2017
a7cc3e8
Fix linting error for ivy configs
muuki88 Jul 29, 2017
0dc9c58
Upgrade to 1.0.0-RC3
muuki88 Jul 29, 2017
8dc7fbf
Fix jar names in JavaAppPackaging. See sbt/sbt/issues/3388
muuki88 Aug 5, 2017
38b27b8
Formatting SettingsHelper
muuki88 Aug 6, 2017
88233b3
Adding the correct moduleSettings
muuki88 Aug 6, 2017
748d3af
Upgrade scalafmt
muuki88 Aug 7, 2017
fb70c56
Upgrade sbt-release process
muuki88 Aug 7, 2017
a9816c1
Setting version to 1.2.2-RC1
muuki88 Aug 7, 2017
2c01581
Setting version to 1.2.2-SNAPSHOT
muuki88 Aug 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
- [email protected]
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:
Expand Down
82 changes: 70 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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/*")
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.15
sbt.version=0.13.16
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
46 changes: 46 additions & 0 deletions src/main/scala-sbt-0.13/com/typesafe/sbt/packager/Compat.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.typesafe.sbt
package packager
package com.typesafe.sbt.packager

import sbt._
import sbt.Keys._
import sbt._

object SettingsHelper {

Expand Down
39 changes: 39 additions & 0 deletions src/main/scala-sbt-1.0/com/typesafe/sbt/packager/Compat.scala
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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}"
}

}
Loading