Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335121 - Adding a new maven module corrupts the parent POM
Summary: Adding a new maven module corrupts the parent POM
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Milos Kleint CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-23 12:24 EST by Sahoo CLA
Modified: 2021-04-19 13:26 EDT (History)
2 users (show)

See Also:


Attachments
Test case. (3.79 KB, text/plain)
2011-01-23 12:25 EST, Sahoo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sahoo CLA 2011-01-23 12:24:31 EST
Build Identifier: 20100917-0705

I have successfully imported a multi-module maven project which has just the parent-pom and a single module in it. When I add a new maven module to the the parent pom, it creates the new module, but corrupts the parent POM. It almost empties the parent POM while trying to add the new module to the list of modules. 

Reproducible: Always

Steps to Reproduce:
Unzip the attached test case in /tmp.
1. Import /tmp/m2e_bug/ into Eclipse as a maven project from existing sources.
2. Select parent-pom, add a new maven module type project to it. Give it some name.
3. Choose "webapp-javaee6" as the artifactId in the archetype selection panel. Leave everything else as default. Finish creating the module.
4. Now, you will see parent-pom getting almost emptied as shown below:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<modules>
		<module>foo</module>
	</modules>
</project>
Comment 1 Sahoo CLA 2011-01-23 12:25:50 EST
Created attachment 187384 [details]
Test case.
Comment 2 Milos Kleint CLA 2011-02-10 03:53:09 EST
the workaround is surprisingly to keep the parent-pom editor opened when creating the module.
Comment 3 Milos Kleint CLA 2011-02-11 08:59:20 EST
I've rewritten the entire handling of <modules> section in the pom editor to use the DOM tree operations (based on SSE XML stuff) rather than the EMF model from maven.edit. It seemed to fix the issue. the disturbing part is that I was not able to figure out what actually removed the file content. My guess is that's some sort of model synchronization issues..
Comment 4 Pascal Rapicault CLA 2011-02-28 13:40:15 EST
.
Comment 5 Denis Roy CLA 2021-04-19 13:26:49 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/