3

When I publish to a local maven repository from a Gradle project, I find that the main JAR file has a -plain suffix.

pdffer/pdffer-template/1.0-SNAPSHOT 
➜ ll
total 32
-rw-r--r--  1 fedmest  staff   918B Sep  1 16:39 maven-metadata-local.xml
-rw-r--r--  1 fedmest  staff   3.8K Sep  1 16:39 pdffer-template-1.0-SNAPSHOT-plain.jar
-rw-r--r--  1 fedmest  staff   1.9K Sep  1 16:39 pdffer-template-1.0-SNAPSHOT.module
-rw-r--r--  1 fedmest  staff   1.7K Sep  1 16:39 pdffer-template-1.0-SNAPSHOT.pom

When I include this library as a Maven dependency from a POM file, it cannot find it - it only works if I rename the main JAR to exclude the -plain suffix. Can I get Gradle to generate the JAR without the suffix? Any idea why the suffix appears, please?

fedmest
  • 709
  • 5
  • 17
  • To get the artifact `-plain` you have to define a classifier `plain` in your dependency... The question is why is it generated with a classifier.... – khmarbaise Sep 01 '21 at 16:24
  • Good question, I have no idea where it comes from... I have not consciously configured that in my gradle.build – fedmest Sep 01 '21 at 18:26
  • I have noticed that not all my projects have this issue. The ones that do are using the following plugins: 'org.springframework.boot' version '2.5.3' and 'io.spring.dependency-management' version '1.0.11.RELEASE'. Could they be applying this change? Would anybody know how to undo it? – fedmest Sep 03 '21 at 07:04
  • @fedmest, Im running into same thing.. by any chance did you get to know the root cause or solution? – Jags Dec 17 '21 at 03:45

1 Answers1

3

To disable 'plain', follow the springboot documentation: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#packaging-executable.and-plain-archives

jar {
    classifier = ''
}

I also found the answer here: https://stackoverflow.com/a/67752182/11723872

orid
  • 200
  • 3
  • 10