Hi all. I'm the peterj who contributed the patch in question. I appreciate the discussion it's started, and I have a few questions.

If it's not possible to update the compiler plugin, is there any way to get traction on the apparent reluctance[1][2] to add integration test elements to the POM? The discussion in [3] seems to have died out and several comments in MNG-2010[1] indicate that new phases (and the additional configuration in MNG-2009 and MNG-2011) will not be considered. Are the use cases given in the bugs just insufficient---in which case effort might be put into expanding them to make the case more clearly---or is this strictly won't-fix across the board?

On a related note, the discussion has made me curious as to why maven-surefire-plugin allows its directories to be configured if maven-compiler-plugin isn't allowed to generate classes in those directories for it to use. <sourceDirectory>/<outputDirectory> and <testSourceDirectory>/<testOutputDirectory> are nicely parallel, but m-s-p allows the latter pair (as well as <outputDirectory>, essentially) to be overridden in the same "bad" way as is being proposed here.

Jason: "people who have messed up systems" is a little vague. (I don't take offence to the suggestion that the use case is "messed up", but I am curious how you came to that conclusion; it makes sense to me, and apparently others.) Can you describe the approved method of compiling and executing integration tests within the existing POM structure? [3] links to a lot of bugs on the issue, and there are pages and pages around the web, but none I've found actually have solutions. Hence the trivial patch, which provides an answer that remains compatible with current use and supports the functionality found in a core plugin.

Thanks for considering the patch (and even applying it briefly) and for the ensuing discussion.

Peter J.

[1] http://jira.codehaus.org/browse/MNG-2010
[2] http://jira.codehaus.org/browse/MNG-591
[3] http://docs.codehaus.org/display/MAVEN/best+practices+-+testing+strategies

On 13/03/09 09:14 PM, Brian E. Fox wrote:
Yes it is odd, but I share jason's concern that sending the source
folders directly to the compiler plugin is bad because then tools that
look at the pom won't find the sources. (which btw is the case even with
the buildhelper)
-----Original Message-----
From: Paul Gier [mailto:[email protected]] Sent: Friday, March 13, 2009 4:51 PM
To: Maven Developers List
Subject: Re: svn commit: r753302 - in
/maven/plugins/trunk/maven-compiler-plugin/src:
it/alt-src-output-directories-MCOMPILER-91/
it/alt-src-output-directories-MCOMPILER-91/src/
it/alt-src-output-directories-MCOMPILER-91/src/my-classes/
it/alt-src-output-directori

Yeah, it probably could be done like that.  But it seems a little
strange way to accomplish it.
Also that would put all the output into a single directory, and I would
prefer to keep the classes separate in the output.

Brian E. Fox wrote:
Can you do it with multiple compiler executions? I'm thinking
something
like add all the src folders, and then exclude them in one execution
and
vice-versa in the other.
-----Original Message-----
From: Paul Gier [mailto:[email protected]] Sent: Friday, March 13, 2009 4:15 PM
To: Maven Developers List
Subject: Re: svn commit: r753302 - in
/maven/plugins/trunk/maven-compiler-plugin/src:
it/alt-src-output-directories-MCOMPILER-91/
it/alt-src-output-directories-MCOMPILER-91/src/
it/alt-src-output-directories-MCOMPILER-91/src/my-classes/
it/alt-src-output-directori

The build helper plugin allows me to add more source directories, but
doesn't allow me to have different compiler configurations for the different directories. And also doesn't allow me to specify separate output
directories.

I have some situations where it is useful to have two separate test
sources that are compiled differently and then output to different locations. For the main sources it's not as much of an issue.

Brian E. Fox wrote:
Why doesn't the buildhelper plugin work for this use case? That lets
you
attach many source folders.

-----Original Message-----
From: Paul Gier [mailto:[email protected]] Sent: Friday, March 13, 2009 2:58 PM
To: Maven Developers List
Subject: Re: svn commit: r753302 - in
/maven/plugins/trunk/maven-compiler-plugin/src:
it/alt-src-output-directories-MCOMPILER-91/
it/alt-src-output-directories-MCOMPILER-91/src/
it/alt-src-output-directories-MCOMPILER-91/src/my-classes/
it/alt-src-output-directori

Do you have an issue with it in both the compile and test-compile
mojos?
Or is the test-compile mojo ok?
The test-compile mojo is where I need it because I have multiple sets
of
test classes that require different compile parameters.

Jason van Zyl wrote:
-1

I don't want people to start abusing this and directly using
multiple
source directories. This will get abused so fast and is only
required
by
people who have messed up systems.

On 13-Mar-09, at 8:37 AM, [email protected] wrote:

Author: pgier
Date: Fri Mar 13 15:37:13 2009
New Revision: 753302

URL: http://svn.apache.org/viewvc?rev=753302&view=rev
Log:
[MCOMPILER-91] Allow source and output directories to be
configured.
Patch from Peter Janes (peterj).

Added:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/pom.xml
(with props)
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/MyTest.java
(with props)
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/verify.bsh
(with props)
Modified:
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/CompilerMojo.java
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/TestCompilerMojo.java
Added:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/s
rc/it/alt-src-output-directories-MCOMPILER-91/pom.xml?rev=753302&view=au
to
========================================================================
======
---
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/pom.xml
(added)
+++
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/pom.xml
Fri Mar 13 15:37:13 2009
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.compiler</groupId>
+  <artifactId>altconfig</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Test for alternative source/target configuration</name>
+
+  <properties>
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>@pom.version@</version>
+        <executions>
+          <execution>
+            <id>my-classes</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+            <configuration>
+              <compileSourceRoots>
+ <compileSourceRoot>src/my-classes/java</compileSourceRoot>
+              </compileSourceRoots>
+              <outputDirectory>target/my-classes</outputDirectory>
+            </configuration>
+          </execution>
+          <execution>
+            <id>my-test-classes</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+            <configuration>
+              <compileSourceRoots>
+ <compileSourceRoot>src/my-classes/java</compileSourceRoot>
+              </compileSourceRoots>
+
<outputDirectory>target/my-test-classes</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/pom.xml
------------------------------------------------------------------------
------
   svn:eol-style = native

