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

Bug 343026

Summary: use variables to specify base directory in Maven launch configuration
Product: z_Archived Reporter: Igor Fedorenko <igor>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: fbricon, feles, konrad_w, lrozenblyum, robert.munteanu
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Igor Fedorenko CLA 2011-04-15 19:29:03 EDT
https://issues.sonatype.org/browse/MNGECLIPSE-1150
Comment 1 Igor Fedorenko CLA 2013-09-28 23:24:59 EDT
closing old/stale bugreports
Comment 2 Robert Munteanu CLA 2013-10-01 08:29:02 EDT
This is still relevant IMO, even though old. Please consider reopening.
Comment 4 Konrad Windszus CLA 2015-10-07 08:48:51 EDT
I created a patch for that in https://git.eclipse.org/r/57619.
With this patch m2e will always create new launch configurations with the PROJECT_LOC variable expression (instead of absolute path names).

That way you can move your workspaces around in your filesystem, without needing to adjust the launch configurations.
Can you please reopen and afterwards apply the patch?
Thanks
Comment 5 Fred Bricon CLA 2015-11-05 10:53:54 EST
Reopening to consider Konrad's patch
Comment 6 Fred Bricon CLA 2015-11-05 10:57:01 EST
*** Bug 481472 has been marked as a duplicate of this bug. ***
Comment 7 Fred Bricon CLA 2015-11-05 17:25:42 EST
@Konrad: patch looks good to me, does the job. 

However could you please create a PR on https://github.com/tesla/m2e-core-tests, to add some unit test(s)?
Comment 8 Konrad Windszus CLA 2015-11-06 10:03:56 EST
@Fred: Thanks a lot for the review, but I guess I am not familiar enough with testing UI specific stuff in Eclipse to come up with a reasonable test here. Do you have any pointers on how to do the testing there?

I was having something like this in mind:
1. Create a new project
2. Trigger a new Build... Action (which will open the launch dialog)
3. Click on launch (should work with the default config)
4. Move project to another location
5. Trigger a new build (leveraging the old launch config)

At least the part where variables get replaced with real values during the execution of a launch config is already covered in org.eclipse.m2e.tests.launch.MavenLaunchDelegateTest.testGetVMArgumentsSubstituteMultiModuleDir()
Comment 9 Fred Bricon CLA 2015-11-06 11:15:55 EST
UI Testing is pretty limited in m2e unfortunately. There were some SWTBot tests in the past but they were removed, because too unreliable[1].

If you can refactor ExecutePomAction to make the LaunchConfig generation testable, that'd be great (get an IProject in, test Launch config paremeters out). But I could easily settle for simple UT of LaunchingUtils#generateProjectLocationVariableExpression)


[1] https://dev.eclipse.org/mhonarc/lists/m2e-dev/msg00672.html
Comment 10 Konrad Windszus CLA 2015-11-06 12:58:15 EST
Thanks for the hints. I picked approach 2 and created a PR at https://github.com/tesla/m2e-core-tests/pull/37. That should cover the variable resolution as well as a check that moved projects can use the same variable expression!
Comment 12 Denis Roy CLA 2021-04-19 13:23:35 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/