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

Bug 384510

Summary: [patch] Regression in Maven Import on checkout
Product: z_Archived Reporter: Mike Youngstrom <youngm>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: fbricon, frank.jakop, igor, sslavic, tompik, youngm
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Server 2008   
Whiteboard:
Attachments:
Description Flags
Test Project
none
Patch to m2e core
none
Patch to m2e tests
none
Patch to m2e core
none
Patch to m2e tests none

Description Mike Youngstrom CLA 2012-07-06 17:05:06 EDT
Build Identifier: 1.1.0.20120530-0009

It appears that the fix to https://bugs.eclipse.org/bugs/show_bug.cgi?id=341038 has caused a regression in the checking out of multi-module projects where the sub module directory names don't match the module's artiact-id.

Reproducible: Always

Steps to Reproduce:
1.Import the example project into an SVN Repository.
2.Install Subversive+Maven 1.1+Subversive+m2e
3.Browse to repository in repository Explorer
4.Right click->Check out as Maven Project...

Notice the "sub" directory renamed to test-sub.
Comment 1 Mike Youngstrom CLA 2012-07-06 17:06:02 EDT
Created attachment 218403 [details]
Test Project
Comment 2 Mike Youngstrom CLA 2012-07-06 18:40:59 EDT
This simple patch appear to fix the issue.  I'll create a test too.  One question though.  The way this is currently written works fine for SVN repositories.  However, for git repositories where the repo has already been cloned to the git working and we're essentially just importing the cloned directory do we really want to be renaming the cloned work directory?  It seems like this directory renaming could cause problems for Git.  Thoughts?

diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java
index af0ee73..d5a8ea8 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java
@@ -133,7 +133,10 @@
       String pomName = modulePath + "/" + IMavenConstants.POM_FILE_NAME; //$NON-NLS-1$
 
       MavenProjectInfo projectInfo = newMavenProjectInfo(pomName, pomFile, model, parentInfo);
-      projectInfo.setBasedirRename(getBasedirRename(projectInfo));
+      //We only want to optionally rename the base directory not any sub directory
+      if(parentInfo == null) {
+        projectInfo.setBasedirRename(getBasedirRename(projectInfo));
+      }
 
       Map<String, Set<String>> modules = new LinkedHashMap<String, Set<String>>();
       for(String module : model.getModules()) {
Comment 3 Mike Youngstrom CLA 2012-07-06 19:19:06 EDT
Created attachment 218406 [details]
Patch to m2e core
Comment 4 Mike Youngstrom CLA 2012-07-06 19:19:27 EDT
Created attachment 218407 [details]
Patch to m2e tests
Comment 5 Mike Youngstrom CLA 2012-07-06 19:20:58 EDT
Let me know what you think of these patches Igor.  I hope this fix can be back ported to juno sr1.

Mike
Comment 6 Fred Bricon CLA 2012-07-19 10:07:34 EDT
Mike, 

the patch doesn't apply to master. 
Please rebase your repos and use git-format to create your patches
Comment 7 Igor Fedorenko CLA 2012-07-19 11:09:08 EDT
(In reply to comment #6)
> Mike, 
> 
> the patch doesn't apply to master. 
> Please rebase your repos and use git-format to create your patches

git-format-patch
Comment 8 Mike Youngstrom CLA 2012-07-19 11:24:52 EDT
Created attachment 218937 [details]
Patch to m2e core
Comment 9 Mike Youngstrom CLA 2012-07-19 11:25:16 EDT
Created attachment 218938 [details]
Patch to m2e tests
Comment 10 Mike Youngstrom CLA 2012-07-19 11:27:13 EDT
Sorry about that.  I'm new to Git and I'm running windows so I'm trying to do this with egit.  I hope I got it right this time.

If I did for future reference I believe in eGit terms the proper patch type is an "Email" patch.
Comment 11 Frank Jakop CLA 2012-07-25 03:58:38 EDT
We're experiencing this issue also with CVS and would really appreciate a port/targeting to juno SR1.
Comment 12 Fred Bricon CLA 2012-07-25 07:02:29 EDT
Mike's patches applied (somehow) :

core : http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=19462411f1cf58d6b1246463946d694201763449

tests : https://github.com/sonatype/m2e-core-tests/commit/b8eec911bda920d768a8e01712964c66f184c04c

I still wasn't able to apply the patches cleanly with "git am", even "git am -3", so instead of going back and forth with Mike, I chose to use egit to apply them then run commands like :

git commit -s --author="Mike Youngstrom <youngm@gmail.com>" --date="Fri, 6 Jul 2012 17:16:27 -0600" --message="[PATCH] Test to ensure we only rename the base
 project and not any of the sub projects.  384510"

Thanks Mike.
Comment 13 Mike Youngstrom CLA 2012-07-25 11:59:24 EDT
Thanks Fred,

It would be nice to know how to create an appropriate patch with egit.  I really don't want to install cygwin for git on my windows box unless I have no other option. :)

Mike
Comment 14 Igor Fedorenko CLA 2012-07-25 12:57:44 EDT
(In reply to comment #13)
> Thanks Fred,
> 
> It would be nice to know how to create an appropriate patch with egit.  I
> really don't want to install cygwin for git on my windows box unless I have no
> other option. :)
> 

EGit user list or forum is a better place to ask this kind of questions. Lets keep bugzilla for bug-related discussions.
Comment 15 Denis Roy CLA 2021-04-19 13:27:12 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/