tarekahf
tarekahf

Reputation: 1002

Convert Imported Maven Sub Module to a Maven Project in Eclipse

I have a multi-module maven project which I imported to Eclipse. I did struggle initially to import it with all its sub-modules but per what I remember, the sub-modules were not converted to Maven Project in Eclipse and they didn't even look like a Java Project. I remember that I used the option "Configure and detect nested projects" and did another import for Existing Maven Project for each sub-module and things looked fine. Even the Maven Build from Eclipse was successful.

However, today I noticed that the node "Maven Dependencies" doesn't show under the sub-module node in Eclipse, and I don't see the maven dependencies. I could only see the "JRE System Library" node. I compared the configuration to another project that was imported successfully as Maven Project, and figured out that this newly imported project in Eclipse, its sub-modules are not recognized as Maven Project.

Then, I used the command mvn eclipse:clean eclipse:eclipse and now I can see the Maven Dependencies showing as "Library Dependencies" which means it is still a Java Project not a Maven Project.

I am trying to locate the option to convert it to a Maven project, but I don't see such an option.

I am thinking to backup one of the sub-modules, delete it from Eclipse and re-import it as a Maven Project.

Any idea how to resolve this problem, please let me know.


Update 1:

Below is the .project file of the project that was imported successfully:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>proj_name</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
</projectDescription>

Below is the .calsspath file of the project that was imported successfuly:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry excluding="path/to/some/file/being/excluded/coming/from/pom/xml/_ServerMessagesTest.java" kind="src" output="Nightly_Build/proj_name" path="src/main/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="Nightly_Build/proj_name" path="src/main/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="test" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="test" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="Nightly_Build/proj_name"/>
</classpath>

Notes/questions:

Upvotes: 0

Views: 44

Answers (0)

Related Questions