How to use Grails Dependency cache in IDE? - ide

Is there a way to use the ivy cache grails dependency DSL creates within an IDE like eclipse or netbeans? Or must I manually add all dependencies to the IDE lib folder?
I've looked into plugins like ivybeans and ivyde, but they seem to require ivy.xml and ivysettings.xml files, which grails does not produce.

The Grails tooling provided by the SpringSource Tool Suite plugin for Eclipse has the functionality you desire. It reads BuildConfig.groovy and modifies the project classpath accordingly.

I just attached the following to the Jira bug.
In snooping around the STS distribution, I found the following code in
C:\springsource\sts-2.3.2.RELEASE\configuration\org.eclipse.osgi\bundles\898\1.cp\src\com\springsource\sts\grails\core\model\GrailsBuildConfig.java
// make sure that we use the Ivy dependency resolution strategy for Grails 1.2
// TODO CD make version number detection more flexible
if (settings.getGrailsVersion().startsWith("1.2")) {
jarFiles.addAll(settings.getTestDependencies());
jarFiles.addAll(settings.getProvidedDependencies());
Based on this find, I tried downgrading my project from Grails 1.3.2 to Grails 1.2 and ran "refresh dependencies". Sure enough, the dependencies were correctly loaded from Ivy.
Looks like someone needs to do the TODO. I can take a stab at it once I figure out how to check out the source code...

IntelliJ syncs dependencies between Grails (form application.properties and BuildConfig.groovy) and the IDE very nicely.

Related

SBT, dependencies, classpath and editors

I recently updated my sbt setup to version 0.11. As you may know, new SBT uses .ivy2 folder to store/cache all the retrieved jar files. I am using IntelliJ and I would like to know what is the recommended way of importing dependencies to the editor's classpath.
One option is to manually visit .ivy2 folder and select the dependencies. Is there a better/easier way to doing this?
I presume you use the SBT-plugin. According to the instructions on the linked page:
After each change to your dependencies, run gen-idea in the SBT Console. When prompted, reload the project.
I usually run
gen-idea no-classifiers no-sbt-classifiers
(see under "Usage" on github). IntelliJ (11 RC) will then ask you to reload the project, which is usually quite fast. Then the references to your SBT dependencies will be available.
You can try IvyIDEA plug-in.

Binary output and testing for Eclipse plugins

I am developing an Eclipse plugin and I use maven to coordinate my source structure. In order to compile the plugin I use the tycho extension for maven. However, I was wondering how to execute unitests.
I want to use the surefire plugin for testing as I additionally use a sonar server for source code quality management. Unitests are applyed if I use eclipse-test-plugin as package target. However, I want to make use of the default surefire plugin for applying unitests.
Now I figured out that the src/test/java that contains my unittest packages is read and compiled correctly but written into the wrong output folder. I need to have the tests in target/test-classes. However they are compiled to target/classes.
As I am new to Eclipse plugin development and maven I could not find out how to write the tests to the correct output folder. I've already tried adding and and changing the build.properties of the eclipse-plugin project. It works also fine for other projects that aren't plugin projects and do not make use of tycho.
Any help appreciated.
Regards,
Florian
Unlike standard maven projects, the convention for eclipse plugins/OSGi bundles is to have tests reside in separate projects. This is because there is no such thing as a maven dependency scope "test" in OSGi.
Thus keeping your tests inside the same project as your code under test would force you to mix up test code/dependencies an productive code/dependencies.
As you mentioned, Tycho provides a separate maven packaging type "eclipse-test-plugin" which you should use for dedicated test plugins/fragments. See https://docs.sonatype.org/display/TYCHO/PackagingTypes
There is no support in Tycho for plain unit tests residing in the same project.

How well does m2eclipse deal with maven plugins?

In general, how well does m2eclipse deal with Maven plugins that modify or amend lifecycle phases?
In particular, I have a project that has a maven-clean-plugin extension to remove an extra generated directory (not in target/) using the configuration filesets tag. This works when running mvn at the command line but not when doing a clean in Eclipse. Is there any way to get m2eclipse to process that plugin?
Another example is flexmojos; there's a lot that can be configured with the flexmojo plugin but those parameters don't seem to get imported by m2eclipse.
Is the integration solely ad-hoc? If m2eclipse embeds Maven, why can't the plugins be executed directly using the underlying pom.xml configuration?
In general, how well does m2eclipse deal with Maven plugins that modify or amend lifecycle phases?
Decently, to my experience. At least for plugin bound to phases from the default lifecycle.
In particular, I have a project that has a maven-clean-plugin extension (...). This works when running mvn at the command line but not when doing a clean in Eclipse. Is there any way to get m2eclipse to process that plugin?
What the clean plugin "extension" is doing and what you're doing (calling mvn clean from Eclipse? calling Project > Clean?) is unclear - at least for me. But maybe have a look at MNGECLIPSE-823 or MNGECLIPSE-156. And don't hesitate to clarify :)
Another example is flexmojos; there's a lot that can be configured with the flexmojo plugin but those parameters don't seem to get imported by m2eclipse.
I don't do flex so the above is too vague for me. But providing a more concrete example might help.

How do I make Intellij stop removing Grails inline plugin module dependencies?

I am developing a Grails application along with a Grails plugin used by that application. In Intellij, I have defined two modules: one for the application, and one for the plugin. In my application's BuildConfig.groovy, I have defined the plugin dependency as a maven dependency, because when it is built/deployed to the production server, it should only refer to the latest 'released' version of the plugin. I override this dependency in my ~/.grails/settings.groovy file with my inline plugin location, so that I don't have to worry about accidentally committing my local development settings to the repository.
This works great when I use the built in grails commands to build/run/test, etc, but it has one fatal flaw: every time I do a clean, and periodically even when I don't, Intellij will read the application's BuildConfig.groovy file and remove the plugin module as a dependency for the grails app! This is extremely frustrating, as I have to then manually go to File -> Project Structure, select the application module, select the dependencies tab, and manually add the plugin's module dependency to it. Every. Single. Time.
Is there some way I can make Intellij leave my grails app's module dependencies alone, and trust that I know what I'm doing when I assign them? This is getting ridiculous!
I'm afraid that's a bug in IDEA. I've created a bug request for this issue: http://youtrack.jetbrains.net/issue/IDEA-56472. There you can find the way to temporarily fix this issue.

I can't find the maven plugin org.maven.ide.eclipse:lifecycle-mapping 0.9.9-SNAPSHOT

I have a maven pom file which depends on this plugin, but I can't find it anywhere online. Is this something which needs to be built from some other piece of code?
I searched in Sonatype repository and svn but I also didn't find jar nor sources. Customizable build lifecycle mappings is a experimental feature in m2eclipse. So if you don't need this feature you can comment this plugin.
Edit
After some tests I've noticed that if you use Maven 3.0 Embedded runtime your pom will work without complain, but there is still no jar for this plugin in the repository. So there is some kind of magic or I need to read more about Maven3/Embedded :)
alt text http://img683.imageshack.us/img683/7041/m2eclipse.png