I am trying to write a build.gradle
for my Spring boot Application.(gradle v.6.5.1
)
After build, I want to deploy it to the private Nexus repo.(with asset zip file)
The problem is... When I execute command gradle build publish --debug
, It uploads the bootJar, but not asset zip file. And there are no suspicious messages in the console.
Here is the part of the build.gradle
plugins {
...
id "maven-publish"
}
task assembleAssets(type:Zip) {
archiveFileName = "${rootProject.name}-${rootProject.version}.zip"
destinationDirectory = file("${buildDir}/libs/")
from "assets"
classifier "assets"
}
tasks.build.dependsOn(assembleAssets)
# From bootJar
configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(bootJar)
}
}
publishing {
publications {
bootJarDeploy(MavenPublication) {
from components.java
}
assetDeploy(MavenPublication) {
artifact source: assembleAssets, extension: 'zip', classifier: 'config'
}
}
repositories {
maven {
url = "${nexus_url}"
credentials {
username repoUser
password repoPw
}
}
}
}
I checked Zip file generation in local directory and uploaded jar(bootJar) in Nexus UI. But There is no zip file in Nexus...
I would like to upload my zip archive file to Nexus.
Is there something I missed or simply it is not good to use maven-publish
plugin with bootJar
?
Thanks.
below publishes zip file
task zipJ(type: Zip, dependsOn: jar) {
from sourceSets.main.runtimeClasspath
}
build.dependsOn zipJ
publishing {
publications {
maven(MavenPublication) {
//from components.java
artifact jar
artifact zipJ
}
}
}