The sbt can't download dependency from nexus repository manager.
Here is the resolver for repo in build.sbt file:
resolvers += "Sonatype Nexus Repository Manager" at "nexus repo url"
Resolver is working fine in case of release version eg 1.0.0 but not for snapshot version like 1.0.0-SNAPSHOT.
Below is the dependency that added in build.sbt
"artifacts" % "name" % "1.0.0-SNAPSHOT" changing()
Related
i have troubles with Sbt.
In my local instance of JFrog Artifactory i have published a java library without the .pom file, so i have just the .jar file.
Configuration:
//build.sbt
libraryDependencies += "com.example" % "my-library" % "1.0" % "provided"
//build.properties
sbt.version = 1.3.0-RC2
Obliviously i have configured the resolvers properly.
Sbt fails with the following error:
not found: http://[Artifactory]/artifactory/maven/com/example/my-library/1.0/my-library-1.0.pom
The error is clear, indeed .pom file doesn't exists.
There is a way to specify, for a specific dependency, the extension ?
If for whatever reason you published the jar without a pom file on purpose, you can specify an explicit URL for the jar you want to depend on, e.g.
libraryDependencies += "slinky" % "slinky" % "2.1"
from "https://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar"
But if you just published the library ivy-style (so an ivy.xml file was published instead of a pom file), you just need to specify a right resolver for your repository, which will have ivy-style patterns.
When publishMavenStyle is true, a POM is generated by the makePom action and published to the repository.
Add this line in your build.sbt
publishMavenStyle := true
Configuring Artifact Resolution
To resolve artifacts through Artifactory, simply add the following code snippet to your build.sbt file:
resolvers += "Artifactory" at "http://<host>:<port>/artifactory/<repo-key>/"
Deploying Artifacts
To deploy sbt build artifacts to repositories in Artifactory, add the following code snippets to your build.sbt file.
For releases, add:
publishTo := Some("Artifactory Realm" at "http://<host>:<port>/artifactory/<repo-key>")
credentials += Credentials("Artifactory Realm", "<host>", "<USERNAME>", "<PASS>")
For snapshots, add:
publishTo := Some("Artifactory Realm" at "http://<host>:<port>/artifactory/<repo-key>;build.timestamp=" + new java.util.Date().getTime)
credentials += Credentials("Artifactory Realm", "<host>", "<USERNAME>", "<PASS>")
Where host and port are the host URL and port on which Artifactory is running, and repo-key is the Artifactory repository to which you are deploying artifacts.
I am trying to publish artifact with SBT to remote Nexus repository with command sbt publish.
My build.sbt:
credentials += Credentials("Sonatype Nexus", "nexus.local", "username", "password")
publishTo := Some("Sonatype Nexus" at "http://nexus.local:8080/repository/releases")
But I get an error:
Repository for publishing is not specified
I successfully push to this repository with Maven. Could you help please?
There are a lot of questions and guides about how to include SBT resolver to a project, but still there are no info about what is an SBT resolver and how can it help including dependencies to a project?
sbt resolver is the configuration for repository that contains jars and their dependencies
for example the below is a resolver definition for a repository called Sonatype and it points at snapshot releases (dev versions)
resolvers +=
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
When you specify a dependncy in sbt (or any other build system for that matter) the build system needs to know where to look to find that dependency. in JVM world a lot of dependencies are stored in the default maven2 repo ( https://repo1.maven.org/maven2/) but sometimes you need to use other custom repositories and you'd define add a resolver for that
I've added this code to my Build.scala.
lazy val root = Project("root", file(".")) dependsOn(jbcrypt)
lazy val jbcrypt = RootProject(uri("https://github.com/jeremyh/jBCrypt.git"))
But sbt fails with the error:
[error] (root/*:update) sbt.ResolveException: unresolved dependency: default#jbcrypt_2.11;0.1-SNAPSHOT: not found
How to tell sbt that it is Java not Scala?
How to reference to a specific branch or tag?
Thank you.
Building a project from source is only possible if the referenced project is a sbt project. sbt doesn't know of all the different build systems out there, so how is it supposed to know how to build a non sbt project?
It is possible to add support for other build systems through a sbt plugin but this may be a lot of work.
Your referenced project is a simple Maven project, which means that you can easily create a sbt project from it. Just fork the repo and create a build.sbt with the following content:
scalaVersion := "2.11.5"
projectDependencies += "junit" % "junit" % "3.8.1" % "test"
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")
}
This is the minimal code that was necessary to get it up and running. sbt seems to require that a publish repo is specified, it also seems to require an explicit Scala version. The dependency is already specified by your linked Maven project.
Of course, you know need to change the URI of RootProject to point to the location of your fork.
To your second question: You can reference a commit/tag/branch by appending it to the URI, separated with a # sign:
uri("git://github.com/your/repo#<commit-hash/tag/branch>")
I'm trying to use finagle in a Scala project and I'm wondering if there's a Maven repository out there which has the jars. I want to add it as a dependency and rather not compile all the stuff locally.
Here is an example build.sbt file for one of my projects which uses Finagle 5.0.0:
https://github.com/cb372/finagle-beanstalk/blob/d2ac139999fd49a6dc4fcd6e1097b07da234b408/build.sbt
Basically you need:
resolvers += "Twitter Maven repo" at "http://maven.twttr.com/"
libraryDependencies += "com.twitter" % "finagle-core" % "5.0.0"
When I checked a few days ago, the latest version of finagle-core available in the Maven repo was 5.3.1, so you should probably use that.
from http://twitter.github.com/finagle/
Note: Maven Artifacts are published to the public twitter maven repo
at http://maven.twttr.com.