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

shadowJar task in Shadow Application Plugin fails with Gradle 5.0 snapshot #396

Closed
breskeby opened this issue Sep 10, 2018 · 6 comments
Closed
Milestone

Comments

@breskeby
Copy link

Shadow Version

2.0.4

Gradle Version

5.0-20180910095944+0000

Expected Behavior

  • shadowJar runs as usually and sets the correct main class. I noticed that the shadow plugin still uses convention mapping. This has always been internal api. The newer gradle version provide access to the JavaApplicationConvention via extension properties. This should be used instead as it is public api.

Actual Behavior

  • task evaluation fails with the following stacktrace:
* Exception is:
org.gradle.api.tasks.TaskValidationException: A problem was found with the configuration of task ':shadowJar'.
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.report(ValidatingTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
        at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)

build scan: https://scans.gradle.com/s/sist5cons7xbw

Gradle Build Script(s)

 buildscript {
   repositories {
     jcenter()
     maven {
       url "https://plugins.gradle.org/m2/"
     }
   }
   dependencies {
     classpath "com.github.jengelman.gradle.plugins:shadow:2.0.4"
   }
 }

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    // Apply the application plugin to add support for building an application
    id 'application'

    // Apply the groovy plugin to also add support for Groovy (needed for Spock)
    id 'groovy'
}

apply plugin: "com.github.johnrengelman.plugin-shadow"


repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // This dependency is found on compile classpath of this component and consumers.
    implementation 'com.google.guava:guava:23.0'

    // Use the latest Groovy version for Spock testing
    testImplementation 'org.codehaus.groovy:groovy-all:2.4.15'

    // Use the awesome Spock testing and specification framework even with Java
    testImplementation 'org.spockframework:spock-core:1.0-groovy-2.4'
    testImplementation 'junit:junit:4.12'
}

// Define the main class for the application
mainClassName = 'conventionMapping.App'

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

  • no jar created
@breskeby
Copy link
Author

looking further into this with some other gradle developers, we're sure this property was never set correctly. With 5.0 this value just gets evaluated now and hasn't been evaluated before. It was likely always null.
This can be fixed by either using afterEvaluate, or pass a closure as input property: jar.inputs.property('mainClassName', {application.mainClassName} ). Alternatively for newer Gradle versions you can use the Provider API

@johnrengelman
Copy link
Collaborator

Thanks @breskeby!
I'll get this patched up.

@felipecsl
Copy link
Contributor

This should be closed now

@johnrengelman
Copy link
Collaborator

Well. Once I release a version it will be.

@breskeby
Copy link
Author

@johnrengelman so you released a version with a fix? can't find anything in the plugin portal nor in the release overview here in github.

@johnrengelman
Copy link
Collaborator

Not yet. Soon. There is a 4.0.0-snapshot Jfrog OSS.

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

3 participants