Issue Details (XML | Word | Printable)

Key: MIDEA-100
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Dennis Lundberg
Reporter: Gerhard Mueller
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Maven 2.x IDEA Plugin

Module file (.iml) is generated in a way that sources and javadocs are not recognized by Intellij Idea

Created: 10/Jul/07 11:35 AM   Updated: 17/Jul/07 10:41 AM   Resolved: 17/Jul/07 10:41 AM
Return to search
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.2

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive idea-demo-project.zip (15 kB)

Environment: WIndows XP, Maven 2.0.7, Java 1.6, IntelliJ IDEA 7.0M1b


 Description  « Hide

When a new iml file is generated with mvn idea:idea -DdownloadSources=true -DdownloadJavadocs=true

the generated .iml-file contains invalid entries for the javadocs and sources, like in this example:

<orderEntry type="module-library">
<library>
<JAVADOC/>
<SOURCES/>
<CLASSES>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar!/" />
</CLASSES>
<SOURCES>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-sources.jar!/" />
</SOURCES>
<JAVADOC>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-javadoc.jar!/" />
</JAVADOC>
</library>
</orderEntry>

Removing the empty
<JAVADOC/>
<SOURCES/>
entries allows me to see the sources, but this is not a good solution.

By looking at the source code https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
the reason might be the method

private Element createOrGetElement( Element lib, String name )
{
Element el = lib.element( "name" );

if ( el == null )
{ el = createElement( lib, name ); }
return el;
}

In my opinion, the method should look like this:

private Element createOrGetElement( Element lib, String name )
{
Element el = lib.element( name ); // CHANGE DONE HERE

if ( el == null )
{ el = createElement( lib, name ); } }
return el;
}

as otherwiese ALWAYS new element instances are created, regardless the provided name to look for,



Dennis Lundberg added a comment - 13/Jul/07 05:18 PM

I just tried this on another project and I can not reproduce what you describe. I only get one SOURCES and one JAVADOC tag per dependency/module-library. Did you check the .iml file before opening it in IDEA?

Please supply a sample project that can be used to illustrate the problem.


Gerhard Mueller added a comment - 15/Jul/07 03:58 PM

This is really strange. I really had that problem, reproducable on my computer.

Today I did the same:
mvn -U idea:idea -DdownloadSources=true -DdownloadJavadocs=true
, and now I get the following (part of .iml file):

<orderEntry type="module-library">
<library>
<JAVADOC>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga-javadoc.jar!/"/>
</JAVADOC>
<SOURCES>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga-sources.jar!/"/>
</SOURCES>
<CLASSES>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga.jar!/"/>
</CLASSES>
<SOURCES>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga-sources.jar!/"/>
</SOURCES>
<JAVADOC>
<root url="jar://C:/Dokumente und Einstellungen/muellerg/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga-javadoc.jar!/"/>
</JAVADOC>
</library>

I will attach my pom file, slightly changed because of private information, and the generated files.


Gerhard Mueller added a comment - 15/Jul/07 04:08 PM

The demo project (pom file and generated idea project files) which show that the generation of idea files seems to have a problem


Dennis Lundberg added a comment - 16/Jul/07 04:43 PM

Thanks for the project Gerhard. I can now verify that this happens. But it only happens when you run the IDEA plugin a second time on a project that has already had its IDEA files created before. Then SOURCES and JAVADOC tags are duplicated. I'll take a look at the code snippet you mentioned.


Dennis Lundberg added a comment - 16/Jul/07 05:14 PM

I have applied your suggested patch and deployed a new SNAPSHOT.
Please verify that this issue is solved in version 2.2.-SNAPSHOT.


Gerhard Mueller added a comment - 17/Jul/07 09:30 AM

Thank you!

Your change in 2.2.-SNAPSHOT works for me.


Dennis Lundberg added a comment - 17/Jul/07 10:41 AM

Fixed in SVN r556749.