3

I'm trying to package my Grails 3.1.5 application.

Running grails package (or grails war) results in the following:

FAILURE: Build failed with an exception.

* What went wrong:
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(Ljava/util/List;Lgroovy/lang/Closure;)Ljava/util/List;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.205 secs
| Error Command [package] error: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.6-bin.zip'. (Use --stacktrace to see the full trace)

Running with --stacktrace gives:

Caused by: java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.DefaultGroovyMethods.each(Ljava/util/List;Lgroovy/lang/Closure;)Ljava/util/List;
        at asset.pipeline.gradle.AssetCompile.getSource(AssetCompile.groovy:188)
        at asset.pipeline.gradle.AssetCompile_Decorated.getSource(Unknown Source)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$PropertyInfo$4.create(AnnotationProcessingTaskFactory.java:460)
        at org.gradle.util.SingleMessageLogger.whileDisabled(SingleMessageLogger.java:166)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$PropertyInfo.getValue(AnnotationProcessingTaskFactory.java:458)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$Validator$1.call(AnnotationProcessingTaskFactory.java:262)

My versions are:

| Grails Version: 3.1.5
| Groovy Version: 2.4.6
| JVM Version: 1.8.0_91

I've removed the .gradle cache folder, run a grails clean, but no luck.

Edit: My current solution is to use gradle to build the war; gradle war produces an uber-jar under build that I can use for deployments. Would sure by nice to use grails for this (unless I'm missing something).

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alex
  • 8,093
  • 6
  • 49
  • 79
  • It is unclear what is going wrong but I expect that you have a wrong version of something in the mix. The error message indicates that Gradle 2.6 is being used. A newly created Grails 3.1.5 app should use Gradle 2.9. I would investigate that and see if that is relevant. – Jeff Scott Brown May 02 '16 at 16:33
  • The latest version of Gradle I can find is 2.13; why & how would Grails be using Gradle 2.9? – Alex May 02 '16 at 16:40
  • "how would Grails be using Gradle 2.9?" - See https://github.com/grails/grails-profile-repository/blob/29bccd9bc76f1f9d844022401da46e1ee37d3be1/profiles/base/skeleton/gradle.properties#L2 and https://github.com/grails/grails-profile-repository/blob/29bccd9bc76f1f9d844022401da46e1ee37d3be1/profiles/base/skeleton/gradle/wrapper/gradle-wrapper.properties#L6. Those configure the version of Gradle that will be engaged while using `gradlew`. – Jeff Scott Brown May 04 '16 at 10:13
  • Is a **gradle wrapper** version the same as a Gradle version? – Alex May 06 '16 at 07:04
  • "Would sure by nice to use grails for this" - I can't tell what is wrong without seeing a project which demonstrates that problem but `./gradlew assemble` will generate the `.war` file if the `war` plugin is installed, and that is what most folks do. If the `war` plugin is not installed then `./gradlew assemble` will generate an executable `.jar` file. – Jeff Scott Brown May 09 '16 at 19:03
  • See https://github.com/grails/grails-core/issues/9923 – Jeff Scott Brown May 09 '16 at 19:13
  • Thanks @JeffScottBrown, I'll try to use gradlew from now on. Is there a part on the docs about this? I'd like to get some background to it/understand common & best practices. – Alex May 10 '16 at 08:16
  • See recent comments at https://github.com/grails/grails-core/issues/9923. Is there a `settings.gradle` file in the directory above your project directory or anywhere in the chain of parent directories above your project directory? – Jeff Scott Brown May 10 '16 at 09:35
  • Just catching up now. I'll reply there. Thank you for your help & spending time investigating. I'll update tonight. – Alex May 10 '16 at 10:06
  • I encountered the same error message when using the "gradle" command from within a Grails project. In my case, the gradle in my PATH was an older version than Grails' version of gradle. The easiset fix is to use "gradlew" from the Grails project, instead. – RMorrisey Mar 22 '17 at 18:11

2 Answers2

0

I have worked around this by using:

./gradlew clean assemble

This produces a WAR in ./build/libs/.

It's possible this is caused by a bug on in Grails, as discussed here.

Alex
  • 8,093
  • 6
  • 49
  • 79
0

In my case, this error cropped up when using an older grails wrapper (grailsw) file. The solution was to use gradlew and the Grails CLI in my path, instead of using the old grailsw.

RMorrisey
  • 7,637
  • 9
  • 53
  • 71