Doesn't sound as a good Maven solution. You're trying to create an Ant
script solution with Maven, at least from my perspective. Using profiles is
normally not the right way to solve things in Maven.

Start by moving your mock classes to a separate project/module. You can
then reuse that artifact where ever you want. If you want to use it in your
unit tests in a project, you declare a test scoped dependency. If you want
to include it in your war, you declare a compile scope dependency (or
possibly a runtime dep, dependening on your mock solution).
Remember not to use profiles to change the result of the build though. If
you want to two flavors of your project, you should create two separate
Maven projects.

/Anders

On Wed, Oct 2, 2013 at 2:57 PM, Ramel Sophie (BIL) <sophie.ra...@bil.com>wrote:

> 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
>
> _______________________________________________
> m2e-users mailing list
> m2e-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/m2e-users
>
_______________________________________________
m2e-users mailing list
m2e-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/m2e-users

Reply via email to