Referencing other grails projects - grails

I am trying to use domain classes of one grails project in other grails projects. I am using GGTS as IDE.
I imported grails project containing domain classes and added it to the build path of my second project.
When I try to reference any of domain classes in second project I get no errors in GGTS but when I run app i get:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
unable to resolve class domainClass

A better solution is to create a Grails plugin, add the domain classses to the plugin (and anything else that should be shared by the 2 applications), and install the plugin in the 2 applications.

that is definite that you should create the other project as plugin.
Please , consult this documentation and let me know any thing ,if u want help.

Related

Creating Grails shared libraries

I'm working on a multi-module project right now, where most of the modules are designed to have their own Web interface (REST API, Web pages, etc.) done using Grails. There are a few classes that I want to be utilized by different (all) modules. If this were a straightforward Java project, I would just create a new Maven project (using archetype:generate), deploy/install, and just import it on the modules accordingly. How do I do this with Grails? Is this one of the things Grails plugins are meant to address?
Since you are talking about a jar/lib artifact it would be best to use a local Maven repository where you build your maven project to then resolve it as a dependency for your modules within your BuildConfig.groovy.
Nothing is stopping you from using a Grails plugin to provide this resource, but that seems a bit overkill since Grails plugins are intended to do so much more.
It looks to me that you want to have a multi-project build or a Mavenized Grails project or separate plugins.
Use a Grails multi-project-build
Guide: http://grails.org/doc/2.1.0/ref/Command%20Line/create-multi-project-build.html
Straight Maven integration
Guide : http://grails.org/doc/latest/guide/commandLine.html#antAndMaven
I have a basic introduction video here: https://www.youtube.com/watch?v=tqGN61hiciE
Separate Grails plugins
You could still use separate Grails plugins and reference them in your main application.

intellij can't resolve grails.plugin

I am using Grails 2.3.3 and IntelliJ ultimate 12.1.6 on my Vista 32 machine.
I used grails command line to create a new app and then added spring security and spring security ui. My BuildConfig.groovy plugins section contains
compile ":spring-security-core:2.0-RC2"
compile ":spring-security-ui:1.0-RC1"
I ran
grails s2-quickstart
grails s2ui-override auth
grails s2ui-override register
My generated RegisterController looks like this:
class RegisterController extends grails.plugin.springsecurity.ui.RegisterController {
}
the grails.plugin is red and unresolved and no matter what I try I can't get IntelliJ to resolve grails.plugin
Grails compiles and runs the app without issue, and if I override methods I find in the source code for the spring ui RegisterController they are correctly wired in to the app, but I can't even compile from intell and I can't get intellij to help me override code.
I thought maybe creating the project outside of IntelliJ was an issue so I created a new Grails project using the IntelliJ interface, the plugins still do not resolve.
I tried adding the plugins as runtime with no success.
I have spent the afternoon and evening researching this with no success. There are questions similar to this with major versions 10 and 11 of IntelliJ but nothing current, so I am resolved to asking for help to get IntelliJ to recognize the Grails plugin classes. I can post an entire small sample project if necessary.
Thanks.
Dave
I often have this issue when I place a new plugin into my BuildConfig.groovy, but not typically when I add a jar dependency.
I resolve it by doing the following in the menu: Tools > Grails > Synchronize Grails Settings
You can tell whether or not a plugin is synchronized in IDEA by navigating in the Project view to grails-app > target > work > plugins. Each synchronized plugin with have a tiny blue square over the bottom right corner of the directory icon. If it doesn't have that icon, it isn't synchronized with IDEA properly.
Using IntelliJ 13.1.5 and Grails 2.4.3 with Maven there is an issue with 2 different groovy-all jars being pulled in by the IDE.
The way to resolve it is to go to Module Settings and under both the project and projectGrialsPlugins modules modify the User Grails library entry. Click the edit button(pencil) and remove the groovy-all.2.3.3.jar from the project.
Remember if you close the project and reopen it those settings may need to be reapplied.

intellij 11.1.4 ultimate grails setup

I have intellij 11.1.4 ultimate and I'm trying to create a Grails project. I can't select a Grails SDK when creating a project. I have looked around and can't find a clear solution on how to set this up step by step.
Can anyone help?
download Grails version you want to use
extract it somewhere on disk
start IntelliJ IDEA
File / Settings / Plugins, check if Grails plugin is installed
File / New Project / Create project from scratch , click Next
fill out the form and make sure to select Select type: Grails Module, click Next
select Grails version in Use library
if there is no library in combobox
click on button Create...
select folder where you extracted Grails SDK (point 1 and 2)
click Finish
If this will not help you, there is JetBrains is having superior support, I always got answer to my questions.

How to rename package in grail

I have installed grails support in STS. and I have a grails application inside that I got package com.mycompany.myapp in domain, controllers and tests. I want to rename them to mycompany.myapp, So that It should affect the functionality of application. Is there any way to do it in Grails.
You can use the normal Eclipse refactoring tooling ie ALT+SHIFT+V to move package.
If you're using any inheritance in your domain classes you'll need to upgrade the class name in the class column for these tables.

Compiled and signed grails plug-in

Is it possible to compile and sign grails plug-in? I am thinking about distributing my application logic using grails plug-in architecture and I do not want my client to be able to read that easily .groovy or to modify it. Is it possible to package it somehow or at least distribute only compiled .class?
Yes. you need to think more traditional Java.
Create a JAR with your logic in it and sign the jar. Put the minimum Groovy code in the plugin. You have not stated where the logic is if it's a controller or GORM object so I am not sure what you looking for 100%.
Hope this helps.
It is possible to compile and package groovy/java code into a jar and then use it in a grails app. (as Scott suggests) but these classes can not directly benefit from grails ie. no way to declare grails service, domain class or controller in a separate jar.
There is an issue in grails jira describing the same problem:
http://jira.codehaus.org/browse/GRAILS-4956
Since Grails 1.4 M1 there are binary plugins, I assume this is exactly what you need. I'm not sure if signing is supported in any way, but it's at least possible to distribute the plugin without its sources.

Resources