Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335121

Summary: Adding a new maven module corrupts the parent POM
Product: z_Archived Reporter: Sahoo <sanjeeb.sahoo>
Component: m2eAssignee: Milos Kleint <mkleint>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: mkleint, pascal
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test case. none

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/