I'm using maven-publish plugin in Gradle to publish my Spring Boot application jar. I run the usual task: ./gradlew artifactorypublish
. However, the following error appeared, which I couldn't understand the meaning of:
> Task :assembleArtifact
> Task :application-jar:compileJava UP-TO-DATE
> Task :application-jar:processResources UP-TO-DATE
> Task :application-jar:classes UP-TO-DATE
> Task :application-jar:jar SKIPPED
> Task :generateMetadataFileForMavenJavaPublication FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateMetadataFileForMavenJavaPublication'.
> Invalid publication 'mavenJava':
- Publication only contains dependencies and/or constraints without a version. You need to add minimal version information, publish resolved versions (https://docs.gradle.org/6.1/userguide/publishing_maven.html#publishing_maven:resolved_dependencies) or reference a platform (https://docs.gradle.org/6.1/userguide/platforms.html)
My build.gradle:
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'maven-publish'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
publishing {
publications {
mavenJava(MavenPublication){
components.java
}
}
}
...
Versions:
Gradle 6.1
Spring Boot 2.2.6 (mostly generated from Spring Boot Initializr)
artifact bootJar
skips the generation of a .module metadata for me and, looking at the source code of DefaultMavenPublication.java, it always will. @Isank can you elaborate a bit more on the solution usingversionMapping
. Your links to sources are brilliant but leave me asking how one would get to the solution, rather than how the solution works. E.g. where do I find info on the strings java-api and java-runtime? – Maricruzmaridel