Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343026 - use variables to specify base directory in Maven launch configuration
Summary: use variables to specify base directory in Maven launch configuration
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 481472 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-15 19:29 EDT by Igor Fedorenko CLA
Modified: 2021-04-19 13:23 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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/