Hi Pablo,

I believe you can resolve this by added an extra source directory using
the build-helper-maven-plugin. In your use-case you would add the main
source directory like this:

<sourceDirectory>src/webapp/WEB-INF/src</sourceDirectory>

Add any additional source directories using the
build-helper-maven-plugin:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>src/integration-tests</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>

If you use this plugin you don't need any configuration of the 
maven-compiler-plugin. Your additional sources will be compiled
automatically.


-----Oorspronkelijk bericht-----
Van: Pablo [mailto:[EMAIL PROTECTED] 
Verzonden: dinsdag 10 januari 2006 13:55
Aan: Maven Users List
Onderwerp: maven-compiler-plugin

Hello everyone

I have the following project structure:
/src/webapp/WEB-INF/src etc.
/src/tests
/src/integration-tests

Junit tests are compiled automatically by setting the value below:
<testSourceDirectory>src/tests/java</testSourceDirectory>

Now I want to use the same plugin to compile integration-tests. The 
compiled tests should be placed in target/integration-tests.

Since fields:
private List compileSourceRoots;
private File outputDirectory;
are readonly it's not possible to set them in plugin's configuration.

I removed @readonly attribute and installed the plugin just to see if it

would work.

This is the part of my pom.xml which defines compiler plugin:
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <encoding>iso-8859-2</encoding>
        </configuration>
        <executions>
          <execution>
            <id>testy</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compileSourceRoots>
 
<compileSourceRoot>src/integration-tests</compileSourceRoot>
              </compileSourceRoots>
              
<outputDirectory>${project.build}/integration-tests</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
I thought that I could change compilesourceRoot and outputDirectory and 
all integration tests would be compiled.
But it isn't so:
[EMAIL PROTECTED]:~/cvsroot/webapp$ mvn clean test-compile
[INFO] Scanning for projects...
[INFO] 
------------------------------------------------------------------------
----
[INFO] Building WebApp
[INFO]    task-segment: [clean, test-compile]
[INFO] 
------------------------------------------------------------------------
----
[INFO] [clean:clean]
[INFO] Deleting directory /home/pablo/cvsroot/webapp/target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 225 source files to /home/pablo/cvsroot/webapp/target/classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 19 source files to
/home/pablo/cvsroot/webapp/target/test-classes
[INFO] [compiler:testCompile {execution: testy}]
Compiling 19 source files to 
/home/pablo/cvsroot/webapp/target/integration-tests
[INFO] 
------------------------------------------------------------------------
----
[INFO] BUILD SUCCESSFUL
[INFO] 
------------------------------------------------------------------------
----
[INFO] Total time: 59 seconds
[INFO] Finished at: Tue Jan 10 13:50:51 CET 2006
[INFO] Final Memory: 7M/33M
[INFO] 
------------------------------------------------------------------------
----

The compiler plugin is run twice. As you can see 
<outputDirectory>${project.build}/integration-tests</outputDirectory>
is used but tests sources' directory is not. What am I doing wrong? How 
can I use this plugin to compile additional things? And will it be ever 
possible to do it? I had to remove @readonly attributes.

Thanks for reading
Pablo

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to