It’s easier to make maven publications. Simplest way is to host your own maven repo on a Web Server.
In your gradle build file, ensure that this is the structure.
plugins {
id 'java'
id 'maven-publish'
}
group = 'com.yourdomain' // Reverse domain name
version = '1.0.0-SNAPSHOT'
This will set your publications there. Then you need to configure the output of the maven repo.
publishing {
repositories {
maven {
def releasesRepoUrl = "$buildDir/repos/releases"
def snapshotsRepoUrl = "$buildDir/repos/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
That is it. Now all you need to do is to clean build and publish.
$ ./gradlew clean build publish
Depending on the version you have there, repo will be generated in either $buildDir/repos/releases
or $buildDir/repos/snapshots
Now all you need to do is to upload those to a web server. Assuming the following things:
- Your maven server is https://maven.yourdomain.com/
- It points to /var/www/ in your server
- The releases and snapshots directories created above are copied to the server directory
All it takes for someone to use your artifact is to define the server and add an implementation to it.
repositories {
maven { url "https://maven.yourdomain.com/" }
}
dependencies {
implementation "com.yourdomain:artifact-name:1.0.0-SNAPSHOT"
}
And they can use it.
The same process applies if you want to host in maven central. However, instead of your own server, you have to go via Sonatype Nexus, and ask them to host your files in there.