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?
Related
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()
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 Using SBT Native Packager to build Docker Image,
and my build.sbt is :
packageName in Docker := name.value
version in Docker := version.value
dockerBaseImage := "java"
dockerRepository :=Some("index.docker.io/xyz")
dockerExposedPorts := Seq(8283)
I am trying to publish image to private docker hub,but its giving
[error] unauthorized: authentication required.
in build.sbt how can i specify hub userName and Password.
is there any other configuration that i am missing here.
Just like Abanoub said this isn't possible via configuration. But you should be able to make the build work by executing docker login in your shell and the packager should then work as expected.
We are using sbt 0.13.9 and we want to use a private GitHub repo to store company-wide dependencies.
I try to add a private GitHub repo to the resolvers like this:
resolvers += Resolver.ssh("Company Repo", "git#github.com:company/company-repo.git", "/raw/master")(Resolver.ivyStylePatterns)
// or
resolvers += Resolver.ssh("Company Repo", "git#github.com:company/company-repo.git", "/raw/master")(Resolver.ivyStylePatterns) as("githubuser")
// or
resolvers += Resolver.ssh("Company Repo", "git#github.com:company/company-repo.git", "/raw/master")(Resolver.ivyStylePatterns) as("githubuser", "password")
// or
resolvers += {
val keyFile: File = new File(Path.userHome.absolutePath + "/.ssh/id_rsa")
Resolver.ssh("Company Repo", "git#github.com:company/company-repo.git", "/raw/master")(Resolver.ivyStylePatterns) as("githubuser", keyFile)
}
// or
resolvers += {
val keyFile: File = new File(Path.userHome.absolutePath + "/.ssh/id_rsa")
Resolver.ssh("Company Repo", "git#github.com:company/company-repo.git", "/raw/master")(Resolver.ivyStylePatterns) as("githubuser", keyFile, "keyFilePassword")
}
(For the resolvers where no user and/or no password was supplied a popup appears to enter the username/password.)
However, it is always failing:
[warn] ==== Company Maven Repo: tried
[warn] com.company/my-module_2.11/2.0.0/ivys/ivy.xml
The location of the files inside the repo are correct, I am 100% sure.
Can sbt handle git repos as resolvers at all? Did someone has a working example with a private GitHub repo? Bitbucket would be fine too.
Again, the repo is private and the repos is a git repo, not http(s) nor sftp.
Oh, and yes, I know bintray, but right now we don't want to pay 45 USD monthly to manage like 3 dependencies for 2 devs.
PS: My configuration is based on examples from
https://groups.google.com/forum/#!topic/maven-and-scala/dhzEZ0dR_is and
SBT doesn't use ssh-based resolver to resolve dependency
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>")