Hi,
I’m trying to publish in local maven repo serveral different jars that are generated and located in build/libs. I want also to publish the associated pom (containing the dependencies) for each jar
I’m using maven-publish gradle as following:
def libsDir = file ("$buildDir/libs")
def jarFiles = libsDir.listFiles({ file -> file.name.endsWith('.jar')} as FileFilter)
publishing {
publications {
jarFiles.each { jarFile ->
def jarName = jarFile.name - '.jar'
create(jarName, MavenPublication) {
artifactId = jarName
artifact(jarFile)
from components.java
pom {
name = jarName
description = .....
properties = [....]
}
}
}
}
}
At the end of the execution of gradle publish task I got the following error:
invalid publication : multiple artifacts with identical extension and classifier (‘jar’, ‘null’)
the line from components.java adds the dependencies into the pom but at the same time it adds automatically jar and make double jar with the one that I add with artifact(jarFile)
and when I remove artifact(jarFile) line I got the no error but the pom file doesn’t have the dependencies. is there any way to solve this issu?
I’m using old version of gradle (5.4.1)
thank you for your help
best regards