Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] Changing "mocks" source dir from test to main classpath in a profile

Hello, 

I have a problem with m2e (or m2e-wtp ? I'm not too sure): in my project, a profile activated in eclipse changes the way a source directory is added to the build, by adding it to the "main" classpath, while it is in the "test" classpath when the profile is not active. 
It works well in Maven (the packaged war contains the class if the profile is active for packaging), but I cannot make this work in Eclipse to deploy on tomcat. 

More specifically, I have classes used in a "mock" mode in Tomcat, as well as in unit tests. So without the profile, these classes are added in the "add-test-source" goal, and with the profile active, to deploy in tomcat from Eclipse, these classes are added in the "add-source" goal. 
The main configuration for build-helper-maven-plugin is: 
<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>build-helper-maven-plugin</artifactId>
	<executions>
		<execution>
			<id>add-source</id>
			<phase>validate</phase>
			<goals>
				<goal>add-test-source</goal>
			</goals>
			<configuration>
				<sources>
					<source>src/mock/java</source>
				</sources>
			</configuration>
		</execution>
	</executions>
</plugin>
While in the profile, the configuration is: 
<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>build-helper-maven-plugin</artifactId>
	<executions>
		<execution>
			<id>add-source</id>
			<phase>validate</phase>
			<goals>
				<goal>add-source</goal>
			</goals>
			<configuration>
				<sources>
					<source>src/mock/java</source>
				</sources>
			</configuration>
		</execution>
	</executions>
</plugin>

My environment is: 
* Eclipse Kepler (tested with 4.3.0 and 4.3.1) with m2e and m2e-wtp preinstalled
* Maven 3.0.1
* JDK 1.6
(and this was working in Eclipse 3.7...)

Is this supposed to work or is it a bug? 
What could I do to have these projects work locally, without adding my mock classes to the generated war for the "real" deployment? would an option in m2e-wtp to also publish test classpath be a workaround solution?

Thank you for your help,

Sophie
https://www.bil.com/Documents/mail-disclaimer.html



Back to the top