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

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.

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.

Ignore Sibling-Modules During Maven Javadoc/Site Compilation

I have a Maven-managed project which contains a few modules, one of which is the actual library of interest. The other modules are just add-ons or examples that build off of the library. I'm looking to generate the Maven site for this library and have it automatically deployed (as a standalone site and not as part of a multi-module site) but I am having trouble with the Javadoc plugin.
When executing the javadoc:javadoc goal, the javadoc plugin is attempting to access the jar for the other modules causing a failure.
I have created a simple example which demonstrates this phenomenon. Make sure you run the clean goal before any others so that the flaw be shown. Though executing the packaging first would solve this error, this cannot be done because the use case occurs during the Maven-managed release process which starts from a clean state.
Is there a way for me to disable this functionality in the javadoc plugin so I only get the documetation for the library module?
I can think of two options depending on your preference. Both include using profiles. If you want the default build to create the javadocs for your library of interest. Make the other modules use a property inside of the default profile in order to skip the javadocs.
If you are okay with passing in a profile, just have the javadocs only run in the profile.

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.

Maven dependancy on another non-repository project?

I have 2 completely separate projects where one depends on the other. I've very recently mavenized the main project but can mavenise the dependency if absolutely necessary.
Originally these were Netbeans projects, with the main project having several modules. What I liked is that I could declare the dependency as a dependent project. This allowed me to use the most recent code as it changes a lot (the project is in its infancy). NetBeans would put the dependent project on the classpath when running, and build a jar in the /dist directory when doing a clean and build.
Now that the main project is in maven, I can't do this anymore. The only alternative I've found was to manually copy it into the project repository, but that removes a lot of automation and ease of use. Every time I wanted to test a change I would have to rebuild the dependency, move it to the buried project repository folder, rename it appropiatly, switch back to NetBeans, then run. This is vs clicking run and everything being done automatically.
Maybe I'm just lazy, but is there an easy way to do this?
I have 2 completely separate projects where one depends on the other. I've very recently mavenized the main project but can mavenize the dependency if absolutely necessary.
Mavenizing the dependent project would help a lot. Like Eclipse or IntelliJ, NetBeans supports something Eclipse calls Workspace dependency resolution: if a project A depends on a project B and you open both of them in your IDE, A can be configured to depend on B sources instead of B jar (and any change would become immediately visible).
mavenizing the depedency project is the best option.
Alternatively you might get away with using a system scope dependency which points to the dependency project's dist/ folder jar artifact.

How to use Grails Dependency cache in 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.