-
Notifications
You must be signed in to change notification settings - Fork 13
Publishing
Geert Bevin edited this page Apr 5, 2024
·
2 revisions
Publishing artifacts to a Maven repository with bld is straight forward.
First, make sure the your build file is extending Project
, so that the publishing operation is available:
public class MyLibraryBuild extends Project {
// ...
}
Then you'll need to setup one or more repository to publish your artifact to.
For example to publish to Maven Central, add the following to your build file:
publishOperation()
.repository(SONATYPE_RELEASES.location())
.withCredentials(
property("sonatypeUser"),
property("sonatypePassword"));
Next, you'll need to provide some information about your artifact, developer(s) and scm, if any. For example:
publishOperation()
// ...
.info(new PublishInfo()
.groupId("com.example")
.artifactId("my-cool-library")
.name("My Library")
.description("My Library is very cool!")
.url("https://github.com/johndoe/mylibrary")
.developer(new PublishDeveloper()
.id("johndoe")
.name("John Doe")
.email("[email protected]")
.url("https://doe.com/"))
.license(new PublishLicense()
.name("The Apache License, Version 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0.txt"))
.scm(new PublishScm()
.connection("scm:git:https://github.com/johndoe/mylibrary.git")
.developerConnection("scm:git:[email protected]:johndoe/mylibrary.git")
.url("https://github.com/johndoe/mylibrary"))
.signKey(property("signKey"))
.signPassphrase(property("signPassphrase")));
In the examples above you'll noticed that the repository and signing credentials are set via properties. Be sure to read the section on how bld can be used to handle sensitive data.
Finally, to publish your artifact, use the following command:
./bld publish
Next learn more about Kotlin Support