我正在使用gradle v3.4和shadowjar v1.2.4。我添加了以下任务,但在执行此操作时,我收到了下面复制的错误。我添加了ShadowJar类型的任务,以便能够从同一个项目生成不同的jar文件。
Shadowjar在此任务的上下文之外对我很好。
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')
}
使用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)
答案 0 :(得分:10)
将类型指定为com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar而不是ShadowJar为我解决了这个问题。
task someJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
答案 1 :(得分:4)
这也有效:
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
task someJar(type: ShadowJar) {
// ...
}