You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laurie Harper <la...@holoweb.net> on 2006/09/07 01:02:29 UTC
Compiler plugin configuration
I'm trying to add support to my M2 build for my integration tests, which
ideally need to be run against the assembled webapp. To do this, I added
a profile which, when enabled, will bind the compiler and surefire
plugins to the integration-test lifecycle phase.
Everything seems to be working except that I can't figure out how to get
the compiler plugin to compile the right set of sources and put the
resulting classes where I want them, so integration tests remain
separate from unit tests.
It seems that setting testSourceDirectory, testClassesDirectory or
testOutputDirectory in the compiler plugin's configuration has no
effect; trying to set compileSourceRoots or outputDirectory raises an error:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>itest:testCompile</id>
<phase>integration-test</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<!--<compileSourceRoots>src/tests/integration</compileSourceRoots>-->
<!--<outputDirectory>target/test-classes-itest</outputDirectory>-->
<testSourceDirectory>src/tests/integration</testSourceDirectory>
<testClassesDirectory>target/test-classes-itest</testClassesDirectory>
<testOutputDirectory>target/test-classes-itest</testOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Is there a way to achieve this, short of reorganizing the source tree
and/or breaking the project up into modules?
Thanks,
L.
<profile>
<id>itest</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>itest:testCompile</id>
<phase>integration-test</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<!--<compileSourceRoots>src/tests/integration</compileSourceRoots>-->
<!--<outputDirectory>target/test-classes-itest</outputDirectory>-->
<testSourceDirectory>src/tests/integration</testSourceDirectory>
<testClassesDirectory>target/test-classes-itest</testClassesDirectory>
<testOutputDirectory>target/test-classes-itest</testOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>itest:test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testClassesDirectory>target/test-classes-itest</testClassesDirectory>
<reportsDirectory>target/surefire-reports-itest</reportsDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>1.2.7</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Compiler plugin configuration
Posted by Laurie Harper <la...@holoweb.net>.
Wendy Smoak wrote:
> On 9/6/06, Laurie Harper <la...@holoweb.net> wrote:
>
>> Everything seems to be working except that I can't figure out how to get
>> the compiler plugin to compile the right set of sources and put the
>> resulting classes where I want them, so integration tests remain
>> separate from unit tests.
> ...
>> Is there a way to achieve this, short of reorganizing the source tree
>> and/or breaking the project up into modules?
>
> Maven does not have good support for combining both unit tests and
> integration tests in the same module.
It used to hint at having first-class support, with an
integrationTestSource element in the POM etc. -- and even today, there
is an 'integration-test' build phase -- but yeah, I know this isn't
something that's directly supported. Hence the attempt to squish it into
my build ;-)
> You can do it by playing around with includes/excludes, but you're
> only allowed one testSourceDirectory per module. (And probably one
> target directory, though I haven't tried to change that.)
For the compiler plugin, one testSourceDirectoy and one test class
target directory, yeah, as far as I can tell. It's odd, therefore, that
the surefire and surefire-report plugins are quite happy to look in a
different directory for test classes -- since there's no apparent way to
get them there...
> Here's a recent thread that links to some examples:
> http://www.nabble.com/Multipart-question-regarding-releasing-with-an-assembly-and-integration-tests.-t2193916.html#a6072535
Heh, Cargo is my next level; my integration tests don't require the
webapp deployed and running, but my acceptance tests do ;-)
> At least until Maven supports separate src/it/java and src/test/java
> directories, putting your integration tests in a separate module is
> the best way to go. This is described in the 'Better Builds with
> Maven' book.
Yeah, with a green-field project I do things the 'maven way'. It's all
those projects that pre-date Maven that cause the trouble :-(
> That said, we do combine unit and integration tests in the Shale
> example apps, and it works well enough.
Ah, good to know, I'll check out how that works; maybe it'll represent
an acceptable compromise for this project.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Compiler plugin configuration
Posted by Wendy Smoak <ws...@gmail.com>.
On 9/6/06, Laurie Harper <la...@holoweb.net> wrote:
> Everything seems to be working except that I can't figure out how to get
> the compiler plugin to compile the right set of sources and put the
> resulting classes where I want them, so integration tests remain
> separate from unit tests.
...
> Is there a way to achieve this, short of reorganizing the source tree
> and/or breaking the project up into modules?
Maven does not have good support for combining both unit tests and
integration tests in the same module.
You can do it by playing around with includes/excludes, but you're
only allowed one testSourceDirectory per module. (And probably one
target directory, though I haven't tried to change that.)
Here's a recent thread that links to some examples:
http://www.nabble.com/Multipart-question-regarding-releasing-with-an-assembly-and-integration-tests.-t2193916.html#a6072535
At least until Maven supports separate src/it/java and src/test/java
directories, putting your integration tests in a separate module is
the best way to go. This is described in the 'Better Builds with
Maven' book.
That said, we do combine unit and integration tests in the Shale
example apps, and it works well enough.
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org