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

Hi

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(Assert.java:63)
	at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2163)
	at org.eclipse.core.internal.resources.Container.getFolder(Container.java:222)
	at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:71)



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:	


  <properties>
    <rootTargetDirectory>${env.M2_TARGET}</rootTargetDirectory>
    <targetDirectory>${rootTargetDirectory}/${project.groupId}/${project.artifactId}/target</targetDirectory>
....

  <build>
    <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
    <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
    <directory>${targetDirectory}</directory>
    <outputDirectory>${targetDirectory}/classes</outputDirectory>
    <testOutputDirectory>${targetDirectory}/test-classes</testOutputDirectory>
....


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

<classpath>
  <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"/>
</classpath>

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>tiget-api</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.m2e.core.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
	</natures>
	<linkedResources>
		<link>
			<name>target</name>
			<type>2</type>
			<locationURI>M2_TARGET/tiget.core/tiget-api/target</locationURI>
		</link>
	</linkedResources>
</projectDescription>

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


Thanks
Lucas