I’m currently migrating an Ant project over to Gradle and have been having a hard time publishing the necessary packages/artifacts over to GitLab.
For example, I have these two tasks to build the jars I need:
task buildClientJar(type: Jar) {
archiveAppendix.set("client")
manifest {
attributes("Class-Path": "Project-Client.jar")
attributes(common, "common")
}
include(["com/project/path/client/**", "serviceBean.xml"])
from configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
with jar
}
task buildModelJar(type: Jar) {
archiveAppendix.set("model")
manifest {
attributes("Class-Path": "Project-Model.jar")
attributes(common, "common")
}
include("com/project/path/model/**")
from configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
with jar
}
If I use the following :
publishing {
publications {
client(MavenPublication) {
artifact buildClientJar
artifactId "Project-Client"
}
model(MavenPublication){
artifact buildModelJar
artifactId "Project-Model"
}
}
repositories {[GitLab implementation]}
}
I get the packages I want as well as the Jar files containing the correct information, but there are two issues:
- There is no module file that is created like when publishing using
from components.java
. - The
pom.xml
that is published in those packages doesn’t contain any dependency information.
I’m sure the solution to both of these problems is similar, but I’m at a loss for how to create the pom.xml
I need for these packages. Especially since some of the dependencies required for the model jar aren’t required for the client jar.
Finally, this whole project needs to be bundled into a .war
file as well which is why I can’t separate each of these into their own projects or modules.