1
votes

I've been looking at using grails to build a mock server framework, but have been having troubles configuring it within STS.

The basic requirement is to have a core framework living in its own project, which will ultimately end up as a WAR artifact, and then for each service that's mocked a new jar project will be created containing the service configuration (typically xml/json responses and groovy files for dynamic responses), which will get pulled into the main WAR file as a dependency (using a profile during the build process).

This external build process is fairly well defined using Maven and profiles. I've prototyped this and it all hangs together running off a builder such as Jenkins.

What I'm having trouble with is setting up a usable eclipse environment using the native eclipse project dependency management and eclipse grails support. What I'd like to have is a standard grails project containing the framework, and then a standard groovy project containing the service configuration files and then add the latter project as a dependency to the former. What I've found however, is that if you do this and then invoke run-app, the classes and resources in the groovy project don't get included in the running application. I've tried checking export, but this doesn't make any difference.

The only workaround I've found so far, is to make the groovy project maven artifact a dependency within the grails application, and to pull this in on each build. This involves the undesirable step of packaging and installing the groovy project into the local repo each time a change is made in that project. The other major drawback to this approach of course is that I don't benefit at all from dynamic updates, and any code changes in the groovy project require a restart of the grails app.

Has anyone successfully configured eclipse in this way? If this isn't possible, is there some way of tinkering with the grails build process in order to include the other project through relative paths, say?

1

1 Answers

1
votes

Judging by the this FAQ entry, the recommended approach would be to use their plugin architecture. Will have to see if this plays nicely with eclipse or not.

http://grails.org/FAQ#Q:%20I'd%20like%20to%20implement%20a%20big%20project%20as%20multi%20modules%20with%20Grails,%20What%20to%20do?

update:

It is possible to have your grails app recognise the expanded working directory of your plugin by adding an entry to BuildConfig.grails with the relative path to your plugin e.g.

grails.plugin.location."my-plugin" = "../my-plugin"

After packaging the plugin using the 'package-plugin' command, your grails app can then debug groovy and java files in your plugin. It will also pick up changes to the plugin following an app restart. So that's nearly what I'm after.

It is however not at all intuitive about how I'd go about creating a custom resource structure with a mix of xml/json/groovy files (you name it) and have these included in the resulting plugin. Not to mention the strangeness with relative resource paths. I read somewhere that you could customise what is and isn't included using _install.groovy, but again it's not obvious how to do this. My biggest concern is that this project should be editable by users that aren't hardcore tech savvy, so really I really I just want to present them with a clean project devoid of all of this grails scaffolding.

I despair at the bloatiness of this approach. What was wrong with a simple groovy project, which could have been included as a simple jar? It just seems like overkill, especially for simple requirements such as mine.