Reputation: 20493
I have to manage multiple Grails version on Ubuntu, namely 1.3.9 and 2.0.4. I have installed Grails from the PPA, which allows to install multiple versions, but only creates one entry under bin, which points to the most recent version.
What is the simplest way to switch between Grails versions? Please note that I am new to Grails, and I would prefer a solution that does not depend on a particular IDE.
Upvotes: 1
Views: 1341
Reputation: 1016
I am using 7 grails version on my ubuntu machine . put the code below at the bottom of .bashrc file.
function switchGrails() {
echo “Switching to grails version: $1″
sudo rm /opt/grails
sudo ln -s /opt/$1 /opt/grails
echo “Done!”
}
alias grails225=’switchGrails “grails-2.2.5″‘
alias grails224=’switchGrails “grails-2.2.4″‘
alias grails223=’switchGrails “grails-2.2.3″‘
alias grails233=’switchGrails “grails-2.3.3″‘
alias grails235=’switchGrails “grails-2.3.5″‘
alias grails237=’switchGrails “grails-2.3.7″‘
alias grails2311=’switchGrails “grails-2.3.11″‘
After save and exit . Compile the .bashrc file . Type cd and . .bashrc to compile .bashrc file.
For more reference : https://pkashyap28.wordpress.com/2014/09/11/manage-multiple-grails-application-in-ubuntu/
Upvotes: 1
Reputation: 31222
I create a bash script (grails.sh
) placed inside the project to determine grails version and use the same version to compile/test/run the project.
#!/bin/bash
GRAILS_DIRECTORY="/usr/local"
GRAILS_VERSION=`grep app.grails.version application.properties | cut -d'=' -f2`
GRAILS_HOME="$GRAILS_DIRECTORY/grails-$GRAILS_VERSION"
export GRAILS_HOME
$GRAILS_HOME/bin/grails compile
$GRAILS_HOME/bin/grails test-app
$GRAILS_HOME/bin/grails -Dserver.port=8443 run-app
To execute the bash script
$ bash grails.sh
Upvotes: 0
Reputation: 4606
Groovy enVironment Manager. http://gvmtool.net/ Best tool not only for grails, it works with groovy, griffon, gradle, vertx, etc.
Upvotes: 2
Reputation: 547
I do this....
http://www.objectpartners.com/2010/10/12/update-fast-path-switching-between-projects/
Upvotes: 1
Reputation: 13122
I wrote a simple script, is not as elaborate as Ian Roberts answer, but this works for me. I suppose that Grails versions are installed under /opt
folder, also you need to add this file called grails
to PATH
.
#!/bin/bash
GRAILS_VERSION=`grep app.grails.version application.properties | cut -d'=' -f2`
GRAILS_HOME="/opt/grails-$GRAILS_VERSION"
export GRAILS_HOME
$GRAILS_HOME/bin/grails $*
There are more questions about this topic in Stack Overflow:
Upvotes: 2
Reputation: 122364
I use a script that parses the application.properties
file to determine which version of Grails a particular app requires and then calls that. I install this script as "grails" in my bin
directory. That way I can just run grails whatever
and the correct version of Grails will be used automatically.
The script I use is one I hacked together myself, but there are similar (and better engineered) solutions such as https://github.com/deluan/grails.sh available to download.
Upvotes: 3
Reputation: 31280
The easiest way is to specify the full path to the grails install you want to use instead of just relying on grails run-app
. That way you have control over which version of "grails" is being executed.
I'm sure there are other more advanced ways to do it, but simply specifying the location of the grails executable is the easiest.
That said, working from within an IDE may make this easier or harder, but how you do so will depend on the specific IDE.
Upvotes: 1