【发布时间】:2017-04-06 14:46:27
【问题描述】:
我正在使用带有 Gradle 支持插件 1.3.8 的 Netbeans 8.0.2。
我添加了一个生成 uber-Jar 的任务,同时排除了一些签名文件,但是当我运行该任务时,它在第 38 行(compile group 行)显示如下错误:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'br.com.myproject.Sample'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
version='1.0.0'
// For DEBUG to work
ext.mainClass = mainClassName
task uniqueJar(type: Jar) {
baseName = project.name
from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': version,
'Main-Class': mainClassName
}
with jar
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// https://mvnrepository.com/artifact/org.eclipse.paho/org.eclipse.paho.client.mqttv3
compile group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version: '1.1.1' // line 38
testCompile group: 'junit', name: 'junit', version: '4.10'
}
错误信息:
执行:gradle unique Jar 参数:[uniqueJar, -c, D:\NetBeansProjects\testeMqtt\settings.gradle]
FAILURE:构建失败并出现异常。
其中:构建文件 'D:\NetBeansProjects\testeMqtt\build.gradle' 行:38
出了什么问题:评估根项目“testeMqtt”时出现问题。
配置 ':compile' 解析后无法更改依赖关系。
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
总时间:0.102 秒
如何修复 uber-Jar 任务?
【问题讨论】:
标签: java gradle gradle-plugin