Skip to content

When publishing as part of release in multi-module project, group name gets ignored #341

@juanavelez

Description

@juanavelez

First of all, we appreciate the help provided by this plugin.

We have a multi-module project for which we execute sbt release with-defaults. The publish process for each of the modules does get executed but they are not published with the correct groupId, instead both the group and artifact IDs are the same and matching the module name

Attaching a modified version of the actual build.sbt file

organization := "mycompany"

scalaVersion in ThisBuild := "2.13.3"

val AkkaVersion = "2.6.16"
val AkkaManagementVersion = "1.1.2"
val AkkaHttpVersion = "10.2.1"
val AkkaStreamKafkaVersion = "2.1.1"
val AkkaPersistenceCassandra = "1.0.4"
val DatastaxJavaDriverVersion = "4.13.0"
val LogbackVersion = "1.2.3"
val LogstashLogbackEncoderVersion = "6.3"
val ScalaLoggingVersion = "3.9.2"
val SprayJsonVersion = "1.3.5"
val ScalatestVersion = "3.2.2"
val ScalaMockVersion = "5.0.0"
val JacksonVersion = "2.13.0"
val ScalaTestVersion = "3.2.2"
val WiremockVersion = "2.27.2"
val FicusVersion = "1.5.0"
val KamonVersion = "2.1.9"
val MicrometerVersion = "1.5.4"
val MicrometerRegistryNewRelic = "0.5.0"
val EmbeddedKafkaVersion = "3.1.0"
val KamonKanelaAgentVersion = "1.0.7"

releaseIgnoreUntrackedFiles := true

credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

lazy val artifactoryRepoLocation = "https://our.artifactory"

resolvers += "Artifactory Maven".at(artifactoryRepoLocation + "libs-release/")

resolvers += "Artifactory Maven Snapshots".at(artifactoryRepoLocation + "libs-snapshot/")

resolvers += "Artifactory SBT".at(artifactoryRepoLocation + "sbt-release-local/")

resolvers += "Artifactory SBT Snapshots".at(artifactoryRepoLocation + "sbt-snapshot-local/")

resolvers += Resolver.mavenLocal

libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.2" % Test
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")

publishTo in ThisBuild := {
  if (isSnapshot.value)
    Some("Artifactory Realm".at(artifactoryRepoLocation + "sbt-snapshot-local;build.timestamp=" + new java.util.Date().getTime))
  else
    Some("Artifactory Realm".at(artifactoryRepoLocation + "sbt-release-local"))
}

lazy val commonScalacOptions =
  Seq("-deprecation", "-feature", "-unchecked", "-Xlint", "-Ywarn-unused:imports", "-encoding", "UTF-8")

lazy val commonJavacOptions = Seq("-Xlint:unchecked", "-Xlint:deprecation")

lazy val commonSettings =
  Seq(
    Compile / scalacOptions ++= commonScalacOptions,
    Compile / javacOptions ++= commonJavacOptions,
    run / javaOptions ++= Seq("-Xms1024m", "-Xmx1024m"),
    Test / parallelExecution := false)

lazy val releaseAwareDockerVersion = settingKey[String]("Release aware docker version.")

lazy val commonDockerSettings =
  Seq(
    releaseAwareDockerVersion := {
      val thisBuildVersion = (ThisBuild / version).value
      val branch = sys.env.get("BRANCH_NAME") // set in jenkins pipeline
      val releaseBranch = sys.env.get("RELEASE_BRANCH") // set in jenkins pipeline
      def plainVersionNumber(v: String): String = v.filter(c => c.isDigit || c == '.')
      def localBuild: Boolean = branch.isEmpty && releaseBranch.isEmpty
      def jenkinsReleaseBuild: Boolean = !localBuild && branch.equals(releaseBranch)

      if (jenkinsReleaseBuild) plainVersionNumber(thisBuildVersion) else thisBuildVersion
    },
    version in Docker := releaseAwareDockerVersion.value,
    dockerUsername := Some("the-company"),
    dockerExposedPorts := Seq(2552, 8080, 8558),
    dockerBaseImage := "adoptopenjdk:8-jdk-hotspot",
    dockerUpdateLatest := true)

