In intellij, does a project constitute a single classpath? - grails

I have two grails projects (on different versions of grails), but they work together to provide a seemless user experience. Can IntelliJ have a single project which has both grails projects?

Some terminology clarifications:
What you're calling a project, IntelliJ calls a module. An IntelliJ module typically generates a single artifact (.war, .jar, etc). The Eclipse equivalent of an IntelliJ module is a project.
An IntelliJ project is a grouping of related modules. The Eclipse equivalent of an IntelliJ project is a workspace
So what you probably want to do is create a IntelliJ project, which contains two modules (one for each Grails app). IntelliJ will allow you to add two Grails modules that use different versions of Grails to the same project. Each IntelliJ module has its classpath.

Yes, sure. You can add it as a new module to current project/workspace: File -> New Module

Related

Intellig IDEA x Grails

I tested several IDEs for developing grails applications. Tested the Spring IDE, did not like because I thought slow and crashes every time.
Tested by netbeans, and the result was the same as before.
Was reading about IntelliJ IDEA. Current problem, even doing the command "grails integrate-with --intellij" mentioned on the website https://grails.org/IDEA+Integration not enabled the option of creating projects in grails .
After running the command above returns nothing.
What should I do?
you will need the ultimate edition of IntelliJ to get grails support
With ultimate you can simply open an existing grails project (see this answer) or create a project from the File/New Project... menu.
grails integrate-with --intellij creates three files in the directory (yourproject.(iml|ipr|iws)). You can open the .ipr file with IntelliJ and have the project loaded (it might ask to convert the file).
Also you can just create new project (pick Gradle and then Grails) or you can just use the directory as existing source where you create-app-ed your project and IntellIj will see, that it is Grails.
Be aware, that it will only work with the Ultimate Edition and not the Community Edition

Grails / IntelliJ setup with multiple modules

I am currently defining the project structure for a project that I am working on. The project is a simple SOA implementation and as such has a grails app and a number of different services.
I wanted to package these services into separate modules (jars) so that they can easily be deployed separately and there is no risk of cost-contamination of classes.
The project structure and dependancies could be visualised as:
Grails App (war)
|__ Service Gateway (jar)
|__Service A (jar)
|__Service B (jar)
Whilst these services will eventually be deployed seperately, for ease of local development I want to package them into a single grails app until such time as it is necessary to break them apart.
My ultimate goal was to be able to develop these services in the same way I would a simple grails app in that I would be able to change any class (within any of the modules) on the fly and have it picked up.
I am struggling though to see the best way in IntelliJ to represent this structure.
I had created seperate modules for each of the above and added the dependancies between them, but obviously grails has no idea of this at runtime.
I have read about and found the following possible solutions, all of which currently feel a bit unsatisfactory as would require a jar to be built meaning that classes cannot be reloaded on the fly.
Install the modules into the local maven repository and reference this in the grails build dependancies.
Drop the built jars into the lib directory.
Add them as grails plugins (seems a little heavy handed as they won't require grails functionality).
Find some other way of including the output directories for these modules on the grails classpath (not sure of the cleanest way to do this).
Thanks!
In the end, I went with a multi module Maven build. The key to the on the fly code deployment is using JRebel to monitor the output directories and reload the classes when they change.

I can't create Grails project in Intellij 11

I can't find the way to create Grails project. When i choose New Project --> Create project from scratch, I don't see anywhere to choose Grails project, how can i configure this issue? And how can i run Grails app?
Just use: File => New Project => Create project from scratch
In the modal form after that is shown after, you can select 'Grails' as the project type.
If you don't see this option, that is because you have installed the Community Edition of IntelliJ, which has no Grails support. You need the Ultimate Edition for that. Trust me, it's worth it.
Look here for a comparison sheet
Create the Grails app on the command-line using:
grails create-app myapp
In IntelliJ, create a new project, or open an existing project. Then in the File menu, choose New Module and choose the option "Import Grails application from existing sources"
http://grails.org/doc/latest/guide/gettingStarted.html#requirements
You can still use Community Edition for Grails development, but you will miss out on
all the Grails specific features like automatic
classpath management, GSP editor and quick access to Grails commands.
To integrate Grails with Community Edition run the following command
to generate appropriate project files:
grails integrate-with --intellij

Grails Paypal plugin with Netbeans

I downloaded and installed the paypal plugin http://www.grails.org/PayPal+Plugin using netbeans. Though the website mentioned there will be a controller and domain class created. However, I don't see it. Can someone advice if I installed correctly?
The Controller and domain class are located within the plugin itself. Browse the source of the plugin to see them.
The plugin is probably located in a hidden directory under your profile. Not the Netbeans project folder. For instance on grails 2.0 on Linux:
/home/user/.grails/2.0.0.M2/projects/testapp/plugins/paypal-0.6.4.
Each plugin is like a complete project with directory structure.
Your project has use of the plugin when it's installed, and includes it when you build it.

Effective grails plugin development

This has been very upsetting for me up till now. Here is what I am trying to do:
IDE I'm using is Intellij IDEA.
Building a grails application.
Grails application specifies two dependencies on in house grails plugins also being developed in IntelliJ as separate grails plugin projects.
Now to make any changes to plugins, I update the source code in plugin projects and use mavan-install (Maven Publisher plugin) to deploy to local Maven repository.
I have to uninstall the plugin in core grails project. Delete the plugin cache from ivy and then run the core grails project which gets the latest copy of plugin from local maven repository.
What's the effective and ideal way to achieve this? A single change makes me do some 5 minutes of labour work to even test and run core application.
Any recommendations/ best practices?
Use inline plugins for this - see section "Specifying Plugin Locations" in http://grails.org/doc/latest/guide/12.%20Plug-ins.html#12.1%20Creating%20and%20Installing%20Plug-ins
By specifying the plugin project directory with grails.plugin.location.<plugin-name> as the location of the installed plugin, you can edit the real files and the changes will affect the test application, and there's no need to sync anything up.

Resources