2
votes

When setting up a sbt project with a local artifactory / maven proxy I see the following message:

In order to specify that all resolvers added in the sbt project should be ignored in favor of those configured in the repositories configuration, add the following configuration option to the sbt launcher script:

-Dsbt.override.build.repos=true

Add the following to your build.sbt file:

resolvers += 
"Artifactory" at "http://url/artifactory/virtualRepository/"

But what I would like to achieve is a behaviour similar to maven i.e. not manually overriding resolvers in the SBT file, but rather via the configuration. Is this possible as well? If yes how? Desired behaviour

  • the project should compile fine without local artifactory proxy
  • when available / configured in repositories the local one should be used as the source / cache for quicker access

currently, I only get unresolved dependencies for sbt plugins:

::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scalariform#sbt-scalariform;1.6.0: not found
[warn]  :: org.scoverage#sbt-scoverage;1.5.0: not found
[warn]  :: org.scalastyle#scalastyle-sbt-plugin;0.8.0: not found
[warn]  :: net.virtual-void#sbt-dependency-graph;0.8.2: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

With warnings of

[warn]  module not found: org.scalariform#sbt-scalariform;1.6.0
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== local: tried
[warn]   d:\users\heilerg\.ivy2\local\org.scalariform\sbt-scalariform\scala_2.10\sbt_0.13\1.6.0\ivys\ivy.xml
[warn] ==== my-ivy-proxy-releases: tried
[warn]   http://url/artifactory/virtualRepositoryScala/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== my-maven-proxy-releases: tried
[warn]   http://url/artifactory/virtualRepositoryScala/org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom
[warn] ==== Artima Maven Repository: tried
[warn]   http://repo.artima.com/releases/org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom
[info] Resolving org.scoverage#sbt-scoverage;1.5.0 ...

and SBT logs will show

 [ERROR] (o.a.r.RemoteRepoBase:766) - IO error while trying to download resource 'repo1:org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom': org.artifactory.api.repo.exception.maven.BadPomException: The target deployment path 'org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom' does not match the POM's expected path prefix 'org/scalariform/sbt-scalariform/1.6.0'. Please verify your POM content for correctness and make sure the source path is a valid Maven repository root path.

Somewhere people mention to use the following option in Artifactory to "suppress POM consistency checks", but in the current version of artifactory I can not finde such an option.

edit

I can see only these options enter image description here

1
Seems to be more of an artifactory issue: github.com/coursier/coursier/issues/286 jfrog.com/jira/browse/RTFACT-6235 A workaround mentioned is to "suppress POM consistency checks" - PhilBa
where can I find this option? In the current artifactory there does not seem this option in the advanced tab of a remote repository. Please see the edit. I can see only the options from the screenshot above. - Georg Heiler
The User Guide says: " in the Admin module, go to Repositories | Remote and click it to display the Edit Repository screen." jfrog.com/confluence/display/RTF/Remote+Repositories - PhilBa
thanks for the hint. The answer (unlike many links suggest) is to look for the file in the basic settings. - Georg Heiler
Nah, its fine. Just one more thing; I'm not sure if this was what you were asking for, but you can specify the proxy in the $userhome/.sbt/repositories file. It should then get picked up globally by all sbt projects - PhilBa

1 Answers

0
votes

As answered in the comment, a common workaround is "Suppress POM Consistency Checks" - Advanced Settings.

If that is not desirable, another method might be to re-publish the plugin with a valid POM. I've written POM consistency for sbt plugins to show that can be done.

// set some unique postfix
ThisBuild / version := "0.15.0-Pets1"
 
lazy val root = (project in file("."))
  .enablePlugins(SbtPlugin)
  .settings(
    name := "sbt-assembly",
    ....
 
    publishMavenStyle := true,
    // add this
    pomConsistency2021DraftSettings,
  )
 
// Add the following
lazy val pomConsistency2021Draft = settingKey[Boolean]("experimental")
 
/**
 * this is an unofficial experiment to re-publish plugins with better Maven compatibility
 */
def pomConsistency2021DraftSettings: Seq[Setting[_]] = Seq(
  pomConsistency2021Draft := Set("true", "1")(sys.env.get("POM_CONSISTENCY").getOrElse("false")),
  moduleName := {
    if (pomConsistency2021Draft.value)
      sbtPluginModuleName2021Draft(moduleName.value,
        (pluginCrossBuild / sbtBinaryVersion).value)
    else moduleName.value
  },
  projectID := {
    if (pomConsistency2021Draft.value) sbtPluginExtra2021Draft(projectID.value)
    else projectID.value
  },
)
 
def sbtPluginModuleName2021Draft(n: String, sbtV: String): String =
  s"""${n}_sbt${if (sbtV == "1.0") "1" else if (sbtV == "2.0") "2" else sbtV}"""
 
def sbtPluginExtra2021Draft(m: ModuleID): ModuleID =
  m.withExtraAttributes(Map.empty)
   .withCrossVersion(CrossVersion.binary)