You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I encountered some difficulties when publishing my custom artifact to Maven Central. Here is my build.gradle.kts file. On line 25, I defined uberJar. When I execute ./gradlew clean build, I can find boilerplate-1.0.0-uber.jar file in the build/libs folder. However, when I execute ./gradlew clean publishToMavenLocal, I cannot find this file in ~/.m2/repository/io/github/exampleuser/boilerplate/1.0.0 folder. What should I do to make it appear here?
importcom.vanniktech.maven.publish.SonatypeHost
plugins {
id("java")
id("com.vanniktech.maven.publish") version "0.28.0"
}
group ="io.github.exampleuser"
version ="1.0.0"
repositories {
mavenCentral()
}
tasks {
test {
useJUnitPlatform()
}
val sourcesJar by creating(Jar::class) {
archiveClassifier ="sources"
from(sourceSets.main.get().allSource)
}
val uberJar by creating(Jar::class) {
archiveClassifier ="uber"
duplicatesStrategy =DuplicatesStrategy.EXCLUDE
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
javadoc {
isFailOnError =false
options {
// https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.htmlthisasStandardJavadocDocletOptions
isSplitIndex =true
memberLevel =JavadocMemberLevel.PUBLIC
encoding ="UTF-8"
}
}
val javadocJar by creating(Jar::class) {
archiveClassifier ="javadoc"
dependsOn(javadoc)
from(javadoc.get().destinationDir)
}
}
artifacts {
archives(tasks["uberJar"])
archives(tasks["sourcesJar"])
archives(tasks["javadocJar"])
}
dependencies {
implementation("com.google.code.gson:gson:2.10.1")
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
mavenPublishing {
// or when publishing to https://central.sonatype.com/
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
}
> ls -al build/libs
drwxr-xr-x 6 exampleuser staff 192 Mar 25 17:08 .
drwxr-xr-x 9 exampleuser staff 288 Mar 25 17:08 ..
-rw-r--r-- 1 exampleuser staff 94850 Mar 25 17:08 boilerplate-1.0.0-javadoc.jar
-rw-r--r-- 1 exampleuser staff 865 Mar 25 17:08 boilerplate-1.0.0-sources.jar
-rw-r--r-- 1 exampleuser staff 7988 Mar 25 17:08 boilerplate-1.0.0-uber.jar
-rw-r--r-- 1 exampleuser staff 988 Mar 25 17:08 boilerplate-1.0.0.jar
> ls -al ~/.m2/repository/io/github/exampleuser/boilerplate/1.0.0
-rw-r--r-- 1 exampleuser staff 94850 Mar 25 17:11 boilerplate-1.0.0-javadoc.jar
-rw-r--r-- 1 exampleuser staff 865 Mar 25 17:11 boilerplate-1.0.0-sources.jar
-rw-r--r-- 1 exampleuser staff 988 Mar 25 17:11 boilerplate-1.0.0.jar
-rw-r--r-- 1 exampleuser staff 2732 Mar 25 17:11 boilerplate-1.0.0.module
-rw-r--r-- 1 exampleuser staff 766 Mar 25 17:11 boilerplate-1.0.0.pom
-rw-r--r-- 1 exampleuser staff 1279 Mar 25 17:11 maven-metadata-local.xml
Thank you for your time.
The text was updated successfully, but these errors were encountered:
overcat
changed the title
How to publish custom artifact to Maven Central?
[Question] How to publish custom artifact to Maven Central?
Mar 25, 2024
Hello, I encountered some difficulties when publishing my custom artifact to Maven Central. Here is my
build.gradle.kts
file. On line 25, I defineduberJar
. When I execute./gradlew clean build
, I can findboilerplate-1.0.0-uber.jar
file in thebuild/libs
folder. However, when I execute./gradlew clean publishToMavenLocal
, I cannot find this file in~/.m2/repository/io/github/exampleuser/boilerplate/1.0.0
folder. What should I do to make it appear here?Thank you for your time.
The text was updated successfully, but these errors were encountered: