unable to set type shadowJar for gradle task
Asked Answered
M

2

5

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)
Marinetti answered 15/5, 2017 at 15:32 Comment(1)
github.com/johnrengelman/shadow/issues/…Chromatology
M
11

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) {
Marinetti answered 15/5, 2017 at 15:54 Comment(1)
alternatively use imports - the same way it works in Java!Manxman
M
4

this would also work:

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

task someJar(type: ShadowJar) {
    // ...
}
Micahmicawber answered 20/1, 2018 at 20:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.