lazy val common =
  project
    .in(file("common"))
    .settings(commonSettings)
    .settings(libraryDependencies ++= Seq(
        "io.kamon" %% "kamon-bundle" % KamonVersion,
        "io.kamon" %% "kamon-kafka" % KamonVersion,
        "io.kamon" %% "kamon-newrelic" % KamonVersion,
        "com.newrelic.telemetry" % "micrometer-registry-new-relic" % MicrometerRegistryNewRelic,
        "io.micrometer" % "micrometer-core" % MicrometerVersion,
        "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion,
        "org.mongodb.scala" %% "mongo-scala-driver" % "2.9.0",
        "io.spray" %% "spray-json" % SprayJsonVersion,
        "com.iheart" %% "ficus" % FicusVersion,
        "ch.qos.logback" % "logback-classic" % LogbackVersion,
        "net.logstash.logback" % "logstash-logback-encoder" % LogstashLogbackEncoderVersion,
        "com.fasterxml.jackson.core" % "jackson-core" % JacksonVersion,
        "com.fasterxml.jackson.core" % "jackson-annotations" % JacksonVersion,
        "com.fasterxml.jackson.core" % "jackson-databind" % JacksonVersion,
        "com.fasterxml.jackson.dataformat" % "jackson-dataformat-cbor" % JacksonVersion,
        "com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % JacksonVersion,
        "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % JacksonVersion,
        "com.fasterxml.jackson.module" % "jackson-module-parameter-names" % JacksonVersion,
        "com.fasterxml.jackson.module" %% "jackson-module-scala" % JacksonVersion,
        "com.typesafe.akka" %% "akka-actor-testkit-typed" % AkkaVersion % Test,
        "org.scalatest" %% "scalatest" % ScalatestVersion % Test,
        "org.scalatest" %% "scalatest-mustmatchers" % ScalatestVersion % Test,
        "org.scalacheck" %% "scalacheck" % "1.14.1" % Test,
        "de.flapdoodle.embed" % "de.flapdoodle.embed.mongo" % "2.2.0" % Test,
        "org.scalamock" %% "scalamock" % ScalaMockVersion % Test))
    .enablePlugins(JavaAppPackaging, JavaAgent, DockerPlugin)

lazy val module1 = project
  .in(file("module1"))
  .settings(commonSettings)
  .settings(libraryDependencies ++= Seq(
      "com.typesafe.akka" %% "akka-stream" % AkkaVersion,
      "com.typesafe.akka" %% "akka-stream-typed" % AkkaVersion,
      "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion,
      "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion,
      "com.typesafe.akka" %% "akka-actor-testkit-typed" % AkkaVersion % Test,
      "org.scalatest" %% "scalatest" % ScalatestVersion % Test,
      "org.scalatest" %% "scalatest-mustmatchers" % ScalatestVersion % Test,
      "com.github.tomakehurst" % "wiremock" % "2.27.2" % Test))
  .dependsOn(common)

