How to build from my checkout directory ... with a twist - grails

We're using Maven 3 with Git as our SCM system. We are using the latest version of the scm plugin (1.5). Our project is in Grails 1.2.1 (Java 1.5). The question is, how do I run a single command to generate a WAR file after doing a checkout from our repo?
This question seems complicated by the fact that we're using the a Grails project (and hence the maven-grails plugin, version 1.3.4). Grateful for any info you have, - Dave

I'm assuming that the command line below below wont work for you because of your requirement to use maven.
grails <environment> war
You can generate a pom.xml for your existing grails project with the following command. This can be a useful starting point.
mvn grails:create-pom
More documentation about grails's maven integration can be found here:
http://grails.org/doc/latest/guide/4.%20The%20Command%20Line.html#4.5%20Ant%20and%20Maven

Related

Equivalent to maven-install command in Grails 3

I have begun the journey of migrating my Grails apps to version 3.
I have a number of plugins that I with Grails 2 have installed to the local maven repository with the maven-install command available with the release plugin. They have then been easily accessible to my main project for import.
As far as I can see the release plugin does not exist for Grails 3. My question is, should I try to migrate the release plugin or is there some other, better way, in Grails 3?
If you have
apply plugin: 'maven-publish'
and the two apply from: 'https://raw.githubusercontent.com/... lines from the build.gradle file that's created for you when you create a Grails 3 plugin you can run
./gradlew install
to do the same thing as the maven-install script.

How do I configure installation of plugins in Grails 3.0.4?

I'm porting an application from Grails 2.4.2 to Grails 3.0.4, and I'm having problems with some plugins that were installed previously. Specifically one that is referenced in a GSP page. The particular plugin is called google-visualizer, and I've found some info here:
https://github.com/bmuschko/grails-google-visualization/blob/master/grails-app/views/formatter/index.gsp
However, I am clueless as to how to install this. I have not found the particular jar file in any maven repo, so I can't add it as a Gradle dependency. In general, where is it documented how to install existing plugins in Grails 3.X? I've read the documentation on how to port existing plugins, but that's not what I'm trying to do. I simply want to tell Grails/Gradle that I'd like to use this particular plugin and have it resolve the dependencies for me. I've tried this syntax as shown here:
https://grails.org/plugins/tag/grails3
Example:
compile ":quartz:1.0.2"
I've put that line in the dependencies block in my build.gradle file, but it doesn't work. I get errors from Gradle. Is there a particular Maven repo that has to be added for plugins? Any help with this is appreciated. Thanks.
Grails 1.x and 2.x plugins are sadly not compatible with Grails 3.x.
You can find the plugins that already have been ported to Grails 3 at: https://bintray.com/grails/plugins/
The grails-google-visualization plugin is not released in a Grails 3 version, but from the repo, it appears that work has started on upgrading.
You can see the progress on a Grails 3 version in this issue: https://github.com/bmuschko/grails-google-visualization/issues/49
Benjamin searched for a new maintainer back some time ago, and found a volunteer - see this tread for details: https://twitter.com/bmuschko/status/498610606896066560
For those plugins that are most important, the Grails Core team maintains a list here: https://github.com/grails/grails-core/wiki/Grails-3-Priority-Upgrade-Plugins
Some of the old plugins will be replaced by their Gradle counterpart, fx. the codenarc plugin, that exist in a Gradle version already.
A simple way is to find out the JAR file for the plugin and then use them in Grails 3.0.4. In this way there is no need to change the source code of the plugin

create POM with junit 4

