Search code examples
javagradlegrailsgroovy

Cannot build newly created Grails 6.0.0 app with provided Gradle wrapper or system Gradle


Configuration:

MacOS Ventura, 13.5

JDK: Liberica JDK 11, and/or Liberica JDK 17

System Gradle: Gradle 8.2.1

Grails: Grails Version: 6.0.0

Problem:

I can run

$> grails create-app foobar

to create a new, empty Grails app. That part works fine.

I can then cd into the 'foobar' directory and run

$> ./gradlew clean build

And I'm met by the following error when using the JDK 11 mentioned above:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':integrationTest'.
> Could not create task ':mergeTestReports'.
   > 'org.gradle.api.file.DirectoryProperty org.gradle.api.tasks.testing.TestReport.getDestinationDirectory()'

If I try instead building with the system Gradle:

$> gradle clean build

I get this (again with JDK 11):

> Configure project :
Cannot resolve reloading agent JAR: Failed to resolve imported Maven boms: Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.7.12 because no repositories are defined.
Required by:
    project :

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/prhodes1/development/experimental/grails/foobar/build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'foobar'.
> Failed to apply plugin 'org.grails.grails-gsp'.
   > Could not create task ':compileGroovyPages'.
      > Could not create task of type 'GroovyPageForkCompileTask'.
         > java.lang.InstantiationException (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring root project 'foobar'.
> Could not resolve all files for configuration ':runtimeClasspath'.
   > Cannot resolve external dependency io.micronaut:micronaut-inject-groovy:3.9.3 because no repositories are defined.
     Required by:
         project :

If I try with JDK 17, using the Gradle wrapper, I get pretty much the same error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':integrationTest'.
> Could not create task ':mergeTestReports'.
   > 'org.gradle.api.file.DirectoryProperty org.gradle.api.tasks.testing.TestReport.getDestinationDirectory()'

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

And likewise for the combination of JDK 17 and system Gradle:

> Configure project :
Cannot resolve reloading agent JAR: Failed to resolve imported Maven boms: Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.7.12 because no repositories are defined.
Required by:
    project :

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/prhodes1/development/experimental/grails/foobar/build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'foobar'.
> Failed to apply plugin 'org.grails.grails-gsp'.
   > Could not create task ':compileGroovyPages'.
      > Could not create task of type 'GroovyPageForkCompileTask'.
         > java.lang.InstantiationException (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring root project 'foobar'.
> Could not resolve all files for configuration ':runtimeClasspath'.
   > Cannot resolve external dependency io.micronaut:micronaut-inject-groovy:3.9.3 because no repositories are defined.
     Required by:
         project :

Also, FYI, the Gradle wrapper created by the grails create-app command is for version 7.2

C02FK2T0ML85:foobar prhodes1$ ./gradlew --version

------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------

Build time:   2021-08-17 09:59:03 UTC
Revision:     a773786b58bb28710e3dc96c4d1a7063628952ad

Kotlin:       1.5.21
Groovy:       3.0.8
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          17.0.6 (BellSoft 17.0.6+10-LTS)
OS:           Mac OS X 13.5 x86_64

So basically I'm stuck. I can't get the generated Grails project to build with either JDK 11 (which is documented as the minimum requirement for Grails 6, per the docs) nor JDK 17, using the generated wrapper or a system install of a recent Gradle. If anybody has any thoughts on how to resolve this and get this Grails app building, I would very much appreciate your insights.


Solution

  • Tried the same command that you had provided but I didn't get the issue you are seeing. Having said that just recently encountered similar issue : Unable to run integration tests when upgrading grails from version 5 to 6 - Could not determine the dependencies of task ':integrationTest'

    And seem like its related to gradle version as well. Make sure your "buildSrc" folder has gradle version 7.6.2.

    Also make sure the gradle/wrapper/gradle-wrapper.properties files have this line

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
    

    For me replacing the "buildSrc" folder again from fresh grails 6 application worked.

    enter image description here