grails-core icon indicating copy to clipboard operation
grails-core copied to clipboard

Grails 5.2.0 create-app, throws "Cannot resolve dependency org.springframework.boot:spring-boot-dependencies:2.7.0 no repositories are defined"

Open akiesh22 opened this issue 2 years ago • 3 comments

Expected Behavior

Application should have started up.

Actual Behaviour

I am starting a new grails application, I am using grails 5.2.0 (Latest as of today)

I generated a skeleton using :

~/grails-5.2.0/bin/grails create-app data_portal --profile=react

However, trying to run the application always gives me following error :

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

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
Where: Build file '.../server/build.gradle' line: 20

What went wrong: A problem occurred evaluating project ':server'.

Receiver class grails.util.Environment does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.

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. ==============================================================================
2: Task failed with an exception.
What went wrong: A problem occurred configuring project ':server'.
Failed to notify project evaluation listener. Receiver class grails.util.Environment does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.

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/

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

CONFIGURE FAILED in 233ms

This is how my settings.gradle looks like

include 'client', 'server'

This is how my server/build.gradle looks like

buildscript {
    repositories {
        maven { url "https://repo.grails.org/grails/core" }
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
        classpath "com.github.node-gradle:gradle-node-plugin:1.3.0"
        classpath "org.grails.plugins:hibernate5:7.3.0"
        classpath "org.grails.plugins:views-gradle:2.3.2"
    }
}

version "0.1"
group "dp"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.node-gradle.node"
apply plugin:"org.grails.plugins.views-json"

repositories {
    maven { url "https://repo.grails.org/grails/core" }
}

dependencyManagement {
    imports {
        mavenBom('org.springframework.boot:spring-boot-dependencies:2.7.0')
    }
    applyMavenExclusions false
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    compileOnly "io.micronaut:micronaut-inject-groovy"
    console "org.grails:grails-console"
    implementation "org.springframework.boot:spring-boot-starter-logging"
    implementation "org.springframework.boot:spring-boot-starter-validation"
    implementation "org.springframework.boot:spring-boot-autoconfigure"
    implementation "org.grails:grails-core"
    implementation "org.springframework.boot:spring-boot-starter-actuator"
    implementation "org.springframework.boot:spring-boot-starter-tomcat"
    implementation "org.grails:grails-plugin-url-mappings"
    implementation "org.grails:grails-plugin-rest"
    implementation "org.grails:grails-plugin-codecs"
    implementation "org.grails:grails-plugin-interceptors"
    implementation "org.grails:grails-plugin-services"
    implementation "org.grails:grails-plugin-datasource"
    implementation "org.grails:grails-plugin-databinding"
    implementation "org.grails:grails-web-boot"
    implementation "org.grails:grails-logging"
    implementation "org.grails.plugins:cache"
    implementation "org.grails.plugins:async"
    implementation "org.grails.plugins:hibernate5"
    implementation "org.hibernate:hibernate-core:5.6.9.Final"
    implementation "org.grails.plugins:views-json"
    implementation "org.grails.plugins:views-json-templates"
    profile "org.grails.profiles:react"
    runtimeOnly "org.glassfish.web:el-impl:2.2.1-b05"
    runtimeOnly "com.h2database:h2"
    runtimeOnly "org.apache.tomcat:tomcat-jdbc"
    runtimeOnly "javax.xml.bind:jaxb-api:2.3.1"
    testImplementation "io.micronaut:micronaut-inject-groovy"
    testImplementation "org.grails:grails-gorm-testing-support"
    testImplementation "org.mockito:mockito-core"
    testImplementation "io.micronaut:micronaut-http-client"
    testImplementation "org.grails:grails-web-testing-support"
    testImplementation "org.grails:views-json-testing-support"
    testImplementation "org.hibernate.validator:hibernate-validator:6.1.7.Final"
}

bootRun {
    ignoreExitValue true
    jvmArgs(
        '-Dspring.output.ansi.enabled=always', 
        '-noverify', 
        '-XX:TieredStopAtLevel=1',
        '-Xmx1024m')
    sourceResources sourceSets.main
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(GroovyCompile) {
    configure(groovyOptions) {
        forkOptions.jvmArgs = ['-Xmx1024m']
    }
}

tasks.withType(Test) {
    useJUnitPlatform()
}

This is how my client/build.gradle looks like:

plugins {
    id "com.github.node-gradle.node" version "1.3.0"
}

node {
    version = '10.15.0' // https://nodejs.org/en/
    yarnVersion = '1.13.0' // https://yarnpkg.com/en/
    download = true
}

task bootRun(dependsOn: 'start') {
    group = 'application'
    description = 'Run the client app (for use with gradle bootRun -parallel'
}

task start(type: YarnTask, dependsOn: 'yarn') {
    group = 'application'
    description = 'Run the client app'
    args = ['run', 'start']
}

task build(type: YarnTask, dependsOn: 'yarn') {
    group = 'build'
    description = 'Build the client bundle'
    args = ['run', 'build']
}

task test(type: YarnTask, dependsOn: 'yarn') {
    group = 'verification'
    description = 'Run the client tests'
    args = ['run', 'test']
}

task eject(type: YarnTask, dependsOn: 'yarn') {
    group = 'other'
    description = 'Eject from the create-react-app scripts'
    args = ['run', 'eject']
}

Steps To Reproduce

No response

Environment Information

  • macOS Monterey
  • openjdk version "1.8.0_292"

Example Application

No response

Version

5.2.0

akiesh22 avatar Jun 29 '22 07:06 akiesh22

This seems to be resolving after changing from grailsGradlePluginVersion=5.2 to grailsGradlePluginVersion=5.1.x

akiesh22 avatar Jun 29 '22 07:06 akiesh22

Thank you for taking time to report this issue. This is definitely a bug. From error logs it seems that the application is unable to resolve the dependency due to missing repository under Gradle as:

repositories {
    maven { url "https://repo.grails.org/grails/core" }
}

The artifact should resolved from https://repo.grails.org/ui/native/core/org/springframework/boot/spring-boot-dependencies/2.7.0/

puneetbehl avatar Jun 30 '22 03:06 puneetbehl

You should be able to workaround by moving repositories block in the file build.gradle under allProjects as:

allprojects {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
}

puneetbehl avatar Sep 15 '22 16:09 puneetbehl

Watching (also have this issue using 5.2.3 and the above workaround does not seem to help)

amaciejk avatar Oct 04 '22 10:10 amaciejk

This error is still happening to me on 5.2.5. Workaround above does not make any difference.

horizondave avatar Nov 16 '22 15:11 horizondave

@horizondave This issue is already closed and I believe that you must be facing similar problem in a different scenario. Please report another issue with simple steps to replicate.

puneetbehl avatar Dec 16 '22 11:12 puneetbehl