在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):xerial/sbt-sonatype开源软件地址(OpenSource Url):https://github.com/xerial/sbt-sonatype开源编程语言(OpenSource Language):Scala 68.0%开源软件介绍(OpenSource Introduction):sbt-sonatype pluginA sbt plugin for publishing your project to the Maven central repository through the REST API of Sonatype Nexus. Deploying artifacts to Sonatype repository is a requirement for synchronizing your projects to the Maven central repository. sbt-sonatype plugin enables two-step release of your Scala/Java projects.
After these steps, your project will be synchronized to the Maven central within ten minutes. No longer need to enter the web interface of Sonatype Nexus repository to performe these release steps.
Prerequisites
Configurationsproject/plugins.sbtImport sbt-sonatype plugin and sbt-pgp plugin to use // For sbt 1.x (sbt-sonatype 2.3 or higher)
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "(version)")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
// For sbt 0.13.x (upto sbt-sonatype 2.3)
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "(version)")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
build.sbtTo use sbt-sonatype, you need to create a bundle of your project artifacts (e.g., .jar, .javadoc, .asc files, etc.) into a local folder specified by publishTo := sonatypePublishToBundle.value
With this setting, If If necessary, you can tweak several configurations: // [Optional] The local staging folder name:
sonatypeBundleDirectory := (ThisBuild / baseDirectory).value / target.value.getName / "sonatype-staging" / (ThisBuild / version).value
// [Optional] If you need to manage unique session names by yourself, change this default setting:
sonatypeSessionName := s"[sbt-sonatype] ${name.value} ${version.value}"
// [Optional] Timeout until giving up sonatype close/promote stages. Default is 60 min.
sonatypeTimeoutMillis := 60 * 60 * 1000
// [If you cannot use bundle upload] Use this setting when you need to uploads artifacts directly to Sonatype
// With this setting, you cannot use sonatypeBundleXXX commands
publishTo := sonatypePublishTo.value
// [If necessary] Settings for using custom Nexus repositories:
sonatypeCredentialHost := "s01.oss.sonatype.org"
sonatypeRepository := "https://s01.oss.sonatype.org/service/local" $HOME/.sbt/(sbt-version 0.13 or 1.0)/sonatype.sbtFor the authentication to Sonatype API, you need to set your Sonatype account information (user name and password) in the global sbt settings. To protect your password, never include this file within your project. credentials += Credentials("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
"(Sonatype user name)",
"(Sonatype password)") (project root)/sonatype.sbtsbt-sonatype is an auto-plugin, which will automatically configure your build. There are a few settings though that you need to define by yourself:
Example settings: // Your profile name of the sonatype account. The default is the same with the organization value
sonatypeProfileName := "(your organization. e.g., org.xerial)"
// To sync with Maven central, you need to supply the following information:
publishMavenStyle := true
// Open-source license of your choice
licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
// Where is the source code hosted: GitHub or GitLab?
import xerial.sbt.Sonatype._
sonatypeProjectHosting := Some(GitHubHosting("username", "projectName", "[email protected]"))
// or
sonatypeProjectHosting := Some(GitLabHosting("username", "projectName", "[email protected]"))
// or if you want to set these fields manually
homepage := Some(url("https://(your project url)"))
scmInfo := Some(
ScmInfo(
url("https://github.com/(account)/(project)"),
"scm:[email protected]:(account)/(project).git"
)
)
developers := List(
Developer(id="(your id)", name="(your name)", email="(your e-mail)", url=url("(your home page)"))
) Publishing Your ArtifactThe basic steps for publishing your artifact to the Central Repository are as follows:
Note: If your project version has "SNAPSHOT" suffix, your project will be published to the snapshot repository of Sonatype, and you cannot use CommandsUsually, we only need to run
Individual Step Commands
Batch Operations
Other Commmands
Advanced Build SettingsSequential Upload Release (Use this for small projects)> ; publishSigned; sonatypeBundleRelease For cross-building projects, use > ; + publishSigned; sonatypeBundleRelease Parallelizing Builds When Sharing A Working FolderWhen you are sharing a working folder, you can parallelize publishSigned step for each module or for each Scala binary version:
Parallelizing Builds When Not Sharing Any Working FolderIf you are not sharing any working directory (e.g., Travis CI), to parallelize the release process, you need to publish a bundle for each build because Sonatype API only supports uploading one bundle per a staging repository. Here is an example to parallelize your build for each Scala binary version:
For sbt-sonatype 2.x: Using with sbt-release pluginTo perform publishSigned and sonatypeBundleRelease with sbt-release plugin, define your custom release process as follows: import ReleaseTransformations._
releaseCrossBuild := true // true if you cross-build the project for multiple Scala versions
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
) Publishing Maven ProjectsIf your Maven project (including Gradle, etc.) is already deployed to the staging repository of Sonatype, you can use Prepare the following two files: $HOME/.sbt/(sbt-version 0.13 or 1.0)/plugins/plugins.sbtaddSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "(version)") $HOME/.sbt/(sbt-version 0.13 or 1.0)/sonatype.sbtcredentials += Credentials("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
"(Sonatype user name)",
"(Sonatype password)") Alternatively, the credentials can also be set with the environment variables Then, run
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论