Java with maven local repo: failed to download dependency of customized jar

I have a java SpringBoot project, that I build using ‘gradle build’ - which create the full executable jar with the default project name.
I also defined a customized jar task - to include only models from that project:

task clientJar(type: Jar, overwrite: true) {
from sourceSets.main.output
baseName = ‘models-only’
include ‘**/model/**’
}

when I run ‘gradle clientJar’ - the new jar is also generated sucesfully as ‘models-only-[version data].jar’

now, when I run ‘gradle uploadArchives’ the local maven .m2 repository is being created and into it are uploaded the custom clientJar AND a normal (non executable) jar containing all classes, with the defautlt name of the project.

  • I belive that the default jar is created due to the ‘plugin java’ line - which is ok. (if I rename my clientJar to the default project name - only the full jar is created).

anyway - THE PROBLEM is:
in a second project I need to use the clientJar as a dependancy, but when I specify it by name I get an error:
‘Could not find com.t2k.playanywhere:models_only:0.0.1-SNAPSHOT’

but if I change the dependency to use the default jar - it manage to download the jar properly from the local repository.

to clarify: at both attempt - the local maven repo contains the 2 jars, but only the default one is apparently found.

I’d appreciate any suggestions.
Thanks!

Edited:
I just found that the problem was due to the customized client jar is being stored in the same folder (at the local repo) as the default jar.
when I create it manually at a folder with the smae name as the client jar - the build dependency is found!

so I guess now the question is how to I fix my clientJar task code to be stored in it’s own folder?

to publish multiple artifacts you have to explicitly declare each artifact you want to publish to your Maven repository, Section 31.6.4.1. Multiple artifacts per project in the current userguide at https://docs.gradle.org/current/userguide/userguide_single.html#artifact_management covers this topic.

cheers,
René

Thanks,
but the example is really not sufficient - it’s barely have any proper documentation, and I couldn’t find any examples for this usage anywhere else…
for example: what is the ‘filter’ field? how do you define it?