我正在使用 gradle v3.4 和 shadowjar v1.2.4。我添加了以下任务,但执行此操作时在下面复制了一个错误。我添加了一个 ShadowJar 类型的任务,以便能够从同一个项目生成不同的 jar 文件。
Shadowjar 在此任务范围之外对我来说工作得很好。
毕业典礼
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')
}
使用堆栈跟踪出错
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)