You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by fyzahmd <fy...@gmail.com> on 2013/03/27 12:36:12 UTC

Maven compiler plugin for Same src folder for tests and source code

Hi All,

I have a project which has the following structure.
<http://maven.40175.n5.nabble.com/file/n5752030/Capture.txt> 

Compilation works fine in eclipse.
How can i compile this using maven ?(both test cases and source file)..


Thanks and Regards,
Fayaz ahamed



   



--
View this message in context: http://maven.40175.n5.nabble.com/Maven-compiler-plugin-for-Same-src-folder-for-tests-and-source-code-tp5752030.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven compiler plugin for Same src folder for tests and source code

Posted by Stephen Connolly <st...@gmail.com>.
There are a number of options. I am ranking them in the order that IMHO
will result in the least number of hacks to Maven.

1. Switch to the Maven way, move the production code to src/main/java/...
and the tests to src/test/java/....

2. Modify the <plugin> configuration for the Maven compiler plugin so that
you set
http://maven.apache.org/plugins/maven-compiler-plugin/testCompile-mojo.html#testIncludesto
com/unit/test/**.java and set
http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#excludesto
com/unit/test/**.java Finally you will need to play with
http://maven.apache.org/pom.html#Directories to set sourceDirectory and
testSourceDirectory to be both ${basedir}/src. If you do all that, then you
should be OK, but adding other plugins that don't play well with Maven's
actual configuration will force more hacks upon you.

3. Change your test dependencies from <scope>test</scope> to
<scope>compile</scope> (note that this may subsequently need hacks to get
surefire to run the tests, and so the layering of hacks begins) You will
probably also need to play with
http://maven.apache.org/pom.html#Directoriesto set sourceDirectory
and testSourceDirectory to be both ${basedir}/src. If you do all that, then
you should be OK, but adding other plugins that don't play well with
Maven's actual configuration will force more hacks upon you.

The easiest is #1. Eclipse with the m2e plugin will pick up the
configuration changes for you. #2 is the next safest, but in the long run
will cause you to cry and vent swearwords at Maven (even though it was you
that picked option 2) #3 is destined to blow up in your face when you least
expect it.


On 27 March 2013 11:36, fyzahmd <fy...@gmail.com> wrote:

> Hi All,
>
> I have a project which has the following structure.
> <http://maven.40175.n5.nabble.com/file/n5752030/Capture.txt>
>
> Compilation works fine in eclipse.
> How can i compile this using maven ?(both test cases and source file)..
>
>
> Thanks and Regards,
> Fayaz ahamed
>
>
>
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Maven-compiler-plugin-for-Same-src-folder-for-tests-and-source-code-tp5752030.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>