I use Maven 3.0.4 and want to have junit 4 by default.
My projects are created with the command :
$>mvn archetype:create -DgroupId=my.group.id -DartifactId=myArtifactId -DpackageName=my.package.name
This puts a depency to junit version 3.8.1 in the created pom.xml, dispite the fact that verion 4.8.1 is already present.
There are no dependencies to junit in my global settings.xml, and I haven't a local .m2/repository/settings.xml. I don't want to remove the old version 3.8.1., but want that all new projects are created with version 4.8.1
Can I do this in my settings.xml (global or local does not matter)? And if so what is the correct syntax?
A couple things:
archetype:create is deprecated by archetype:generate; please use generate, it's interchangeable with create in your example.
As for a solution, I'd say the simplest thing to do is generate your project, edit the pom to have the correct junit version; and then from within your project run:
mvn archetype:create-from-project
Which will create an archetype based on your modifications, you simply need to install this with:
cd target/generated-sources/archetype/
mvn install
Now you can create new maven projects with this new archetype as you like with:
mvn archetype:generate -DgroupId=my.group.id -DartifactId=newArtifact -DpackageName=my.package.name -DarchetypeArtifactId=myArtifactId-archetype -DarchetypeGroupId=my.group.id
Hopefully this helps.

Grails and hudson plugin issue

I'm developing my first project in Grails framework. I'm using Spring Security Core plugin. On my machine, on newest IntelliJ Idea everything works fine. I can run, test and so on with no problems.
I have a remote machine with subversion where I upload my code and Hudson with Grails Plugin. Target which I call on my hudson builds is:
"test-app --non-interactive"
When I run build, everything goes fine - plugins are downloaded and then, bam!
Resolving plugin JAR dependencies ...
:: UNRESOLVED DEPENDENCIES :: ::::::::::::::::::::::::::::::
:: org.springframework#org.springframework.test;3.0.5.RELEASE: configuration not found in org.springframework#org.springframework.test;3.0.5.RELEASE: 'master'. It was required from org.grails.internal#League;0.1 test
Here I put whole output from Hudson Console of this project build.
That looks like a dependency issue with the Mail plugin, try going back to a non-snaphot version. I think 1.0 will be out shortly but see if 0.9 works.
Grails will automatically install the plugins it needs, you don't need to do anything manual on the build server.
You have to install the plugin of the remote machine. Because the plugins are not included in the code. The plugin will be installed under your_home/.grails/grails_version/plugins (or project/your_project).

Installing Nimble for Grails

I came across Nimble yesterday, but couldn't get past Step 1, configuring BuildConfig.groovy to find the Nimble's remote repository.
My BuildConfig.groovy file is one line:
grails.plugin.repos.discovery.intient="http://intient.com/downloads/grails/
Here is the message I get when running grails install-plugin nimble 0.2:
Welcome to Grails 1.1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /opt/dev/sdks/grails-1.1.1
Base Directory: /home/wraith/dev/source/demo
Running script /opt/dev/sdks/grails-1.1.1/scripts/InstallPlugin.groovy
Environment set to development
No authentication for svn repo at intient ...
Reading remote plugin list ...
Reading remote plugin list ...
Reading remote plugin list ...
Plugin 'nimble' was not found in repository. If it is not stored in a configured repository you will need to install it manually. Type 'grails list-plugins' to find out what plugins are available.
This is the first time I have tried to install a plugin not in the official repository. What is the best way to narrow down if it is a problem at Intient.com or with my configuration?
Follow these instructions with the following modifications:
Step 1 is correct
Instead of using the remote repository, download the zipped plugin
Move the plugin to ~/dev/plugins
grails install-plugin ~/dev/plugins/grails-nimble-0.2.zip
Steps 3-5 are correct
We were performing some maintenance on intient.com and the load balancer wasn't providing this content for the last 12 hours or so (oops!).
Should be sorted now but the steps Wraith Monster gave above work for a manual install as well.
Once Grails 1.2 proper hits Nimble will be part of the official plugin repo and we won't need to worry about this at all.
you could always download the zip file for the plugin and install it manually
Download source code from http://github.com/intient/nimble
Unzip under your plugins directory of your project (usually under ${USER_HOME}/.grails/<grails-version>/projects/<myproject>/plugins)
Rename the extracted folder into "nimble-0.2"
Remove from BuildConfig the line grails.plugin.repos.discovery.intient="http://intient.com/downloads/grails/"
Edit the file application.properties of your project and add the line plugins.nimble=0.2
If not installed under your project, you should install the plugins : shiro (version 1.0-SNAPSHOT at least) and mail (>0.6). (run command grails install-plugin <pluginName> <version>)
Start directly from Step 3
It should work (at least, it worked for me). Good luck

Resources