I am trying to publish a multi project to sonatype using sbt-release, sbt-pgp and sbt-sonatype plugins.
while running: sbt publishLocalSigned I see the .asc file published.
but when running sbt release to sonatype I can only see the .md5 and sha1 files.
here is my release.sbt:
import ReleaseTransformations._
// publishing
publishMavenStyle in ThisBuild := true
credentials in ThisBuild += Credentials(Path.userHome / ".ivy2" / ".credentials_sonatype")
publishTo in ThisBuild := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
publishArtifact in Test := false
pomIncludeRepository in ThisBuild := { _ => false }
pomExtra in ThisBuild := {
<url>my.url</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git#github.com:url.git</connection>
<developerConnection>scm:git:git#github.com:url.git</developerConnection>
<url>url</url>
</scm>
<developers>
<developer>
<id>dev</id>
<name>dev</name>
<email>dev#gmail.com</email>
</developer>
</developers>
}
// use maven style tag name
releaseTagName in ThisBuild := s"${name.value}-${(version in ThisBuild).value}"
// sign artifacts
releasePublishArtifactsAction in ThisBuild := PgpKeys.publishSigned.value
// don't push changes (so they can be verified first)
releaseProcess in ThisBuild := Seq(
checkSnapshotDependencies,
inquireVersions,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
pushChanges,
releaseStepCommand("sonatypeRelease")
)
my plugin.sbt:
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
I am sure my gpg keys are properly set, otherwise I wont be able to run the publishLocalSigned but it seems like I miss something to my sbt-gpg plugin to kick in on release.
sbt version is 1.2.8 and I tried to downgrade to 0.13.17 and got the same behaviour.
I have to mention I was mainly following the jackson-module-scala approach:
https://github.com/FasterXML/jackson-module-scala/blob/master/release.sbt
Related
I am trying to instrument a java app with prometheus exporter using sbt-native-packager:
This is what I have:
plugin.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.5.1")
build.sbt
import com.typesafe.sbt.packager.docker.DockerChmodType
dockerChmodType := DockerChmodType.UserGroupWriteExecute
enablePlugins(JavaServerAppPackaging, AshScriptPlugin, DockerPlugin)
settings(moduleName := "my-test")
settings(mainClass in Compile := Some("org.name.demo.stream.MyTestClass"))
dockerBaseImage := "openjdk:8-jre-alpine"
daemonUser in Docker := "test"
As per the prometheus exporter docs, I would like to instrument the exporter as an java agent:
java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=8080:config.yaml -jar my-test_2.12-0.1.jar
Is it possible for me to do this instrumentation via sbt-native-packager? Appreciate inputs.
Use https://github.com/sbt/sbt-javaagent
In plugins.sbt
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.6")
then in build.sbt
val MyAppSettings = Seq(
name := "My",
dockerBaseImage := "adoptopenjdk:11-jre-hotspot",
mainClass := Some("com.MyClass"),
packageName in Docker := "mycontainer",
libraryDependencies ++= myDependencies,
javaAgents += JavaAgent("io.prometheus.jmx" % "jmx_prometheus_javaagent" % "0.16.1", arguments = "33002:/opt/docker/jmx-exporter.yaml"),
mappings in Universal ++= Seq(
file("jmx-exporter.yaml") -> "jmx-exporter.yaml"
)
)
lazy val myProject = (project in file("my-project"))
.settings(MyAppSettings)
.enablePlugins(JavaAppPackaging, JavaAgent)
I'm working on a JPA + Playframework 2.5.x project which I package it as Docker image.
I want to forcibly add all the files except one file (META-INF/persistence.xml) under conf folder to docker output
Currently I have done the following:
mappings in Docker += file("conf/base/application.conf") -> "opt/docker/conf/base/application.conf"
mappings in Docker += file("conf/base/default-client.conf") -> "opt/docker/conf/base/default-client.conf"
mappings in Docker += file("conf/prod/application.conf") -> "opt/docker/conf/prod/application.conf"
mappings in Docker += file("conf/prod/logback.xml") -> "opt/docker/conf/prod/logback.xml"
mappings in Docker += file("conf/stage/application.conf") -> "opt/docker/conf/stage/application.conf"
mappings in Docker += file("conf/stage/logback.xml") -> "opt/docker/conf/stage/logback.xml"
mappings in Docker += file("conf/local/application.conf") -> "opt/docker/conf/local/application.conf"
mappings in Docker += file("conf/local/logback.xml") -> "opt/docker/conf/local/logback.xml"
mappings in Docker += file("conf/routes") -> "opt/docker/conf/routes"
mappings in Docker += file("conf/ValidationMessages.properties") -> "opt/docker/conf/ValidationMessages.properties"
I am sure this is not the best way to achieve this. Can anybody suggest better option to customize the Docker output the way I need it ?
My build.sbt file:
PlayKeys.externalizeResources := false
name := """wp-pw-ng"""
version := "1.0.0-SNAPSHOT"
lazy val `wp-pw-ng` = (project in file(".")).enablePlugins(PlayJava, JavaAppPackaging)
val playVer = "2.5.9"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
javaJpa,
"org.hibernate" % "hibernate-core" % "5.2.3.Final" exclude("dom4j", "dom4j"),
"mysql" % "mysql-connector-java" % "6.0.5",
cache,
javaWs,
filters,
"dom4j" % "dom4j" % "1.6",
"com.google.guava" % "guava" % "20.0-rc1",
"com.amazonaws" % "aws-java-sdk" % "1.11.34"
)
val docDeps = Seq(
"io.swagger" %% "swagger-play2" % "1.5.3.2"
)
libraryDependencies ++= docDeps
fork in Test := true
javaOptions in Test ++= Seq(
"-Xms512M",
"-Xmx1536M",
"-Xss1M",
"-XX:MaxPermSize=384M"
)
fork in run := false
unmanagedResourceDirectories in Compile <+= (sourceDirectory in Compile) (_ / "resources")
mappings in Docker += file("conf/base/application.conf") -> "opt/docker/conf/base/application.conf"
mappings in Docker += file("conf/base/default-client.conf") -> "opt/docker/conf/base/default-client.conf"
mappings in Docker += file("conf/base/pw.conf") -> "opt/docker/conf/base/paywall.conf"
mappings in Docker += file("conf/prod/application.conf") -> "opt/docker/conf/prod/application.conf"
mappings in Docker += file("conf/prod/logback.xml") -> "opt/docker/conf/prod/logback.xml"
mappings in Docker += file("conf/stage/application.conf") -> "opt/docker/conf/stage/application.conf"
mappings in Docker += file("conf/stage/logback.xml") -> "opt/docker/conf/stage/logback.xml"
mappings in Docker += file("conf/local/application.conf") -> "opt/docker/conf/local/application.conf"
mappings in Docker += file("conf/local/logback.xml") -> "opt/docker/conf/local/logback.xml"
mappings in Docker += file("conf/routes") -> "opt/docker/conf/routes"
mappings in Docker += file("conf/ValidationMessages.properties") -> "opt/docker/conf/ValidationMessages.properties"
//************************************************
// Custom Docker Build,
// use command 'activator docker:publishLocal'
// to publish image locally to computer.
//************************************************
import com.typesafe.sbt.packager.docker._
val playUser = "play"
val grp = "idud"
dockerRepository := Some("quay.io/we")
version in Docker := "latest"
val buildEnv: String = System.getProperty("build.env")
dockerCommands := Seq(
Cmd("FROM", "anapsix/alpine-java:8_jdk_unlimited"),
Cmd("RUN", "apk", "-Uuv add", "--no-cache", "su-exec", "groff", "less", "python", "py-pip", "&& pip install awscli ", "&& apk --purge -v del py-pip ", " && rm /var/cache/apk/* "),
Cmd("RUN", s"addgroup $grp"),
Cmd("RUN", s"adduser -s /bin/bash -D -G $grp $playUser"),
Cmd("RUN", "echo", s"'$playUser ALL=(ALL) NOPASSWD:ALL'", ">> /etc/sudoers"),
Cmd("WORKDIR", "/opt/docker"),
Cmd("ADD", "opt /opt"),
Cmd("RUN", "chown", "-R", s"$playUser:$grp", "."),
Cmd("USER", s"$playUser"),
Cmd("ENTRYPOINT", "[\"bin/wp-pw-ng\", \"-Dconfig.file=conf/" + buildEnv + "/application.conf\", \"-Dhttp.port=7000\" , \"-Dpidfile.path=/dev/null\" ,\"-Dlogger.file=conf/" + buildEnv + "/logback.xml\"]"),
Cmd("EXPOSE", "9877")
)
Additional Info
I had to resort to this work-around due to issue in build stage mode issue with Playframework, Issue 4590 and I had to use PlayKeys.externalizeResources := false flag in my build.sbt file. This would remove all files from conf folder in Docker.
The playExternalizeResources:= false setting just prevents sbtfrom adding the playExternalizedResources to your mappings in Universal, which are the mappings available for all target package formats including docker.
Your build sbt can be lightenend with the MappingsHelper ( ScalaDocs )
import NativePackagerHelper._
mappings in Universal ++= contentOf("conf")
You can also filter the mappings to remove the unwanted files, e.g
import NativePackagerHelper._
mappings in Universal ++= contentOf("conf").filter(_.2.contains("persistence.xml")
Hope that helps,
Muki
Simply add the files that you want to be mapped inside a universal/conf directory. As a result of this, when you're creating the docker image the files get added to the /opt/docker/conf directory.
Here is a build.sbt file from https://github.com/jducoeur/bootstrap-datepicker-scalajs :
import SonatypeKeys._
sonatypeSettings
lazy val root = project.in(file(".")).
enablePlugins(ScalaJSPlugin)
name := "Scala.js facade for bootstrap-datepicker"
normalizedName := "bootstrap-datepicker-facade"
version := "0.3"
organization := "org.querki"
scalaVersion := "2.11.6"
crossScalaVersions := Seq("2.10.4", "2.11.5")
libraryDependencies ++= Seq(
"org.querki" %%% "querki-jsext" % "0.5",
"org.scala-js" %%% "scalajs-dom" % "0.8.0",
"org.querki" %%% "jquery-facade" % "0.6"
)
jsDependencies += "org.webjars" % "bootstrap" % "3.3.4" / "bootstrap.js" minified "bootstrap.min.js" dependsOn "jquery.js"
jsDependencies += "org.webjars" % "bootstrap-datepicker" % "1.4.0" / "bootstrap-datepicker.js" minified "bootstrap-datepicker.min.js" dependsOn "bootstrap.js"
jsDependencies in Test += RuntimeDOM
homepage := Some(url("http://www.querki.net/"))
licenses += ("MIT License", url("http://www.opensource.org/licenses/mit-license.php"))
scmInfo := Some(ScmInfo(
url("https://github.com/jducoeur/bootstrap-datepicker-scalajs"),
"scm:git:git#github.com:jducoeur/bootstrap-datepicker-scalajs.git",
Some("scm:git:git#github.com:jducoeur/bootstrap-datepicker-scalajs.git")))
publishMavenStyle := true
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
pomExtra := (
<developers>
<developer>
<id>jducoeur</id>
<name>Mark Waks</name>
<url>https://github.com/jducoeur/</url>
</developer>
</developers>
)
pomIncludeRepository := { _ => false }
It declared two js dependencies: bootstrap and bootstrap-datepicker. Since bootstrap-datepicker already depends on bootstrap, can we not just declare bootstrap-datepicker alone?
There are different dependencies here. One is dependencies between WebJars, which just makes sure the relevant packages are downloaded.
Then there are dependencies between JS packages, which is used to make sure they are loaded in correct order into the jsdeps.js file. This dependency does not automatically include the other library into the final output.
So you need to define all JS libs you need in your application and use dependsOn to make sure they are in the correct order.
When upgrading to Play 2.2 I get the error
Exception: There is no cache plugin registered. Make sure at least one CachePlugin implementation is enabled
I understand that this means that there could be more than one cache on the classpath or none at all. I have tried removing cache from the dependencies and also excluding any play imports from the other dependencies but nothing has altered the error. If I remove cache and exclude("com.typesafe.play", "*") from all dependencies I correctly get java.lang.NoClassDefFoundError: play/api/cache/Cache
But as soon as I then add cache back back in I get the same error of no cache plugin registered.
My cache dependencies but running play dependencies | grep cache
| com.typesafe.play:play-cache_2.10:2.2.2-RC2 | rm-play:rm-play_2.10:1.0-SNAPSHOT | As play-cache_2.10.jar|
| net.sf.ehcache:ehcache-core:2.6.6| com.typesafe.play:play-cache_2.10:2.2.2-RC2| As ehcache-core.jar |
| com.typesafe.play:play_2.10:2.2.2-RC2| com.typesafe.play:play-cache_2.10:2.2.2-RC2| As play_2.10.jar| net.sf.ehcache:ehcache-core:2.6.6|
My Build.scala
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "rm-play"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
javaCore,
javaJdbc,
javaEbean,
cache,
//Group id
"com.google.guava" % "guava" % "14.0.1" ,
"com.dbdeploy" % "maven-dbdeploy-plugin" % "3.0M3",
"postgresql" % "postgresql" % "9.1-901.jdbc4",
"joda-time" % "joda-time" % "2.3",
"com.amazonaws" % "aws-java-sdk"% "1.6.11",
"ws.securesocial" %% "securesocial" % "master-SNAPSHOT" exclude("com.typesafe.play", "*")
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += Resolver.sonatypeRepo("snapshots"),
resolvers += Resolver.sonatypeRepo("releases")
)
}
plugin.sbt
// Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2-RC2")
Ok so my problem was that in my application.conf file I had some cache properties left over from 2.0, commenting them out helped me get the above error.
#memcachedplugin=enabled
#memcached.namespace=srm
#ehcacheplugin=enabled
#memcached.host="127.0.0.1:11211"
I have a problem at deploying a lift application on a Tomcat Server.
At server start the log shows an error:
INFO: Deploying web application archive lift.war
Nov 08, 2013 5:47:18 PM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Nov 08, 2013 5:47:18 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/lift] startup failed due to previous errors
The error occurs on either Tomcat 6 and 7 with lift Version 2.6 with scala 2.10.3 on Tomcat 7
Thanks in advance!
EDIT:
Here's the stack trace from Tomcat:
SCHWERWIEGEND: Exception starting filter LiftFilter
java.lang.NoSuchMethodError: scala.Predef$.Map()Lscala/collection/immutable/Map$;
at net.liftweb.common.BoxTrait$class.$init$(Box.scala:62)
at net.liftweb.common.Box$.<init>(Box.scala:49)
at net.liftweb.common.Box$.<clinit>(Box.scala)
at net.liftweb.util.Props$.mode$lzycompute(Props.scala:112)
at net.liftweb.util.Props$.mode(Props.scala:110)
at net.liftweb.util.Props$.devMode$lzycompute(Props.scala:204)
at net.liftweb.util.Props$.devMode(Props.scala:204)
at net.liftweb.http.LiftRules$.<init>(LiftRules.scala:79)
at net.liftweb.http.LiftRules$.<clinit>(LiftRules.scala)
at net.liftweb.http.provider.servlet.ServletFilterProvider$class.init(ServletFilterProvider.scala:38)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:928)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4649)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5305)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
EDIT:
Here is my build.sbt:
name := "lift_project"
version := "0.0.1"
organization := "net.liftweb"
scalaVersion := "2.10.3"
resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"staging" at "http://oss.sonatype.org/content/repositories/staging",
"releases" at "http://oss.sonatype.org/content/repositories/releases"
)
seq(com.github.siasia.WebPlugin.webSettings :_*)
unmanagedBase <<= baseDirectory { base => base / "lib" }
unmanagedJars in Compile <<= baseDirectory map { base => (base ** "*.jar").classpath }
unmanagedResourceDirectories in Test <+= (baseDirectory) { _ / "src/main/webapp" }
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-language:implicitConversions", "-language:postfixOps")
libraryDependencies ++= {
val liftVersion = "2.6-M1"
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile",
"net.liftweb" %% "lift-ldap" % liftVersion % "compile",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container,test",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container,test" artifacts Artifact("javax.servlet", "jar", "jar"),
"ch.qos.logback" % "logback-classic" % "1.0.6",
"com.h2database" % "h2" % "1.3.167",
"mysql" % "mysql-connector-java" % "5.1.25",
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)
}
net.virtualvoid.sbt.graph.Plugin.graphSettings
EDIT:
And the content of the lib folder:
activation-1.1.jar
commons-codec-1.6.jar
commons-fileupload-1.2.2.jar
h2-1.3.167.jar
htmlparser-1.4.jar
iText-2.1.5.jar
jcommon-1.0.18.jar
jfreechart-1.0.15.jar
jfreechart-1.0.15-demo.jar
jfreechart-1.0.15-experimental.jar
jfreechart-1.0.15-swt.jar
joda-convert-1.2.jar
joda-time-2.1.jar
junit.jar
lift-actor_2.10-2.6-M1.jar
lift-common_2.10-2.6-M1.jar
lift-db_2.10-2.6-M1.jar
lift-json_2.10-2.6-M1.jar
lift-ldap_2.10-2.6-M1.jar
lift-mapper_2.10-2.6-M1.jar
lift-markdown_2.10-2.6-M1.jar
lift-proto_2.10-2.6-M1.jar
lift-util_2.10-2.6-M1.jar
lift-webkit_2.10-2.6-M1.jar
logback-classic-1.0.6.jar
logback-core-1.0.6.jar
mail-1.4.4.jar
mysql-connector-java-5.1.25.jar
paranamer-2.4.1.jar
sbt-launch.jar
scala-compiler.jar
scala-library.jar
scalap-2.10.0.jar
scala-reflect-2.10.3.jar
slf4j-api-1.7.2.jar
swtgraphics2d.jar
Ok. I guess the problem lies here:
unmanagedJars in Compile <<= baseDirectory map { base => (base ** "*.jar").classpath }
This simply adds every jar under your project to the WAR. I don't know which SBT version you're using but IIRC older versions of SBT put scala-library.jar in their build path under your project root (baseDirectory), which, in your case, gets included during the build process, resulting in a jar conflict.
Try removing the suspected line or change 'baseDirectory' to something more specific like 'unmanagedBase'.
scala-library.jar does look suspicious, as we cannot tell the version from the file name. Maybe it is an old standard library, for which your lift version is not working.
Try
unzip -p scala-library.jar META-INF/MANIFEST.MF
to see the version, you need it to be 2.10.0 or newer.
I agree with harp seal pup that the problem is probably caused by your copying of the unmanaged jars. Try not to use unmanaged jars (remove the line, let sbt manage the dependencies).
After using some try&error methods I finally identified the jar causing trouble:
sbt-launch.jar
After removing this from the lib folder everything works fine on Tomcat (and Jetty as well)