Propchange:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/pom.xml
------------------------------------------------------------------------
------
   svn:keywords = Author Date Id Revision

Added:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/MyTest.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/s
rc/it/alt-src-output-directories-MCOMPILER-91/src/my-classes/java/MyTest
.java?rev=753302&view=auto
========================================================================
======
---
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/MyTest.java
(added)
+++
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/MyTest.java
Fri Mar 13 15:37:13 2009
@@ -0,0 +1,7 @@
+import junit.framework.TestCase;
+
+public class MyTest
+    extends TestCase
+{
+
+}

Propchange:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/MyTest.java
------------------------------------------------------------------------
------
   svn:eol-style = native

Propchange:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/src/my-classes/java/MyTest.java
------------------------------------------------------------------------
------
   svn:keywords = Author Date Id Revision

Added:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/verify.bsh
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/s
rc/it/alt-src-output-directories-MCOMPILER-91/verify.bsh?rev=753302&view
=auto
========================================================================
======
---
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/verify.bsh
(added)
+++
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/verify.bsh
Fri Mar 13 15:37:13 2009
@@ -0,0 +1,24 @@
+import java.io.*;
+
+try
+{
+ File outputClasses = new File( basedir, "target/my-classes/MyTest.class" );
+    if ( !outputClasses.isFile() )
+    {
+ System.out.println( "Test class not existent: " + outputClasses );
+        return false;
+    }
+ File outputTestClasses = new File( basedir, "target/my-test-classes/MyTest.class" );
+    if ( !outputTestClasses.isFile() )
+    {
+ System.out.println( "Test class not existent: " + outputTestClasses );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/verify.bsh
------------------------------------------------------------------------
------
   svn:eol-style = native

Propchange:
maven/plugins/trunk/maven-compiler-plugin/src/it/alt-src-output-director
ies-MCOMPILER-91/verify.bsh
------------------------------------------------------------------------
------
   svn:keywords = Author Date Id Revision

Modified:
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/CompilerMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/s
rc/main/java/org/apache/maven/plugin/CompilerMojo.java?rev=753302&r1=753
301&r2=753302&view=diff
========================================================================
======
---
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/CompilerMojo.java
(original)
+++
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/CompilerMojo.java
Fri Mar 13 15:37:13 2009
@@ -45,11 +45,18 @@
    extends AbstractCompilerMojo
{
    /**
+     * The default source directories containing the sources to be

compiled.
+     *
+     * @parameter default-value="${project.compileSourceRoots}"
+     *
+     */
+    private List defaultCompileSourceRoots;
+
+    /**
     * The source directories containing the sources to be
compiled.
     *
-     * @parameter expression="${project.compileSourceRoots}"
-     * @required
-     * @readonly
+     * @parameter
+     *
     */
    private List compileSourceRoots;

@@ -65,9 +72,8 @@
    /**
     * The directory for compiled classes.
     *
-     * @parameter expression="${project.build.outputDirectory}"
+     * @parameter default-value="${project.build.outputDirectory}"
     * @required
-     * @readonly
     */
    private File outputDirectory;

@@ -97,6 +103,10 @@

    protected List getCompileSourceRoots()
    {
+        if( compileSourceRoots == null )
+        {
+            compileSourceRoots = defaultCompileSourceRoots;
+        }
        return compileSourceRoots;
    }


Modified:
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/TestCompilerMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/s
rc/main/java/org/apache/maven/plugin/TestCompilerMojo.java?rev=753302&r1
=753301&r2=753302&view=diff
========================================================================
======
---
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/TestCompilerMojo.java
(original)
+++
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven
/plugin/TestCompilerMojo.java
Fri Mar 13 15:37:13 2009
@@ -52,11 +52,18 @@
    private boolean skip;

    /**
-     * The source directories containing the test-source to be
compiled.
+     * The default source directories containing the test-source
to
be compiled.
     *
-     * @parameter expression="${project.testCompileSourceRoots}"
-     * @required
+     * @parameter
default-value="${project.testCompileSourceRoots}"
     * @readonly
+     * @required
+     */
+    private List defaultCompileSourceRoots;
+
+    /**
+     * The source directories containing the test-source to be
compiled.
+     *
+     * @parameter
     */
    private List compileSourceRoots;

@@ -72,9 +79,8 @@
    /**
     * The directory where compiled test classes go.
     *
-     * @parameter
expression="${project.build.testOutputDirectory}"
+     * @parameter
default-value="${project.build.testOutputDirectory}"
     * @required
-     * @readonly
     */
    private File outputDirectory;

@@ -149,6 +155,10 @@

    protected List getCompileSourceRoots()
    {
+        if( compileSourceRoots == null )
+        {
+            compileSourceRoots = defaultCompileSourceRoots;
+        }
        return compileSourceRoots;
    }



Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
http://twitter.com/jvanzyl
----------------------------------------------------------




---------------------------------------------------------------------
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]


---------------------------------------------------------------------
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]


---------------------------------------------------------------------
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



--
Sometimes the Universe needs a change of perspective.
  --J. Michael Straczynski

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to