lazy val module2 = project
  .in(file("module2"))
  .settings(commonSettings)
  .settings(commonDockerSettings)
  .settings(javaAgents += "io.kamon" % "kanela-agent" % KamonKanelaAgentVersion)
  .settings(
    name := "prefix-module2",
    mainClass in (Compile, run) := Some("some.package.classbuild.sbt"),
    libraryDependencies ++= Seq(
        "com.typesafe.akka" %% "akka-actor" % AkkaVersion,
        "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion,
        "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion,
        "com.typesafe.akka" %% "akka-persistence-query" % AkkaVersion,
        "com.typesafe.akka" %% "akka-cluster-sharding-typed" % AkkaVersion,
        ("com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion)
          .exclude("com.fasterxml.jackson.core", "*")
          .exclude("com.fasterxml.jackson.dataformat", "jackson-dataformat-cbor")
          .exclude("com.fasterxml.jackson.datatype", "jackson-datatype-jdk8")
          .exclude("com.fasterxml.jackson.datatype", "jackson-datatype-jsr310")
          .exclude("com.fasterxml.jackson.module", "jackson-module-parameter-names")
          .exclude("com.fasterxml.jackson.module", "jackson-module-scala"),
        ("com.typesafe.akka" %% "akka-stream-kafka-cluster-sharding" % AkkaStreamKafkaVersion)
          .exclude("com.typesafe.akka", "akka-cluster-sharding-typed")
          .exclude("com.typesafe.akka", "akka-stream"),
        ("com.typesafe.akka" %% "akka-cluster" % AkkaVersion).exclude("com.typesafe.akka", "akka-http-spray-json"),
        ("com.typesafe.akka" %% "akka-cluster-tools" % AkkaVersion).exclude("com.typesafe.akka", "akka-persistence-cassandra"),
        "com.typesafe.akka" %% "akka-discovery" % AkkaVersion,
        "com.typesafe.akka" %% "akka-stream" % AkkaVersion,
        "com.typesafe.akka" %% "akka-persistence-cassandra" % AkkaPersistenceCassandra,
        "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion,
        "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion,
        "com.typesafe.akka" %% "akka-http-spray-json" % AkkaHttpVersion,
        "com.typesafe.akka" %% "akka-stream-kafka" % AkkaStreamKafkaVersion,
        "com.lightbend.akka.management" %% "akka-management" % AkkaManagementVersion,
        "com.lightbend.akka.discovery" %% "akka-discovery-kubernetes-api" % AkkaManagementVersion,
        "com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % AkkaManagementVersion,
        "com.lightbend.akka.management" %% "akka-management-cluster-http" % AkkaManagementVersion,
        "com.lightbend.akka.management" %% "akka-management-loglevels-logback" % AkkaManagementVersion,
        "software.aws.mcs" % "aws-sigv4-auth-cassandra-java-driver-plugin" % "4.0.3",
        ("com.datastax.oss" % "java-driver-core" % DatastaxJavaDriverVersion).exclude("io.dropwizard.metrics", "metrics-core"),
        "com.datastax.oss" % "java-driver-metrics-micrometer" % DatastaxJavaDriverVersion,
        "ch.qos.logback" % "logback-classic" % LogbackVersion,
        "com.typesafe.scala-logging" %% "scala-logging" % ScalaLoggingVersion,
        "io.github.embeddedkafka" %% "embedded-kafka" % EmbeddedKafkaVersion % Test,
        "com.typesafe.akka" %% "akka-persistence-testkit" % AkkaVersion % Test,
        "com.github.tomakehurst" % "wiremock-jre8" % "2.27.2" % Test,
        "org.fusesource.leveldbjni" % "leveldbjni-all" % "1.8" % Test, // it's needed for BacklogCopyTaskSpec
        "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % Test,
        "com.typesafe.akka" %% "akka-stream-kafka-testkit" % AkkaStreamKafkaVersion % Test,
        "org.awaitility" % "awaitility-scala" % "4.2.0" % Test,
        "org.scalatest" %% "scalatest" % ScalatestVersion % Test,
        "org.mockito" % "mockito-core" % "3.12.4" % Test,
        "org.scalatest" %% "scalatest-mustmatchers" % ScalatestVersion % Test,
        "org.scalamock" %% "scalamock" % ScalaMockVersion % Test))
  .dependsOn(common, module1, module3, module4)
  .enablePlugins(JavaAppPackaging, JavaAgent, DockerPlugin)

lazy val module3 = project
  .in(file("module3"))
  .settings(commonSettings)
  .settings(commonDockerSettings)
  .settings(javaAgents += "io.kamon" % "kanela-agent" % KamonKanelaAgentVersion)
  .settings(
    name := "prefix-module3",
    mainClass in (Compile, run) := Some("some.package.class"),
    libraryDependencies ++= Seq(
        "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion,
        "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion,
        "com.typesafe.akka" %% "akka-cluster-typed" % AkkaVersion,
        "com.typesafe.akka" %% "akka-cluster-tools" % AkkaVersion,
        "com.typesafe.akka" %% "akka-discovery" % AkkaVersion,
        "com.typesafe.akka" %% "akka-stream" % AkkaVersion,
        "com.typesafe.akka" %% "akka-stream-kafka" % AkkaStreamKafkaVersion,
        "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion,
        "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion,
        "com.typesafe.akka" %% "akka-http-spray-json" % AkkaHttpVersion,
        "com.lightbend.akka.management" %% "akka-management" % AkkaManagementVersion,
        "com.lightbend.akka.discovery" %% "akka-discovery-kubernetes-api" % AkkaManagementVersion,
        "com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % AkkaManagementVersion,
        "com.lightbend.akka.management" %% "akka-management-cluster-http" % AkkaManagementVersion,
        "com.lightbend.akka.management" %% "akka-management-loglevels-logback" % AkkaManagementVersion,
        "ch.qos.logback" % "logback-classic" % LogbackVersion,
        "com.fasterxml.jackson.module" %% "jackson-module-scala" % JacksonVersion,
        "com.typesafe.scala-logging" %% "scala-logging" % ScalaLoggingVersion,
        "com.typesafe.akka" %% "akka-protobuf" % AkkaVersion,
        "com.typesafe.akka" %% "akka-persistence" % AkkaVersion,
        "com.typesafe.akka" %% "akka-distributed-data" % AkkaVersion,
        "com.typesafe.akka" %% "akka-cluster-sharding" % AkkaVersion,
        //TEST
        "io.github.embeddedkafka" %% "embedded-kafka" % EmbeddedKafkaVersion % Test,
        "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % Test,
        "com.typesafe.akka" %% "akka-persistence-testkit" % AkkaVersion % Test,
        "org.scalatest" %% "scalatest" % ScalaTestVersion % Test,
        "com.typesafe.akka" %% "akka-stream-kafka-testkit" % AkkaStreamKafkaVersion % Test,
        "com.typesafe.akka" %% "akka-actor-testkit-typed" % AkkaVersion % Test,
        "org.scalatest" %% "scalatest-mustmatchers" % ScalaTestVersion % Test,
        "org.scalamock" %% "scalamock" % ScalaMockVersion % Test,
        "com.github.tomakehurst" % "wiremock" % WiremockVersion % Test))
  .dependsOn(common)
  .enablePlugins(JavaAppPackaging, JavaAgent, DockerPlugin)

lazy val module4 = project
  .in(file("module4"))
  .settings(commonSettings)
  .settings(commonDockerSettings)
  .settings(
    name := "prefix-module4",
    libraryDependencies ++= Seq(
        "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion,
        "com.typesafe.akka" %% "akka-http-spray-json" % AkkaHttpVersion,
        "com.typesafe.akka" %% "akka-cluster-typed" % AkkaVersion,
        "com.typesafe.akka" %% "akka-cluster-sharding" % AkkaVersion,
        "com.typesafe.akka" %% "akka-cluster-sharding-typed" % AkkaVersion,
        "com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % AkkaManagementVersion,
        "com.typesafe.akka" %% "akka-discovery" % AkkaVersion,
        "com.typesafe.akka" %% "akka-persistence-testkit" % AkkaVersion % Test,
        "com.github.tomakehurst" % "wiremock-jre8" % "2.27.2" % Test,
        "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % Test,
        "com.typesafe.akka" %% "akka-stream-kafka-testkit" % AkkaStreamKafkaVersion % Test,
        "org.scalatest" %% "scalatest" % ScalatestVersion % Test,
        "org.scalatest" %% "scalatest-mustmatchers" % ScalatestVersion % Test,
        "org.scalamock" %% "scalamock" % ScalaMockVersion % Test))
  .dependsOn(common)
  .enablePlugins(JavaAppPackaging, JavaAgent, DockerPlugin)

Snippet from the release process log:

[info] 	published module1_2.13 to https://our.artifactory/artifactory/sbt-release-local/module1/module1_2.13/0.0.160/module1_2.13-0.0.160.jar
[info] 	published module1_2.13 to https://our.artifactory/artifactory/sbt-release-local/module1/module1_2.13/0.0.160/module1_2.13-0.0.160-sources.jar
[info] 	published module1_2.13 to https://our.artifactory/artifactory/sbt-release-local/module1/module1_2.13/0.0.160/module1_2.13-0.0.160-javadoc.jar

whereas we were expecting it to be based off the organization name

[info] 	published module1_2.13 to https://our.artifactory/artifactory/sbt-release-local/mycompany/module1_2.13/0.0.160/module1_2.13-0.0.160.jar
[info] 	published module1_2.13 to https://our.artifactory/artifactory/sbt-release-local/mycompany/module1_2.13/0.0.160/module1_2.13-0.0.160-sources.jar
[info] 	published module1_2.13 to https://our.artifactory/artifactory/sbt-release-local/mycompany/module1_2.13/0.0.160/module1_2.13-0.0.160-javadoc.jar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions