Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Working with Mavenized Grails projects in GGTS 3.1.0 *Updated for 3.1.0 release*

  1. #1
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default Working with Mavenized Grails projects in GGTS 3.1.0 *Updated for 3.1.0 release*

    EDIT: Rewritten for GGTS 3.1.0. I recommend that you stop using GGTS 3.1.0.M1 for maven integration and move to the latest nightly or the final release. Many fixes are now in.

    GGTS 3.1.0 now has support for mavenized grails projects. This feature requires m2e version 1.1 or later to be installed, which you can find on the dashboard. More information on working with and creating mavenized projects outside of GGTS can be found in the Grails docs.

    Before importing a mavenized grails project, you must make sure of the following in your project and GGTS installation:

    1. Your project uses Grails version 2.1.1 and grails-maven-plugin version 2.1.1 or any later full release. Build snapshots will not work.
    2. You have the same version of Grails unzipped and installed in your GGTS instance.
    3. You have successfully run mvn compile from the command line before importing the project (this ensures that the grails project is in the correct shape and that all plugins are correctly installed and available.
    4. Due to GRAILS-9406, you may need to explicitly add groovy-all 1.8.8 as a dependency. Add this to your dependency section:
      Code:
          <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy-all</artifactId>
              <version>1.8.8</version>
              <type>jar</type>
          </dependency>
    5. You have m2e (Eclipse plugin for maven) v1.1 or later installed in your GGTS.
    6. Your mavenized project uses the grails-app or the grails-plugin packaging. The war packaging will not work since it confuses WTP (Eclipse's Web Tools Project).


    You can import a mavenized grails project using File -> Import... -> Existing Maven project wizard:
    image04.jpg

    After importing your mavenized project, there may be a dialog asking you to convert the project to a Grails project:
    convert_to_grails.jpg

    You should click no. If you click yes, then your project will be imported without the Maven classpath container on it and you will likely have build errors. To get around this problem if you accidentally clicked yes, just run Maven -> Update project.

    Also, your project may have errors if Grails dependency management has not been enabled. You can manually turn on Grails dependency management like this:
    image03.png

    Once Grails dependency management has been enabled, you will notice that your mavenized project will have classpath containers both for Grails and for Maven:
    image05.png

    This is OK. In GGTS, mavenized grails projects are treated using a hybrid of Grails and Maven features, and so grails-ide and m2e share responsibility to manage dependencies and provide functionality. It shouldn't be a surprise that, interacting with these kinds of projects will be different than interacting with a pure grails project.

    First, here is a list of functionality known to work the same as before:

    • Editor support, Groovy search, GSP search, Groovy refactoring and other editing commands
    • The Project explorer view will show your project in a Grailsy way
    • Grails commands that only manipulate project files such as create-domain-class, generate-views. You can execute these commands in any of the normal ways: the lightweight grails pop-up dialog, the grails command wizard, or a custom grails launch.
    • Grails run-app and test-app will work as before including all debugging support


    And there are some parts of your project that must be interacted with differently:

    • Refresh dependencies/Project update: Don’t run Grails -> Refresh dependencies to update your classpath. Instead, run Maven -> Update project. Running refresh dependencies is disabled for mavenized projects since Maven manages the classpath.
    • Installing plugins: you can open the Grails plugin manager, but you can’t install plugins from there. Instead, install plugins by adding the dependency to the plugin in your pom. Then run Maven -> Update project.
    • Uninstalling/upgrading plugins: If you are uninstalling or upgrading a plugin:
      1. First update your pom.xml to reflect the new dependencies
      2. Run mvn clean on the project. This can be done either on the command line or inside of GGTS
      3. Run Maven -> Update project inside of GGTS.

      This will give you a clean compile using the new plugins and removing any old ones.
    • [B]Forked mode[B]: Note that GGTS will automatically run your Grails goals in forked mode even if you have explicit configuration in your pom otherwise. This is to avoid running out of permgen when Grails is run in-process.


    If you have any problems or comments, please reply to this post. Also, be aware that most of the comments on the first page are outdated since they deal with an older version of these instructions.

    Suggestions to improve these instructions are appreciated!
    Last edited by Andrew Eisenberg; Oct 4th, 2012 at 03:03 PM. Reason: Update for 3.1.0 release
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

  2. #2
    Join Date
    Aug 2012
    Location
    Oakland CA
    Posts
    16

    Default

    Where can I find the "Maven -> Update project" menu? I don't see it in any of the regular menus or toolbars.

  3. #3
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    First you need to install m2e. As described above, Go to Help -> Install new software. In the "Work with" box, choose the Juno update site. Look for the m2e entries and install them.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

  4. #4
    Join Date
    Aug 2012
    Location
    Oakland CA
    Posts
    16

    Default

    m2e is already installed (btw I'm running GGTS 3.0.0). so, with m2e installed, where is the Maven menu/button?

  5. #5
    Join Date
    May 2010
    Posts
    413

    Default

    Right click on the project in the project or package explorer. There should be a 'Maven' menu.

    If the menu is not there, it could be that your project doesn't have 'Maven nature'. Only projects with maven nature will have m2e functionality, such as the 'Maven' menu.

    To add maven nature, use "Configure >> Convert to Maven Project".
    Kris De Volder -- SpringSource

  6. #6
    Join Date
    Aug 2012
    Location
    Oakland CA
    Posts
    16

    Default

    ah yes - the context menu - thanks for the reminder!

  7. #7
    Join Date
    Jan 2010
    Posts
    4

    Question WTP integration incompatibility?

    Quote Originally Posted by Andrew Eisenberg View Post
    Do NOT install from the dashboard, since that will also install WTP integration which will confuse m2e into converting the project into a WTP project.
    I'm curious to know why. I happen to know a thing or two about the WTP integration and, given that Grails projects have the grails-app packaging, I'm pretty sure they're completely ignored by m2e-wtp (which only messes with war, ejb, ear, rar, app-client packagings).

    Regards,

    Fred

  8. #8
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    The grails-app packaging is optional and a fairly recent addition to the grails-maven integration. Moreover, the archetype for Grails 2.1.1 still produces a pom that uses a war packaging type (it can be changed, but it is not easy to figure out unless you are already familiar with the grails-maven-plugin). So, if you have WTP integration installed, then a grails project that doesn't use grails-app packaging will be treated incorrectly in GGTS. (There might be a way to create a custom lifecycle mapping to fix this to ignore the WTP maven plugins, but it's just simpler to say not to use it.)

    This all has been fixed in the latest snapshot and the 3.1.0.RC1 build out this week. We have updated the grails-maven archetype to use the grails-app packaging and GGTS now correctly recognizes the packaging. When RC1 is out, I will fix up this documentation to reflect the changes.

    So, I'm not really sure if this is a WTP problem or a Grails problem. It would certainly be nice if WTP maven integration did not trample on war packaged mavenized grails apps, but I'm hoping that this packaging style will be deprecated. The instructions for using this in 3.1.0.RC1 and later will be vastly simplified and part of ensuring this is by being clear as to exactly what we do and do not support.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

  9. #9
    Join Date
    Sep 2012
    Posts
    1

    Default

    Here is some additional steps required to get this working. I used the GGTS M1 release - not nightly build, windows 7, java 7, and the GGTS installed version of maven.

    1. When you install GGTS, before you do anything else, specify your JDK in your IDE settings rather than the default JRE. While I eventually did this, the maven $java.home variable was stuck with the JRE for sometime causing a dependency error for the POM in m2e view.


    1.1. I still had issues even after doing this so I had to create a shortcut for GGTS and add a vm parameter after GGTS in the short cut. Here is an example of mine:

    GGTS.exe -vm "C:\development\Java\jdk1.7.0_07\bin"

    2. When you do the "import existing maven project" step, GGTS will ask you if you wish to convert this to a grails project. Select yes to all. It might be obvious to some, but after trying this a number of times I was beginning to question if this was one of the issues. It isn't.

    Attachment 5202

    3. For m2e it is prudent to enable to enable reindex on start from > windows>preferences>maven

    Attachment 5203

    ...and restart GGTS.

    4. Totally frustrating was the fact that maven dependencies was still not working. Add the following to the .classpath of the project:

    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>


    5. The maven package command works but on deployment it also includes the latest servlet jar which will cause a conflict with most/all web servers. Adding an excludes directive to the POM solves this i.e.

    <dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>tomcat</artifactId>
    <version>${grails.version}</version>
    <scope>provided</scope>
    <type>zip</type>
    <exclusions>
    <exclusion>
    <artifactId>javax.servlet-api</artifactId>
    <groupId>javax.servlet</groupId>
    </exclusion>
    </exclusions>
    </dependency>



    6. So everything should now work. I STILL have an issue albeit none critical: the project reports over 100 grails dependency problems see screen shot below. Its not critical but really annoying - any ideas?

    Attachment 5204

  10. #10
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    Thanks for the extra suggestions.

    I STILL have an issue albeit none critical: the project reports over 100 grails dependency problems see screen shot below. Its not critical but really annoying - any ideas?
    I'm guessing that the problem here is that Grails-IDE is adding source locations for plugins in your ~/.grails folder, when they don't exist there (maven puts them inside the project). This will happen because of what you did in step #2. Running Grails refresh dependencies will cause this. For now, the best fix is to delete your project from the workspace, run mvn eclipse:clean on the command line and re-import.

    That being said, this and many other issues have been fixed for our RC1 release. I'll be updating the docs in the next day or so with new (and simpler) instructions.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •