Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle install command stops working as soon as the shadow jar plugin is added #361

Closed
shabeepk opened this issue Mar 2, 2018 · 6 comments
Milestone

Comments

@shabeepk
Copy link

shabeepk commented Mar 2, 2018

Shadow Version

2.0.2

Gradle Version

4.5.1

Expected Behavior

It should build and install without a problem

Actual Behavior

gradle install command stops working as soon as the shadow jar plugin is added, even though it works fine before that.

Executing task 'install'...

:compileJava NO-SOURCE
:compileGroovy NO-SOURCE
:compileScala
:processResources NO-SOURCE
:classes
:jar
:startScripts
:distTar
:distZip
:shadowJar
A problem was found with the configuration of task ':shadowJar'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.
 - No value has been specified for property 'mainClassName'.
:startShadowScripts
Using TaskInputs.file() with something that doesn't resolve to a File object has been deprecated and is scheduled to be removed in Gradle 5.0. Use TaskInputs.files() instead.
:shadowDistTar
:shadowDistZip
:install FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':install'.
> Could not publish configuration 'archives'
   > A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact my-project:zip:zip:null, trying to add MavenArtifact  my-project:zip:zip:null.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Gradle Build Script(s)

plugins {
    id 'com.github.johnrengelman.shadow' version '2.0.2'
    id 'scala'
    id 'java'
    id 'groovy'
    id 'application'
    id 'maven'
    id 'maven-publish'
}

group = "my.company"
version = "2018.03.01"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            url "my.company.url"
            authentication {
                awsIm(AwsImAuthentication)
            }
        }
    }
}

mainClassName = 'my.company.my.project.Main'

repositories {
    mavenLocal()
    jcenter()
    maven {
        url "my.company.url"
        authentication {
            awsIm(AwsImAuthentication)
        }
    }

}

// In this section you declare the dependencies for your production and test code
dependencies {

    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.13'
    testCompile group: 'org.spockframework', name: 'spock-core', version: '1.1-groovy-2.4'

    testCompile group: 'org.scalatest', name: 'scalatest_2.11', version: '3.2.0-SNAP10'
    testCompile group: 'org.scalacheck', name: 'scalacheck_2.11', version: '1.13.5'

    testCompile group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.7.5'
    testCompile group: 'org.apache.hadoop', name: 'hadoop-aws', version: '2.7.5'
    testCompile group: 'org.apache.spark', name: 'spark-sql_2.11', version: '2.3.0'
    testCompile group: 'org.apache.spark', name: 'spark-repl_2.11', version: '2.3.0'
    testCompile group: 'org.apache.spark', name: 'spark-hive_2.11', version: '2.3.0'
    testCompile group: 'com.databricks', name: 'spark-redshift_2.11', version: '2.0.1'

    testCompile(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.6.5')
            {
                force = true
            }
    testCompile(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.6.5') {
        force = true
    }
    testCompile(group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.6.5') {
        force = true
    }

    //compile "org.scala-lang:scala-library:2.11+"
    //compile "org.scala-lang:scala-compiler:2.11+"

    //shadow group: 'org.apache.spark', name: 'spark-core_2.11', version: '2.3.0'
    shadow group: 'org.apache.spark', name: 'spark-sql_2.11', version: '2.3.0'
    shadow group: 'org.apache.spark', name: 'spark-repl_2.11', version: '2.3.0'
    shadow group: 'org.apache.spark', name: 'spark-hive_2.11', version: '2.3.0'
    shadow group: 'com.databricks', name: 'spark-redshift_2.11', version: '2.0.1'
    // shadow group: 'redis.clients', name: 'jedis', version: '2.9.0'
}

applicationDefaultJvmArgs = [
        "-Xms100g", "-Xmx200g",
        "-server", "-d64"
]

run {
    standardInput = System.in

    //systemProperties System.getProperties()
    //systemProperty "java.util.concurrent.ForkJoinPool.common.parallelism", "4"

    minHeapSize = "6g"
    maxHeapSize = "14g"
    //maxHeapSize = "112g"
    jvmArgs "-d64", "-server"

}

task repl(type: JavaExec) {
    main = "scala.tools.nsc.MainGenericRunner"
    classpath = sourceSets.main.runtimeClasspath
    standardInput System.in
    args '-usejavacp'
    systemProperties System.getProperties()
    minHeapSize = "1g"
    maxHeapSize = "14g"
    jvmArgs "-d64", "-server"

}

shadowJar {
    zip64 true
    mainClassName 'my.company.my.project.Main'
}

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

@denuno
Copy link

denuno commented Apr 6, 2018

You need to add a classifier, the jar and the shadowJar are using the same artifactId-- this is more of a maven publish plugin thing (really just a configuration thing, but the error gives a hint about the problem).

@jnehlmeier
Copy link

@denuno Have the same issue but don't understand your solution. shadowJar uses classifier "all" by default, right?

@jnehlmeier
Copy link

workaround can be read here: #347 (comment)

@johnrengelman
Copy link
Collaborator

This should be fixed in the latest version(4.0.2)

@jnehlmeier
Copy link

@johnrengelman I am using 4.0.2 with Gradle 4.10.2 and still have the issue. I had to use the mentioned workaround.

@johnrengelman
Copy link
Collaborator

johnrengelman commented Nov 21, 2018

ha. I'm not reading close enough.
Somehow i didn't manage to put this into a patch release. I'll do that now.

@johnrengelman johnrengelman added this to the 4.0.4 milestone Nov 21, 2018
msgilligan added a commit to ConsensusJ/consensusj that referenced this issue Mar 26, 2019
So that we can `./gradlew install`

Having source and java doc jars disabled is ok until we
release.

See:

GradleUp/shadow#361

GradleUp/shadow#452
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants