johnrengelman / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
http://imperceptiblethoughts.com/shadow/
Apache License 2.0
3.59k stars 386 forks source link

two jar files in maven repo #898

Open onixred opened 6 months ago

onixred commented 6 months ago

I want to publish a jar without dependencies to the repositories. But as a result of publishing I have two jar files. like a disaster, fat jar. help me.

Shadow Version

'8.1.1'

Gradle Version

'8.5'

Gradle Build Script(s)

plugins {
    id 'application'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
    id 'java-library'
    id 'maven-publish'
}
...

repositories {
    mavenCentral()
}

configurations {
    developmentOnly
}

dependencies {
    compileOnly 'com.github.spotbugs:spotbugs-annotations:4.8.2'
    implementation 'org.jetbrains:annotations:24.1.0'
    implementation 'org.bytedeco:javacv:1.5.9'
}

shadowJar {
    mergeServiceFiles()
}

publishing {
    publications {
        Library(MavenPublication) {
            from components.java
        }
    }
}
sharmando commented 2 months ago

same issue my subproject ingestion is generating:

ingestion.jar ingestion-all.jar

Despite I also have mergeServiceFiles() in my config

the -all file is much larger than the non -all.I Have a project on 7.1.2 and another on 8.1.1 and both are doing that. In the past I used an older version that it would only generate 1 jar

puritys commented 2 weeks ago

I remove from components.java and use customized artifacts to solve this issue

publishing {
    publications {
        maven(MavenPublication) {
            artifactId = 'xxx'
            version = version
            artifacts = [jar, javadocJar, sourceJar]                     
       }
    }
}