Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] [m2e-users] JavaLaunchDelegate : add maven dependencies to classpath

This is more complicated than adding project output and test output
directories. Maven runtime classpath calculation rules are quite
different from what JDT uses by default, so you need to fully replace
both classpath and source lookup path calculation. The easiest way to do
this is by calling MavenRuntimeClasspathProvider#enable on your launch
configuration.

Also, this is question belongs to m2e-dev mailing list, please send any
followup question there.

--
Regards,
Igor

On 2014-05-07, 16:58, Marek Jagielski wrote:
Hi,
I created MyJavaLaunchDelegate that extends JavaLaunchDelegate for
running my own type of files. Files are inside JavaProject with m2e
nature. I would like to add maven dependencies to the classpath of my run.

As I know I have to put them into:

@Override
public String[] getClasspath(ILaunchConfiguration configuration) throws
CoreException {
List<String> extendedClasspath = new ArrayList<>();
Collections.addAll(extendedClasspath, super.getClasspath(configuration));
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(configuration.getAttribute(SystemInCloudLaunchConfigurationConstants.ATTR_PROJECT_NAME,
""));
IPath path = project.getLocation();
extendedClasspath.add(path.toString() + "/target/test-classes");
extendedClasspath.add(path.toString() + "/target/classes");
...
return extendedClasspath.toArray(new String[extendedClasspath.size()]);
}

I am adding already classes of my project.
I will be thankful for any tips.

Marek


--
Marek Jagielski



_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-users



Back to the top