GradleUp / 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.
https://www.gradleup.com/shadow/
Apache License 2.0
3.75k stars 396 forks source link

two jar files in maven repo #898

Open onixred opened 10 months ago

onixred commented 10 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 7 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 5 months 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]                     
       }
    }
}