Maven 2.x IDEA Plugin

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

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 2.1
  • Fix Version/s: 2.2
  • Component/s: None
  • Labels:
    None
  • Environment:
    WIndows XP, Maven 2.0.7, Java 1.6, IntelliJ IDEA 7.0M1b
  • Number of attachments :
    1

Description

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,

Activity

Hide
Dennis Lundberg added a comment -

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.

Show
Dennis Lundberg added a comment - 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.
Hide
Gerhard Mueller added a comment -

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.

Show
Gerhard Mueller added a comment - 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.
Hide
Gerhard Mueller added a comment -

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

Show
Gerhard Mueller added a comment - The demo project (pom file and generated idea project files) which show that the generation of idea files seems to have a problem
Hide
Dennis Lundberg added a comment -

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.

Show
Dennis Lundberg added a comment - 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.
Hide
Dennis Lundberg added a comment -

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

Show
Dennis Lundberg added a comment - I have applied your suggested patch and deployed a new SNAPSHOT. Please verify that this issue is solved in version 2.2.-SNAPSHOT.
Hide
Gerhard Mueller added a comment -

Thank you!

Your change in 2.2.-SNAPSHOT works for me.

Show
Gerhard Mueller added a comment - Thank you! Your change in 2.2.-SNAPSHOT works for me.
Hide
Dennis Lundberg added a comment -

Fixed in SVN r556749.

Show
Dennis Lundberg added a comment - Fixed in SVN r556749.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: