grails / grails-database-migration

Grails® framework Database Migration Plugin
Apache License 2.0
98 stars 115 forks source link

Grails 4 Error adding system properties to dbmUpdate #162

Closed virtualdogbert closed 4 years ago

virtualdogbert commented 5 years ago

Task List

Steps to Reproduce

  1. in build.gradle add the following:
    bootRun, test, integrationTest, dbmUpdate, runScript, console].each { runTask ->
    configure(runTask) {
        systemProperties System.properties
    }
    }

    This adds access to the system properties to each of those tasks.

Expected Behaviour

There should be no errors when refreshing gradle, and I should be able to run dbmUpdate, with it having access to the system properties(used in bootStrap for licencing check).

Actual Behaviour

I get the following error

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/tpelletier/git/tdstm/build.gradle' line: 243

* What went wrong:
A problem occurred evaluating root project 'tdstm'.
> Could not get unknown property 'dbmUpdate' for root project 'tdstm' of type org.gradle.api.Project.

* 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

CONFIGURE FAILED in 0s

I can run fine if I remove dbmUpdate, but then that task won't get the system properties needed to run.

I think this is probably related to Gradle 5, which comes with Grails 4.

Environment Information

Example Application

I'll try to get a sample app later today and add the link in the comments.

virtualdogbert commented 5 years ago

Here is the link to the example app: Example App

to reproduce the issue just load it into Intellij, and click the Gradle refresh button.

virtualdogbert commented 5 years ago

So trying to get this running on staging and I realized why I need the system properties available for dbmUpdate, it has to do with how we deal with the external config. We are using the external config plugin and we set one of the candidates to a system property.

Itaqua commented 4 years ago

Hey @virtualdogbert I found a work around (not sure if it's the best solution) but I just removed the by-task configuration in the build.gradle and changed to:

/*
// getting rid of the by-task pass system properties configuration
[bootRun, test, integrationTest, dbmUpdate, runScript, console].each { runTask ->
...
}
*/

// The run task added by the application plugin
// is also of type JavaExec.
tasks.withType(JavaExec) {
    // Assign all Java system properties from
    // the command line to the JavaExec task.
    systemProperties System.properties
}

Now dbmUpdate task (and the other ones) receives the system properties

virtualdogbert commented 4 years ago

I didn't realize we worked around it that way. I think we found that we didn't actually need the properties as they were only used for really old migrations, which we had culled from the list anyway.

In either case thanks for posting, just in case anyone else runs into this issue this would be a valid workaround.