Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to set type shadowJar for gradle task

I am using gradle v3.4 and shadowjar v1.2.4. I added the following task but I get an error copied below when doing this. I added a task of type ShadowJar in order to be able to generate different jar files from the same project.

Shadowjar works fine for me outside the context of this task.

gradle

    task someJar(type: ShadowJar) {
    group = "shadow"
    description = "some executable jar"
    mainClassName = 'com.some.client.SomeClient'
    main = 'com.some.client.SomeClient'
    manifest.attributes 'Main-Class': 'com.some.client.SomeClient'
    classifier = 'someClient'
   from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
    configurations = [project.configurations.runtime]
    exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
}

error using stacktrace

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'ShadowJar' for root project 'someporject' of type org.gradle.api.Project.
        at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
        at org.gradle.groovy.scripts.BasicScript.getProperty(BasicScript.java:81)
        at build_2cp7m6fw08pxyu0f84a6pva88.run(/Users/continue/git/iso20022/build.gradle:202)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
like image 971
ali haider Avatar asked May 15 '17 15:05

ali haider


2 Answers

Specifying the type as com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar instead of ShadowJar resolved the issue for me.

task someJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
like image 127
ali haider Avatar answered Oct 28 '22 10:10

ali haider


this would also work:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

task someJar(type: ShadowJar) {
    // ...
}
like image 41
Sergii Redchuk Avatar answered Oct 28 '22 11:10

Sergii Redchuk