0

On buid node I have sbt

sbt script version: 1.4.6

I have scala project with dependensies in project/plugins.sbt

addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.4")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.github.tototoshi" % "sbt-slick-codegen" % "1.4.0")
addSbtPlugin("org.openapitools" % "sbt-openapi-generator" % "5.0.0-beta2")
libraryDependencies += "org.postgresql" % "postgresql" % "42.2.9"

in project/build.properties

sbt.version=1.4.6

in Artifactory create 2 remote repo

http://rep.local:80/artifactory/mavenCentral via https://repo1.maven.org/maven2/ with type Maven layout maven2-default

and

SBT-scala-sbt.org-plugins via https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/ with type SBT layout sbt-default

build.sbt

name := "some_app"
version := "1.0.0"
scalaVersion := "2.13.3"

resolvers += ("Artifactory" at "http://rep.local/artifactory/libs-release-local").withAllowInsecureProtocol(true)
resolvers += ("maven-central" at "http://rep.local:80/artifactory/mavenCentral").withAllowInsecureProtocol(true)
resolvers += ("ivy" at "http://rep.local/SBT-scala-sbt.org-plugins").withAllowInsecureProtocol(true)

enablePlugins(BuildInfoPlugin)
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
enablePlugins(CodegenPlugin)

addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")

scalacOptions ++= Seq(
  "-P:bm4:no-filtering:y",
  "-P:bm4:no-map-id:y",
  "-P:bm4:no-tupling:y"
)

buildInfoOptions += BuildInfoOption.BuildTime

Docker / packageName := "new/some_app"
dockerBaseImage := "openjdk:13"
dockerExposedPorts ++= Seq(8080, 8080)
dockerRepository := Some("docker.rep.local")
dockerUpdateLatest := true

libraryDependencies ++= Dependencies.all

lazy val root = (project in file(".")).settings(
  SlickCodeGen.settings: _*
)

javaOptions ++= {
  val props = sys.props.toList
  props.filter { case (key, _) => key.startsWith("http") } map {
    case (key, value) => s"-D$key=$value"
  }
}
javacOptions += "-Dfile.encoding=UTF-8"
javaOptions in run += "-Dconfig.resource=application.dev.conf"
javaOptions in reStart += "-Dconfig.resource=application.dev.conf"

fork := true
trapExit := false
connectInput := true

try building on build node and returned error

[error] sbt.librarymanagement.ResolveException: Error downloading org.openapitools:sbt-openapi-generator;sbtVersion=1.0;scalaVersion=2.12:5.0.0-beta2

[error]   download error: Caught java.net.ConnectException: Connection refused (Connection refused) (Connection refused (Connection refused)) while downloading https://repo1.maven.org/maven2/org/openapitools/sbt-openapi-generator_2.12_1.0/5.0.0-beta2/sbt-openapi-generator-5.0.0-beta2.pom
[error]   download error: Caught java.net.ConnectException: Connection refused (Connection refused) (Connection refused (Connection refused)) while downloading https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.openapitools/sbt-openapi-generator/scala_2.12/sbt_1.0/5.0.0-beta2/ivys/ivy.xml
[error]   download error: Caught java.net.ConnectException: Connection refused (Connection refused) (Connection refused (Connection refused)) while downloading https://repo.typesafe.com/typesafe/ivy-releases/org.openapitools/sbt-openapi-generator/scala_2.12/sbt_1.0/5.0.0-beta2/ivys/ivy.xml

Try find https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.openapitools/sbt-openapi-generator/scala_2.12/sbt_1.0/5.0.0-beta2/ivys/ivy.xml via local repo http://rep.local/SBT-scala-sbt.org-plugins

http://rep.local/artifactory/SBT-scala-sbt.org-plugins/org.openapitools/sbt-openapi-generator/scala_2.12/sbt_1.0/5.0.0-beta2/ivys/

enter image description here

Exist!

$ sbt docker:publish 

continue to return error... How solve this problem?

Nikolay Baranenko
  • 1,582
  • 6
  • 35
  • 60
  • if off addSbtPlugin("org.openapitools" % "sbt-openapi-generator" % "5.0.0-beta2") - build without problem, error returned after add this SBT Pliggin – Nikolay Baranenko Feb 04 '21 at 19:30

1 Answers1

0

If you are unable to reach Maven Central, simply appending resolver is not going to work.

What you need is to completely override the resolvers using repositories file and -Dsbt.override.build.repos=true. See Proxy Repositories for the documentation.

repositories

[repositories]
  local
  libs-release-local: http://rep.local/artifactory/libs-release-local,allowInsecureProtocol
  proxy-central: http://rep.local:80/artifactory/mavenCentral,allowInsecureProtocol
  proxy-ivy: http://rep.local/SBT-scala-sbt.org-plugins,[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext],allowInsecureProtocol

Resolvers your proxy repository must support

For sbt 1.x, your proxy repository must support at least the following (in addition to any other custom resolvers that your build are using):

  maven-central
  sbt-plugin-releases: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)([branch]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

Note that repo.scala-sbt.org will redirect to Bintray, but where it will redirect is subject to change. In fact, Bintray in general will be shut down on May 1st, 2021.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319