You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tiago Fernandez <ti...@gmail.com> on 2006/04/18 04:35:46 UTC

Working with more than one module

 Hello everyone,

I'm trying to change the whole architecture structure I've got to get it
working along Maven 2, following the best practices (
http://maven.apache.org/guides/mini/guide-using-one-source-directory.html).
So, currently I've got a project with a structure like this:

/
+- pom.xml
+- src/
...+- main/
......+- java/
..........+- /mypack/
..............+- core/
..............+- gui/
...+- test/
......+- java/
..........+- /mypack/
..............+- core/
..............+- gui/
+- core/
...+- pom.xml
...+- target/
......+- my-core-1.0.jar
+- gui/
...+- pom.xml
...+- target/
......+- my-module-1.0.jar

It's building ok when I don't tell Maven to run the test cases, but when
turning it on, maven-surefire-plugin gets confused for some reason. The
issue is: when testing only the core module, surefire's plugin is trying to
compile also the tests from the gui module. In core/pom.xml I'm including
ONLY core's tests:

<testSourceDirectory>../src/test/java/</testSourceDirectory>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/core/**</include>
</includes>
</configuration>
</plugin>

Is there another way to compile only the core's tests? Did anybody already
experience this problem?

Thanks a lot.

--

Tiago Fernandez
http://www.tiago182.spyw.com

Re: Working with more than one module

Posted by Tiago Fernandez <ti...@gmail.com>.
Thanks Wayne, in fact I think your solution could solve my problem :-)

BTW, the layout I've shown previously was taken out from:
http://maven.apache.org/guides/mini/guide-using-one-source-directory.html

And I was waiting for something on:
http://maven.apache.org/guides/mini/guide-multi-module.html

But as you can see, there's nothing there yet.

Kind regards,
Tiago

On 4/17/06, Wayne Fay <wa...@gmail.com> wrote:
>
> I hate to break it to you, but you haven't really totally followed the
> Maven best practices with this architecture. So let me help you out,
> if you don't mind... ;-)
>
> Here's how I would do it:
>
> > /
> > +- pom.xml
> > +- core/
> > ...+- pom.xml
> > ...+- src/
> > ......+- main/
> > .........+- java/
> > .............+- /mypack/
> > ................+- core/
> > ...+- test/
> > ......+- java/
> > ..........+- /mypack/
> > ..............+- core/
> > ...+- target/
> > ......+- my-core-1.0.jar
> > +- gui/
> > ...+- pom.xml
> > ...+- src/
> > ......+- main/
> > .........+- java/
> > .............+- /mypack/
> > ................+- gui/
> > ...+- test/
> > ......+- java/
> > ..........+- /mypack/
> > ..............+- gui/
> > ...+- target/
> > ......+- my-module-1.0.jar
>
> Thus your core code and tests only live inside the /core/ module, and
> your gui code and tests only live inside the /gui/ module, and your
> GUI module perhaps brings in the Core module as a dependency, and both
> have the /pom.xml as <parent>.
>
> This would solve your surefire problems as well.
>
> Wayne
>
>
> On 4/17/06, Tiago Fernandez <ti...@gmail.com> wrote:
> >  Hello everyone,
> >
> > I'm trying to change the whole architecture structure I've got to get it
> > working along Maven 2, following the best practices (
> >
> http://maven.apache.org/guides/mini/guide-using-one-source-directory.html
> ).
> > So, currently I've got a project with a structure like this:
> >
> > /
> > +- pom.xml
> > +- src/
> > ...+- main/
> > ......+- java/
> > ..........+- /mypack/
> > ..............+- core/
> > ..............+- gui/
> > ...+- test/
> > ......+- java/
> > ..........+- /mypack/
> > ..............+- core/
> > ..............+- gui/
> > +- core/
> > ...+- pom.xml
> > ...+- target/
> > ......+- my-core-1.0.jar
> > +- gui/
> > ...+- pom.xml
> > ...+- target/
> > ......+- my-module-1.0.jar
> >
> > It's building ok when I don't tell Maven to run the test cases, but when
> > turning it on, maven-surefire-plugin gets confused for some reason. The
> > issue is: when testing only the core module, surefire's plugin is trying
> to
> > compile also the tests from the gui module. In core/pom.xml I'm
> including
> > ONLY core's tests:
> >
> > <testSourceDirectory>../src/test/java/</testSourceDirectory>
> > ...
> > <plugin>
> > <artifactId>maven-surefire-plugin</artifactId>
> > <configuration>
> > <includes>
> > <include>**/core/**</include>
> > </includes>
> > </configuration>
> > </plugin>
> >
> > Is there another way to compile only the core's tests? Did anybody
> already
> > experience this problem?
> >
> > Thanks a lot.
> >
> > --
> >
> > Tiago Fernandez
> > http://www.tiago182.spyw.com
>

Re: Working with more than one module

Posted by Wayne Fay <wa...@gmail.com>.
I hate to break it to you, but you haven't really totally followed the
Maven best practices with this architecture. So let me help you out,
if you don't mind... ;-)

Here's how I would do it:

> /
> +- pom.xml
> +- core/
> ...+- pom.xml
> ...+- src/
> ......+- main/
> .........+- java/
> .............+- /mypack/
> ................+- core/
> ...+- test/
> ......+- java/
> ..........+- /mypack/
> ..............+- core/
> ...+- target/
> ......+- my-core-1.0.jar
> +- gui/
> ...+- pom.xml
> ...+- src/
> ......+- main/
> .........+- java/
> .............+- /mypack/
> ................+- gui/
> ...+- test/
> ......+- java/
> ..........+- /mypack/
> ..............+- gui/
> ...+- target/
> ......+- my-module-1.0.jar

Thus your core code and tests only live inside the /core/ module, and
your gui code and tests only live inside the /gui/ module, and your
GUI module perhaps brings in the Core module as a dependency, and both
have the /pom.xml as <parent>.

This would solve your surefire problems as well.

Wayne


On 4/17/06, Tiago Fernandez <ti...@gmail.com> wrote:
>  Hello everyone,
>
> I'm trying to change the whole architecture structure I've got to get it
> working along Maven 2, following the best practices (
> http://maven.apache.org/guides/mini/guide-using-one-source-directory.html).
> So, currently I've got a project with a structure like this:
>
> /
> +- pom.xml
> +- src/
> ...+- main/
> ......+- java/
> ..........+- /mypack/
> ..............+- core/
> ..............+- gui/
> ...+- test/
> ......+- java/
> ..........+- /mypack/
> ..............+- core/
> ..............+- gui/
> +- core/
> ...+- pom.xml
> ...+- target/
> ......+- my-core-1.0.jar
> +- gui/
> ...+- pom.xml
> ...+- target/
> ......+- my-module-1.0.jar
>
> It's building ok when I don't tell Maven to run the test cases, but when
> turning it on, maven-surefire-plugin gets confused for some reason. The
> issue is: when testing only the core module, surefire's plugin is trying to
> compile also the tests from the gui module. In core/pom.xml I'm including
> ONLY core's tests:
>
> <testSourceDirectory>../src/test/java/</testSourceDirectory>
> ...
> <plugin>
> <artifactId>maven-surefire-plugin</artifactId>
> <configuration>
> <includes>
> <include>**/core/**</include>
> </includes>
> </configuration>
> </plugin>
>
> Is there another way to compile only the core's tests? Did anybody already
> experience this problem?
>
> Thanks a lot.
>
> --
>
> Tiago Fernandez
> http://www.tiago182.spyw.com
>
>