java - Gradle: Cannot change dependencies of configuration ':compile' after it has been resolved -
i'm using netbeans 8.0.2 gradle support plugin 1.3.8.
i've added task generate uber-jar while excluding few signature files, when run task displays error @ line 38 (the compile group line) follows:
apply plugin: 'java' apply plugin: 'application' mainclassname = 'br.com.myproject.sample' sourcecompatibility = '1.8' [compilejava, compiletestjava]*.options*.encoding = 'utf-8' version='1.0.0' // debug work ext.mainclass = mainclassname task uniquejar(type: jar) { basename = project.name from(configurations.compile.collect { it.isdirectory() ? : 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 } jar } repositories { mavencentral() // may define additional repositories, or remove "mavencentral()". // read more 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' } error message:
executing: gradle unique jar arguments: [uniquejar, -c, d:\netbeansprojects\testemqtt\settings.gradle]
failure: build failed exception.
where: build file 'd:\netbeansprojects\testemqtt\build.gradle' line: 38
what went wrong: problem occurred evaluating root project 'testemqtt'.
cannot change dependencies of configuration ':compile' after has been resolved.
try: run --stacktrace option stack trace. run --info or --debug option more log output.
build failed
total time: 0.102 secs
how can fix uber-jar task?
solved issue using shadow gradle plugin generating uber-jars:
apply plugin: 'java' apply plugin: 'application' mainclassname = 'br.com.myproject.sample' sourcecompatibility = '1.8' [compilejava, compiletestjava]*.options*.encoding = 'utf-8' version='1.0.0' // debug work ext.mainclass = mainclassname repositories { mavencentral() } dependencies { compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1' testcompile group: 'junit', name: 'junit', version: '4.10' } buildscript { repositories { jcenter() } dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4' } } apply plugin: 'com.github.johnrengelman.shadow'
Comments
Post a Comment