Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] Target folder outside project's folder -> JUnit does not work

You need to have m2e extensions development environment as explained in
[1]. Alternatively you can use m2e development environment as explained
in [2].

You will need to implement org.eclipse.m2e.core.projectConfigurators

Subclass org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator in
your implementation and override #getOutputLocation method to return
whatever location you need.

In (parent) pom of your project define m2e lifecycle mapping
configuration that maps maven-compiler-plugin to your new project
configurator. Configuration format is explain in [3] and you can use
standard m2e mapping [4] as an example.

Hope this helps and if you have more questions, please ask on m2e-dev
mailing list.



On 2013-08-22 10:34 AM, Lucas Persson wrote:
Thanks Igor

I will happily receive pointer to implement a java project configurator.
22 aug 2013 kl. 16:10 skrev Igor Fedorenko <igor@xxxxxxxxxxxxxx>:

It is not possible to configure m2e to do what you want and generally
m2e only supports projects that are fully contained under their base
directory. You should be able to implement alternative java project
configurator that will configure classpath like you need. I can provide
pointers on m2e-dev if you want to try.


On 2013-08-22 9:20 AM, Lucas Persson wrote:

I have defined that the target folder (and target/classes) shall be outside the project's folder.
The reason to have it like this is that I am using a proprietary SCM which do not allow write access unless a file is checkout out.
And als it does not have any type of "ignore" filter.

The thing is that every time I do "Maven->Update Project..." it fails like this:

An internal error occurred during: "Updating Maven Project".
Path must include project and resource name: /tiget-api

java.lang.IllegalArgumentException: Path must include project and resource name: /tiget-api
	at org.eclipse.core.runtime.Assert.isLegal(
	at org.eclipse.core.internal.resources.Workspace.newResource(
	at org.eclipse.core.internal.resources.Container.getFolder(
	at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(

I am not sure what m2e does here but I guess it is updating the output folder (among other things)

It seems that if I do not use target folders outside the project's folder the "Maven->Update Project..." succeeds.

The real only issue I can see after that "Maven->Update Project..." fails is that when I try to run JUnit then the Junit launch classpath is not including the target/classes and target/test-classes folders. So JUnit will always end up in class not found for the test class.

So in the root pom(parent pom) I have something like this:	



And in order to make sure the both Eclipse and Maven compiles to same output folder I have it like this in .classpath and .project

   <classpathentry kind="src" path="src/main/java"/>
   <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
   <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
   <classpathentry kind="output" path="target/classes"/>

<?xml version="1.0" encoding="UTF-8"?>

And M2_TARGET is a Eclipse "Linke resource" path variable which all developers in my team needs to defined in their workspace.

So this works very well until we started to use m2e plugin for dependency management.

So basically is there some way to configure m2e to for instance not updating the output folder?
Or can I make some sort of extension to m2e to fix this?

I am using m2e plugin of 1.4 in Eclipse Indigo

m2e-users mailing list

m2e-users mailing list

m2e-users mailing list

Back to the top