Gant script conversion / upgrade to Grails 3.3.2

7 views
Skip to first unread message

Duane Rosengartner

unread,
Aug 23, 2018, 3:56:02 PM8/23/18
to Grails Dev Discuss
In the Grails upgrade documentation, it appears the script I'm trying to implement is beyond the scope of create-script. In docs, I find the create-command command and I've started down this path. The doc states that the command will be included/available in maven, so I'm assuming that its referring to a packaging step that I have not pursued. I also believe I should be able to use grails and gradle to execute the script. I have 2 issues: Gradle is not recognized as a command from console and the script/command is not found using grails to execute. The script is in the application rather than within a separate plugin, so I'm seeing this as a gap in the docs. Ideas anyone? where I may have gone wrong in the install such that gradle did not get wired up properly?  I did not use the sdkman install procedure; I'm on windows and used the unzip method

Colin Harrington

unread,
Aug 25, 2018, 2:25:56 PM8/25/18
to grails-de...@googlegroups.com
Duane, 

Gradle is not recognized as a command from console
It sounds like the gradle install isn't complete and the gradle executable isn't on your $PATH.  Sometimes with Windows you have to log out or restart for environment variable to take hold. Also note there are a couple other options on windows that'll help manage installing packages for you.  Checkout https://gradle.org/install/ for more details. 

Did you know about the gradle-wrapper?  When you create a new Grails app, it includes both a gradlew and grailsw script.  Those scripts will download the appropriate versions and you can use them wherever you'd execute gradle or grails (respectively) from the terminal.  

ApplicationCommand vs Script
A command is a Grails Gradle task and shell command that can be run with the grails command from a terminal window.  Commands are backed by the ApplicationCommand Trait and are meant to be runnable from the grails shell (or directly like grails run-query).  They are useful for plugins that require access to an instance of the GrailsApplication at runtime.  For example the database migration plugin uses ApplicationCommands to handle the dbm-diff command.  You can run those commands via gradle (gradle dbmDiff) or via grails (grails dbm-diff) and the Commands need access to the application.

A script on the other hand is a groovy script and itends up extending GroovyScriptCommand.  scripts are just groovy scripts that have access to a few things, but not the whole entire classpath of your application.   See the section about creating custom scripts here https://docs.grails.org/3.3.x/guide/commandLine.html#creatingCustomScripts  I don't think scripts are bundled up with the application in the same way that ApplicationCommands are.

A third option would be to write(or find/extend) a Gradle task to accomplish what you are looking for.  There are a ton of gradle plugins out there that might line up with what you are looking for.  https://plugins.gradle.org/

It sounds like you are thinking the task you are migrating is beyond the scope of a script.  Its hard to point you in the right direction without knowing too much about what you are trying to accomplish.  What types of things did the old script accomplish?

Happy Trails,

On Thu, Aug 23, 2018 at 2:56 PM Duane Rosengartner <duan...@gmail.com> wrote:
In the Grails upgrade documentation, it appears the script I'm trying to implement is beyond the scope of create-script. In docs, I find the create-command command and I've started down this path. The doc states that the command will be included/available in maven, so I'm assuming that its referring to a packaging step that I have not pursued. I also believe I should be able to use grails and gradle to execute the script. I have 2 issues: Gradle is not recognized as a command from console and the script/command is not found using grails to execute. The script is in the application rather than within a separate plugin, so I'm seeing this as a gap in the docs. Ideas anyone? where I may have gone wrong in the install such that gradle did not get wired up properly?  I did not use the sdkman install procedure; I'm on windows and used the unzip method

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/abc63d48-5051-4e4c-8dca-96cd0fffebfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages