-
Notifications
You must be signed in to change notification settings - Fork 23
Prevent native packager bin-compat issues #169
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017 Lightbend, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.lightbend.rp.sbtreactiveapp | ||
|
||
import com.typesafe.sbt.packager.docker.DockerAlias | ||
|
||
/** | ||
* `sbt-native-packager` is not SemVer compliant and classes like `DockerAlias` break binary compatibility | ||
* in patch releases. This object provides makes all 1.3.x versions of `sbt-native-packager` compatible. | ||
*/ | ||
object NativePackagerCompat { | ||
|
||
// removed from `sbt-native-packager` (https://github.com/sbt/sbt-native-packager/pull/1138/files#diff-6aa67d5df515952c884df8bad5ff2ac4L12) | ||
def untagged(dockerAlias: DockerAlias): String = | ||
dockerAlias.registryHost.map(_ + "/").getOrElse("") + | ||
dockerAlias.username.map(_ + "/").getOrElse("") + dockerAlias.name | ||
|
||
// removed from `sbt-native-packager` (https://github.com/sbt/sbt-native-packager/pull/1138/files#diff-6aa67d5df515952c884df8bad5ff2ac4L12) | ||
def versioned(dockerAlias: DockerAlias): String = { | ||
untagged(dockerAlias) + dockerAlias.tag.map(":" + _).getOrElse("") | ||
} | ||
|
||
// removed from `sbt-native-packager` (https://github.com/sbt/sbt-native-packager/pull/1138/files#diff-6aa67d5df515952c884df8bad5ff2ac4L12) | ||
def latest(dockerAlias: DockerAlias) = s"${untagged(dockerAlias)}:latest" | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ package com.lightbend.rp.sbtreactiveapp | |
import com.typesafe.sbt.packager.Keys._ | ||
import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin | ||
import com.typesafe.sbt.packager.docker | ||
import com.typesafe.sbt.packager.docker.DockerKeys | ||
import sbt.{ Def, _ } | ||
import sbt.Keys._ | ||
import sbt.plugins.JvmPlugin | ||
|
@@ -92,7 +93,7 @@ object SbtReactiveAppPlugin extends AutoPlugin { | |
} | ||
} | ||
|
||
object localImport extends docker.DockerKeys | ||
val localImport: DockerKeys = docker.DockerPlugin.autoImport | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the original change. The breaking changes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
override def requires = SbtReactiveAppPluginAll && docker.DockerPlugin && BashStartScriptPlugin && SbtReactiveAppPluginAll | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package controllers | ||
|
||
import javax.inject._ | ||
import play.api._ | ||
import play.api.mvc._ | ||
|
||
@Singleton | ||
class HelloController @Inject() (cc: ControllerComponents) extends AbstractController(cc) { | ||
def index() = Action { _ => | ||
Ok("Hello, World") | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This scripted test is a copy/paste/trim version of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just update play-endpoints to Play 2.6.21 and keep this one minimal to the plugin conflict? Also, maybe rename this test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah users should be able to always upgrade to latest bugfix version, in this case of Play and sbt-reactive-app. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name := "hello-play" | ||
scalaVersion := "2.11.12" | ||
|
||
libraryDependencies += guice | ||
|
||
lazy val root = (project in file(".")) | ||
.enablePlugins(PlayScala, SbtReactiveAppPlugin) | ||
.settings( | ||
packageName in Docker := "hello-play", | ||
httpIngressPorts := Seq(9000), | ||
httpIngressPaths := Seq("/") | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
play.crypto.secret = whatever |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GET / controllers.HelloController.index |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.lightbend.rp" % "sbt-reactive-app" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} | ||
|
||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.21") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This test only checks `sbt` runs successfuly. | ||
# Since Play 2.6.21 there's a dependency issue between Play's sbt-plugin and sbt-reactive-app where both bring in | ||
dwijnand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# incompatible versions of sbt-native-packager. Just starting `sbt` is enough to assert the fixes for compat work. | ||
|
||
> about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change in the PR. There's no automated test for it, unfortunately. The issue manifests when running
deploy minikube
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the part that sbt-native-packager participate in
deploy minikube
is just image creation, can we reproduce this by callingDocker/stage
from the scripted test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you probably need
Docker/publish
to exercise alias.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good call. We can add that on a separate PR