I'm trying to deploy a jar + pom file to artifactory using gradle + artifactory plugin + maven-publish plugin.
I've tried multiple solutions from other sources like this and I think the spring-boot plugin is breaking stuff (because it edits the jar file)
The following script successfully uploads a .pom file, but not the .jar file generated by spring-boot. How can I get it to also upload that?
this is my build.gradle:
buildscript {
ext {
springBootVersion = '1.4.0.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0"
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: "com.jfrog.artifactory"
apply plugin: 'maven-publish'
apply from: "gradle/artifactory.gradle"
publishing {
publications {
mavenJava(MavenPublication) {
components.java
}
}
}
jar {
baseName = 'BatchParser'
}
version = '1.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.projectlombok:lombok:1.16.10')
...
testCompile('org.springframework.boot:spring-boot-starter-test')
}
and artifactory.gradle
artifactory {
contextUrl = 'url'
publish {
repository {
repoKey = 'libs-release-local'
username = 'user'
password = 'password'
}
defaults {
publications("mavenJava")
}
}
}
output of:
gradlew clean build artifactoryPublish
[buildinfo] Not using buildInfo properties file for this build.
:clean
:compileJava
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
:generatePomFileForMavenJavaPublication
:artifactoryPublish
Deploying artifact: http://url/libs-release-local/BatchParser/1.0/BatchParser-1.0.pom
Deploying build descriptor to: http://url/api/build
Build successfully deployed. Browse it in Artifactory under http://url/webapp/builds/BatchParser/1471949957594
There's a very subtle mistake in your publishing
block. from
is missing which is causing Gradle to silently not include the jar file in the publication. You need to update your publishing
block so that it looks like this:
publications {
mavenJava(MavenPublication) {
from components.java
}
}
If I were you, I'd open a Gradle usability bug for this. Silently doing nothing isn't very user friendly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With