https://docs.gradle.org/current/userguide/publishing_maven.html#header

gradle v5.3.1

plugins { java-library maven-publish id(“com.gradle.build-scan”) version “2.2.1” }

tasks.register(“sourcesJar”) { from(sourceSets.main.get().allJava) archiveClassifier.set(“sources”) }

tasks.register(“javadocJar”) { from(tasks.javadoc) archiveClassifier.set(“javadoc”) }

publishing { publications { create(“maven”) { from(components[“java”]) artifact(tasks[“sourcesJar”]) artifact(tasks[“javadocJar”]) } } repositories { maven { val releasesRepoUrl = “http://nexus.wiloon.com/repository/maven-releases" val snapshotsRepoUrl = “http://nexus.wiloon.com/repository/maven-snapshots" url = uri(if (version.toString().endsWith(“SNAPSHOT”)) snapshotsRepoUrl else releasesRepoUrl) credentials { username = “admin” password = “password” } } } }