You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Oleg Gusakov <ol...@gmail.com> on 2008/10/19 18:52:07 UTC

compiler plugin: separate test compiler configuration

One of the users requested a separate source/target configuration for 
test compiler for the reason of running junit4 tests and yet being java 
1.4 in the main classes.

It's a trivial change in the compiler plugin, but I decided to ask here 
before changing it.

The proposed change - add two configuration parameters:

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <testSource>1.5</testSource>
          <testTarget>1.5</testTarget>
        </configuration>
      </plugin>


Please let me know if it breaks anything. Please also indicate if you 
need more separation (like memory, etc)?

Thanks,
Oleg

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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
It did not work for me, and this might have been the reason.

Anyway, I changed the compiler plugin and you can now use testSource and 
testTarget withing the same execution, if you'd like to.

Thank you for the update,
Oleg

� wrote:
> Oleg Gusakov wrote:
>   
>> Such contriction will not work. The problem is in the way compiler
>> plugin is instantiated: compiler environment is created, and them the
>> same instance is reused for test-compiler, sticking to the existing
>> plugin configuration. Execution does not get a new instance of as far
>> as  can see. 
>>
>> That is why I had to enhance the configuration of compiler plugin -
>> 2.1-SNAPSHOT now accepts the "test" set of parameters; see
>> http://jira.codehaus.org/browse/MCOMPILER-83
>>     
>
> It can work, we do so for years now: http://svn.xstream.codehaus.org/browse/~raw,r=HEAD/xstream/trunk/xstream/pom.xml. The profile for JDK 5 + 6 configure the compiler plugin with a second execution to compile the JDK 5 specific stuff with source/target=1.5 while the standard execution uses source/target=1.3. The only caveat is that the entries in the excludes lists must have exactly the same number of entries. This can be used to compile main source with source/target=1.3 while the test source is compiled with source/target = 1.5:
>
> ============= %< ===============
> <plugin>
>   <groupId>org.apache.maven.plugins</groupId>
>   <artifactId>maven-compiler-plugin</artifactId>
>   <configuration>
>     <source>1.3</source>
>     <target>1.3</target>
>     <excludes>
>       <exclude>foo</exclude>
>     </excludes>
>     <testExcludes>
>       <exclude>**</exclude>
>     </testExcludes>
>   </configuration>
>   <executions>
>     <execution>
>       <id>compile-jdk15</id>
>       <configuration>
>         <source>1.5</source>
>         <target>1.5</target>
>         <excludes>
>           <exclude>**</exclude>
>         </excludes>
>         <testExcludes>
>           <exclude>foo</exclude>
>         </testExcludes>
>       </configuration>
>       <goals>
>         <goal>compile</goal>
>         <goal>testCompile</goal>
>       </goals>
>     </execution>
>   </executions>
> </plugin>
> ============= %< ===============
>
> - J�rg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
>   

RE: compiler plugin: separate test compiler configuration

Posted by Jörg Schaible <Jo...@scalaris.com>.
Oleg Gusakov wrote:
> Such contriction will not work. The problem is in the way compiler
> plugin is instantiated: compiler environment is created, and them the
> same instance is reused for test-compiler, sticking to the existing
> plugin configuration. Execution does not get a new instance of as far
> as  can see. 
> 
> That is why I had to enhance the configuration of compiler plugin -
> 2.1-SNAPSHOT now accepts the "test" set of parameters; see
> http://jira.codehaus.org/browse/MCOMPILER-83

It can work, we do so for years now: http://svn.xstream.codehaus.org/browse/~raw,r=HEAD/xstream/trunk/xstream/pom.xml. The profile for JDK 5 + 6 configure the compiler plugin with a second execution to compile the JDK 5 specific stuff with source/target=1.5 while the standard execution uses source/target=1.3. The only caveat is that the entries in the excludes lists must have exactly the same number of entries. This can be used to compile main source with source/target=1.3 while the test source is compiled with source/target = 1.5:

============= %< ===============
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.3</source>
    <target>1.3</target>
    <excludes>
      <exclude>foo</exclude>
    </excludes>
    <testExcludes>
      <exclude>**</exclude>
    </testExcludes>
  </configuration>
  <executions>
    <execution>
      <id>compile-jdk15</id>
      <configuration>
        <source>1.5</source>
        <target>1.5</target>
        <excludes>
          <exclude>**</exclude>
        </excludes>
        <testExcludes>
          <exclude>foo</exclude>
        </testExcludes>
      </configuration>
      <goals>
        <goal>compile</goal>
        <goal>testCompile</goal>
      </goals>
    </execution>
  </executions>
</plugin>
============= %< ===============

- Jörg

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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
Such contriction will not work. The problem is in the way compiler 
plugin is instantiated: compiler environment is created, and them the 
same instance is reused for test-compiler, sticking to the existing 
plugin configuration. Execution does not get a new instance of as far 
as  can see.

That is why I had to enhance the configuration of compiler plugin - 
2.1-SNAPSHOT now accepts the "test" set of parameters; see 
http://jira.codehaus.org/browse/MCOMPILER-83

Thanks,
Oleg

mlorenzi wrote:
> Milos Kleint wrote:
>   
>> well, I suppose the question was if configuring just the testCompile
>> execution doesn't work.
>> I suppose having a general config at sourcelevel 1.4 and then specific
>> one for testCompile execution shall work.
>>
>>     
>
> I've the same problem and I've tried this way too, but it seems it doesnt
> work.
> I've reduced it in a very simple pom with something like this 
> (for example to configure compiler version 1.4 as default but 1.5 for test
> compile):
>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <compilerVersion>1.4</compilerVersion>
>         </configuration>
>         <executions>
>           <execution>
>             <id>xxx</id>
>             <phase>test-compile</phase>
>             <goals>
>               <goal>testCompile</goal>
>             </goals>
>             <configuration>
>               <compilerVersion>1.5</compilerVersion>
>             </configuration>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
>
> if I try a clean test -X I see in the log that the general configuration is
> used and the one in the execution is simply ignored:
>
> [DEBUG]   (f) compilerVersion = 1.4
> ...
> [DEBUG] -- end configuration --
> [INFO] [compiler:compile]
>
> [DEBUG]   (f) compilerVersion = 1.4
> [DEBUG] -- end configuration --
> [INFO] [compiler:testCompile]
>
> I've a more complex situation in real projects where I need to configure the
> compilation for integration tests with a java 1.5 compiler keeping the 1.4
> for the application sources, but I'm not able to do (same problem).
> Is there something wrong with my configuration or it is a bug?
> Attached is the sample pom which I used for the test.
> http://www.nabble.com/file/p20379248/foo-pom.zip foo-pom.zip 
>   

Re: compiler plugin: separate test compiler configuration

Posted by mlorenzi <Mi...@phoenixspa.it>.

Milos Kleint wrote:
> 
> well, I suppose the question was if configuring just the testCompile
> execution doesn't work.
> I suppose having a general config at sourcelevel 1.4 and then specific
> one for testCompile execution shall work.
> 

I've the same problem and I've tried this way too, but it seems it doesnt
work.
I've reduced it in a very simple pom with something like this 
(for example to configure compiler version 1.4 as default but 1.5 for test
compile):

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerVersion>1.4</compilerVersion>
        </configuration>
        <executions>
          <execution>
            <id>xxx</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compilerVersion>1.5</compilerVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

if I try a clean test -X I see in the log that the general configuration is
used and the one in the execution is simply ignored:

[DEBUG]   (f) compilerVersion = 1.4
...
[DEBUG] -- end configuration --
[INFO] [compiler:compile]

[DEBUG]   (f) compilerVersion = 1.4
[DEBUG] -- end configuration --
[INFO] [compiler:testCompile]

I've a more complex situation in real projects where I need to configure the
compilation for integration tests with a java 1.5 compiler keeping the 1.4
for the application sources, but I'm not able to do (same problem).
Is there something wrong with my configuration or it is a bug?
Attached is the sample pom which I used for the test.
http://www.nabble.com/file/p20379248/foo-pom.zip foo-pom.zip 
-- 
View this message in context: http://www.nabble.com/compiler-plugin%3A-separate-test-compiler-configuration-tp20058021p20379248.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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


RE: compiler plugin: separate test compiler configuration

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
MNG-3203 is what I was thinking of. My use case at the time was to use jdk 1.5 for running the tests only. We needed 1.4 for the actual code but I wanted 1.5 in testing so I could use testng properly to get cobertura output.

-----Original Message-----
From: Brett Porter [mailto:brett@apache.org] 
Sent: Sunday, October 19, 2008 7:21 PM
To: Maven Developers List
Subject: Re: compiler plugin: separate test compiler configuration

MCOMPILER-15

MNG-3203 is for a workaround in Maven

Cheers,
Brett

On 20/10/2008, at 10:13 AM, Brian E. Fox wrote:

> There's already a jira for this since I originally suggested it a  
> long time ago. IIRC John and I looked at it and found some problems  
> with it but I'd have to dig up the jira to remember.
>
> -----Original Message-----
> From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com]
> Sent: Sunday, October 19, 2008 4:51 PM
> To: Maven Developers List
> Subject: Re: compiler plugin: separate test compiler configuration
>
> This could be arranged, but Eugene has a very valid question - Eclipse
> sets all those on the project level and might misbehave as soon as
> somebody starts debugging such a project.
>
> Milos, you can say that's eclipse's problem. But is't a majority of
> users, whether it's good or bad, we need to respect that use case.
>
> So the question remains - should we modify the compiler plugin to  
> allow
> separate configurations for test compiler? Or if such a need comes -
> it's an indication that it's time to move tests into a separate  
> project?
>
> Anyone ?
>
> � wrote:
>> Yes Milos, it was my question.
>>
>> In fact, it's nice to can specify specific configuration for both  
>> source and
>> test.
>>
>> For instance, we want to be able to define the source and target  
>> level but
>> also some other configuration such as compilerArgument and so on
>>
>> R�my
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


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


Re: compiler plugin: separate test compiler configuration

Posted by Brett Porter <br...@apache.org>.
MCOMPILER-15

MNG-3203 is for a workaround in Maven

Cheers,
Brett

On 20/10/2008, at 10:13 AM, Brian E. Fox wrote:

> There's already a jira for this since I originally suggested it a  
> long time ago. IIRC John and I looked at it and found some problems  
> with it but I'd have to dig up the jira to remember.
>
> -----Original Message-----
> From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com]
> Sent: Sunday, October 19, 2008 4:51 PM
> To: Maven Developers List
> Subject: Re: compiler plugin: separate test compiler configuration
>
> This could be arranged, but Eugene has a very valid question - Eclipse
> sets all those on the project level and might misbehave as soon as
> somebody starts debugging such a project.
>
> Milos, you can say that's eclipse's problem. But is't a majority of
> users, whether it's good or bad, we need to respect that use case.
>
> So the question remains - should we modify the compiler plugin to  
> allow
> separate configurations for test compiler? Or if such a need comes -
> it's an indication that it's time to move tests into a separate  
> project?
>
> Anyone ?
>
> � wrote:
>> Yes Milos, it was my question.
>>
>> In fact, it's nice to can specify specific configuration for both  
>> source and
>> test.
>>
>> For instance, we want to be able to define the source and target  
>> level but
>> also some other configuration such as compilerArgument and so on
>>
>> R�my
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


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


RE: compiler plugin: separate test compiler configuration

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
There's already a jira for this since I originally suggested it a long time ago. IIRC John and I looked at it and found some problems with it but I'd have to dig up the jira to remember.

-----Original Message-----
From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
Sent: Sunday, October 19, 2008 4:51 PM
To: Maven Developers List
Subject: Re: compiler plugin: separate test compiler configuration

This could be arranged, but Eugene has a very valid question - Eclipse 
sets all those on the project level and might misbehave as soon as 
somebody starts debugging such a project.

Milos, you can say that's eclipse's problem. But is't a majority of 
users, whether it's good or bad, we need to respect that use case.

So the question remains - should we modify the compiler plugin to allow 
separate configurations for test compiler? Or if such a need comes - 
it's an indication that it's time to move tests into a separate project?

Anyone ?

� wrote:
> Yes Milos, it was my question.
>
> In fact, it's nice to can specify specific configuration for both source and
> test.
>
> For instance, we want to be able to define the source and target level but
> also some other configuration such as compilerArgument and so on
>
> R�my
>
>   

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


Re: compiler plugin: separate test compiler configuration

Posted by Michael McCallum <gh...@apache.org>.
eclipse already blends test and compile scopes... if it plays havoc with your 
build just don't use the feature...

On Mon, 20 Oct 2008 20:16:18 Daniel Le Berre wrote:
> Brian E. Fox a écrit :
> >> Milos, you can say that's eclipse's problem. But is't a majority of
> >> users, whether it's good or bad, we need to respect that use case.
> >
> > I think it should be allowed. Just because Eclipse can't do it doesn't
> > mean maven shouldn't. It just means if you want to use eclipse and maven,
> > then you can't use that feature. Maven shouldn't be limited to the least
> > common denominator of all tools out there.
>
> I have the same feeling.
>
> 	Daniel



-- 
Michael McCallum
Enterprise Engineer
mailto:gholam@apache.org

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


Re: compiler plugin: separate test compiler configuration

Posted by Eugene Kuleshov <eu...@md.pp.ru>.

  Oleg, please make a large bold warning in the documentation for those
parameters about issues they could cause in the IDE.

  I still think it is a huge mistake to encourage such features for Maven,
which supposed to support best practices.

  regards,
  Eugene



Oleg Gusakov wrote:
> 
> Changes made on 2.1-SNAPSHOT trunk, binary snapshot published on apache 
> snapshots.
> 
> Added support for:
> * testSource
> * testSource
> * testCompilerArgument
> * testCompilerArguments
> 
> Details, sample config: http://jira.codehaus.org/browse/MCOMPILER-83
> 
-- 
View this message in context: http://www.nabble.com/compiler-plugin%3A-separate-test-compiler-configuration-tp20058021p20082244.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
Changes made on 2.1-SNAPSHOT trunk, binary snapshot published on apache 
snapshots.

Added support for:
* testSource
* testSource
* testCompilerArgument
* testCompilerArguments

Details, sample config: http://jira.codehaus.org/browse/MCOMPILER-83


Brian E. Fox wrote:
> Well yeah, that’s the correct fix but requires maven core changes.
>
> -----Original Message-----
> From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
> Sent: Monday, October 20, 2008 1:18 PM
> To: Maven Developers List
> Subject: Re: compiler plugin: separate test compiler configuration
>
> Or if plugin instance were created per execution invocation. Right now 
> it seems like plugin instance is created and initialized once, and 
> execution is passed the same instance.
>
> The above is speculation, based on the observed effect. I did not check 
> the actual code.
>
> Brian E. Fox wrote:
>   
>> It could work if the plugin took different params for test mode.
>>
>> -----Original Message-----
>> From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
>> Sent: Monday, October 20, 2008 12:38 PM
>> To: Maven Developers List
>> Subject: Re: compiler plugin: separate test compiler configuration
>>
>> Milos - it does not :(
>>
>> Milos Kleint wrote:
>>   
>>     
>>> I'm not sure we did. The execution based config for testCompile
>>> doesn't really work?
>>>
>>> Milos
>>>
>>> On Mon, Oct 20, 2008 at 5:41 PM, Oleg Gusakov
>>> <ol...@gmail.com> wrote:
>>>   
>>>     
>>>       
>>>> Looks like we reached a consensus here, I will add the params.
>>>>
>>>> Thanks everyone for discussion and guidance!
>>>>
>>>> Michael McCallum wrote:
>>>>     
>>>>       
>>>>         
>>>>> eclipse already blends test and compile scopes... if it plays havoc with
>>>>> your build just don't use the feature...
>>>>>
>>>>>       
>>>>>         
>>>>>           
>>>> Brian E. Fox wrote:
>>>>     
>>>>       
>>>>         
>>>>>> Milos, you can say that's eclipse's problem. But is't a majority of
>>>>>> users, whether it's good or bad, we need to respect that use case.
>>>>>>
>>>>>>         
>>>>>>           
>>>>>>             
>>>>> I think it should be allowed. Just because Eclipse can't do it doesn't
>>>>> mean maven shouldn't. It just means if you want to use eclipse and maven,
>>>>> then you can't use that feature. Maven shouldn't be limited to the least
>>>>> common denominator of all tools out there.
>>>>>
>>>>>       
>>>>>         
>>>>>           
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>>
>>>   
>>>     
>>>       
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>   

RE: compiler plugin: separate test compiler configuration

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Well yeah, that’s the correct fix but requires maven core changes.

-----Original Message-----
From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
Sent: Monday, October 20, 2008 1:18 PM
To: Maven Developers List
Subject: Re: compiler plugin: separate test compiler configuration

Or if plugin instance were created per execution invocation. Right now 
it seems like plugin instance is created and initialized once, and 
execution is passed the same instance.

The above is speculation, based on the observed effect. I did not check 
the actual code.

Brian E. Fox wrote:
> It could work if the plugin took different params for test mode.
>
> -----Original Message-----
> From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
> Sent: Monday, October 20, 2008 12:38 PM
> To: Maven Developers List
> Subject: Re: compiler plugin: separate test compiler configuration
>
> Milos - it does not :(
>
> Milos Kleint wrote:
>   
>> I'm not sure we did. The execution based config for testCompile
>> doesn't really work?
>>
>> Milos
>>
>> On Mon, Oct 20, 2008 at 5:41 PM, Oleg Gusakov
>> <ol...@gmail.com> wrote:
>>   
>>     
>>> Looks like we reached a consensus here, I will add the params.
>>>
>>> Thanks everyone for discussion and guidance!
>>>
>>> Michael McCallum wrote:
>>>     
>>>       
>>>> eclipse already blends test and compile scopes... if it plays havoc with
>>>> your build just don't use the feature...
>>>>
>>>>       
>>>>         
>>> Brian E. Fox wrote:
>>>     
>>>       
>>>>> Milos, you can say that's eclipse's problem. But is't a majority of
>>>>> users, whether it's good or bad, we need to respect that use case.
>>>>>
>>>>>         
>>>>>           
>>>> I think it should be allowed. Just because Eclipse can't do it doesn't
>>>> mean maven shouldn't. It just means if you want to use eclipse and maven,
>>>> then you can't use that feature. Maven shouldn't be limited to the least
>>>> common denominator of all tools out there.
>>>>
>>>>       
>>>>         
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>>   
>>     

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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
Or if plugin instance were created per execution invocation. Right now 
it seems like plugin instance is created and initialized once, and 
execution is passed the same instance.

The above is speculation, based on the observed effect. I did not check 
the actual code.

Brian E. Fox wrote:
> It could work if the plugin took different params for test mode.
>
> -----Original Message-----
> From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
> Sent: Monday, October 20, 2008 12:38 PM
> To: Maven Developers List
> Subject: Re: compiler plugin: separate test compiler configuration
>
> Milos - it does not :(
>
> Milos Kleint wrote:
>   
>> I'm not sure we did. The execution based config for testCompile
>> doesn't really work?
>>
>> Milos
>>
>> On Mon, Oct 20, 2008 at 5:41 PM, Oleg Gusakov
>> <ol...@gmail.com> wrote:
>>   
>>     
>>> Looks like we reached a consensus here, I will add the params.
>>>
>>> Thanks everyone for discussion and guidance!
>>>
>>> Michael McCallum wrote:
>>>     
>>>       
>>>> eclipse already blends test and compile scopes... if it plays havoc with
>>>> your build just don't use the feature...
>>>>
>>>>       
>>>>         
>>> Brian E. Fox wrote:
>>>     
>>>       
>>>>> Milos, you can say that's eclipse's problem. But is't a majority of
>>>>> users, whether it's good or bad, we need to respect that use case.
>>>>>
>>>>>         
>>>>>           
>>>> I think it should be allowed. Just because Eclipse can't do it doesn't
>>>> mean maven shouldn't. It just means if you want to use eclipse and maven,
>>>> then you can't use that feature. Maven shouldn't be limited to the least
>>>> common denominator of all tools out there.
>>>>
>>>>       
>>>>         
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>>   
>>     

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


RE: compiler plugin: separate test compiler configuration

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
It could work if the plugin took different params for test mode.

-----Original Message-----
From: Oleg Gusakov [mailto:oleg.subscriptions@gmail.com] 
Sent: Monday, October 20, 2008 12:38 PM
To: Maven Developers List
Subject: Re: compiler plugin: separate test compiler configuration

Milos - it does not :(

Milos Kleint wrote:
> I'm not sure we did. The execution based config for testCompile
> doesn't really work?
>
> Milos
>
> On Mon, Oct 20, 2008 at 5:41 PM, Oleg Gusakov
> <ol...@gmail.com> wrote:
>   
>> Looks like we reached a consensus here, I will add the params.
>>
>> Thanks everyone for discussion and guidance!
>>
>> Michael McCallum wrote:
>>     
>>> eclipse already blends test and compile scopes... if it plays havoc with
>>> your build just don't use the feature...
>>>
>>>       
>> Brian E. Fox wrote:
>>     
>>>> Milos, you can say that's eclipse's problem. But is't a majority of
>>>> users, whether it's good or bad, we need to respect that use case.
>>>>
>>>>         
>>> I think it should be allowed. Just because Eclipse can't do it doesn't
>>> mean maven shouldn't. It just means if you want to use eclipse and maven,
>>> then you can't use that feature. Maven shouldn't be limited to the least
>>> common denominator of all tools out there.
>>>
>>>       
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
>   

Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
Milos - it does not :(

Milos Kleint wrote:
> I'm not sure we did. The execution based config for testCompile
> doesn't really work?
>
> Milos
>
> On Mon, Oct 20, 2008 at 5:41 PM, Oleg Gusakov
> <ol...@gmail.com> wrote:
>   
>> Looks like we reached a consensus here, I will add the params.
>>
>> Thanks everyone for discussion and guidance!
>>
>> Michael McCallum wrote:
>>     
>>> eclipse already blends test and compile scopes... if it plays havoc with
>>> your build just don't use the feature...
>>>
>>>       
>> Brian E. Fox wrote:
>>     
>>>> Milos, you can say that's eclipse's problem. But is't a majority of
>>>> users, whether it's good or bad, we need to respect that use case.
>>>>
>>>>         
>>> I think it should be allowed. Just because Eclipse can't do it doesn't
>>> mean maven shouldn't. It just means if you want to use eclipse and maven,
>>> then you can't use that feature. Maven shouldn't be limited to the least
>>> common denominator of all tools out there.
>>>
>>>       
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
>   

Re: compiler plugin: separate test compiler configuration

Posted by Milos Kleint <mk...@gmail.com>.
I'm not sure we did. The execution based config for testCompile
doesn't really work?

Milos

On Mon, Oct 20, 2008 at 5:41 PM, Oleg Gusakov
<ol...@gmail.com> wrote:
> Looks like we reached a consensus here, I will add the params.
>
> Thanks everyone for discussion and guidance!
>
> Michael McCallum wrote:
>>
>> eclipse already blends test and compile scopes... if it plays havoc with
>> your build just don't use the feature...
>>
>
> Brian E. Fox wrote:
>>>
>>> Milos, you can say that's eclipse's problem. But is't a majority of
>>> users, whether it's good or bad, we need to respect that use case.
>>>
>>
>> I think it should be allowed. Just because Eclipse can't do it doesn't
>> mean maven shouldn't. It just means if you want to use eclipse and maven,
>> then you can't use that feature. Maven shouldn't be limited to the least
>> common denominator of all tools out there.
>>
>

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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
I made the easiest and straightforward change, fully backward compatible.

I will look at toolchains later on, when I make more serious changes.

Thanks,
Oleg

Brett Porter wrote:
> What about considering toolchains?
>
> - Brett
>
> On 21/10/2008, at 2:41 AM, Oleg Gusakov wrote:
>
>> Looks like we reached a consensus here, I will add the params.
>>
>> Thanks everyone for discussion and guidance!
>>
>> Michael McCallum wrote:
>>> eclipse already blends test and compile scopes... if it plays havoc 
>>> with your build just don't use the feature...
>>>
>> Brian E. Fox wrote:
>>>> Milos, you can say that's eclipse's problem. But is't a majority of 
>>>> users, whether it's good or bad, we need to respect that use case.
>>>>
>>>
>>> I think it should be allowed. Just because Eclipse can't do it 
>>> doesn't mean maven shouldn't. It just means if you want to use 
>>> eclipse and maven, then you can't use that feature. Maven shouldn't 
>>> be limited to the least common denominator of all tools out there.
>>>
>
> -- 
> Brett Porter
> brett@apache.org
> http://blogs.exist.com/bporter/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: compiler plugin: separate test compiler configuration

Posted by Brett Porter <br...@apache.org>.
What about considering toolchains?

- Brett

On 21/10/2008, at 2:41 AM, Oleg Gusakov wrote:

> Looks like we reached a consensus here, I will add the params.
>
> Thanks everyone for discussion and guidance!
>
> Michael McCallum wrote:
>> eclipse already blends test and compile scopes... if it plays havoc  
>> with your build just don't use the feature...
>>
> Brian E. Fox wrote:
>>> Milos, you can say that's eclipse's problem. But is't a majority  
>>> of users, whether it's good or bad, we need to respect that use  
>>> case.
>>>
>>
>> I think it should be allowed. Just because Eclipse can't do it  
>> doesn't mean maven shouldn't. It just means if you want to use  
>> eclipse and maven, then you can't use that feature. Maven shouldn't  
>> be limited to the least common denominator of all tools out there.
>>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
Looks like we reached a consensus here, I will add the params.

Thanks everyone for discussion and guidance!

Michael McCallum wrote:
> eclipse already blends test and compile scopes... if it plays havoc with your 
> build just don't use the feature...
>   
Brian E. Fox wrote:
>> Milos, you can say that's eclipse's problem. But is't a majority of 
>> users, whether it's good or bad, we need to respect that use case.
>>     
>
> I think it should be allowed. Just because Eclipse can't do it doesn't mean maven shouldn't. It just means if you want to use eclipse and maven, then you can't use that feature. Maven shouldn't be limited to the least common denominator of all tools out there.
>   

Re: compiler plugin: separate test compiler configuration

Posted by Daniel Le Berre <le...@cril.univ-artois.fr>.
Brian E. Fox a écrit :
>> Milos, you can say that's eclipse's problem. But is't a majority of 
>> users, whether it's good or bad, we need to respect that use case.
> 
> I think it should be allowed. Just because Eclipse can't do it doesn't mean maven shouldn't. It just means if you want to use eclipse and maven, then you can't use that feature. Maven shouldn't be limited to the least common denominator of all tools out there.
> 

I have the same feeling.

	Daniel
-- 
              Daniel Le Berre mailto:leberre@cril.univ-artois.fr
              MCF,    CRIL-CNRS UMR 8188,    Universite d'Artois
              http://www.cril.univ-artois.fr/~leberre

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


RE: compiler plugin: separate test compiler configuration

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
>Milos, you can say that's eclipse's problem. But is't a majority of 
>users, whether it's good or bad, we need to respect that use case.

I think it should be allowed. Just because Eclipse can't do it doesn't mean maven shouldn't. It just means if you want to use eclipse and maven, then you can't use that feature. Maven shouldn't be limited to the least common denominator of all tools out there.

Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
As Daniel is in a different time zone, I take the frivolity to elaborate 
these.

His project - SAT4J - is the engine behind both P2 and Maven Mercury 
dependency conflict resolution, and as such must adhere to Eclipse 
platform requirements.

Hope this explains the motivation.

Eugene Kuleshov wrote:
> Daniel Le Berre wrote:
>   
>> I develop a library that needs to run on a 1.4 JVM (Eclipse requirements).
>>
>>     
>
> Can you please elaborate on this? As far as I know Eclipse runs perfectly on
> 1.5 and despite Eclipse Platform being compatible with 1.4, more and more
> Eclipse projects actually require 1.5 to run. For instance, Ganymede
> (Eclipse 3.4) bundles for Java and J2EE developers require Java 5 to run.
> First due to Mylyn and second - due to WTP.
>
> Besides, nothing actually stops you from using jsr14 target in Eclipse. More
> over m2eclipse will configure that for you and most likely your junit4 tests
> would work too.
>
>   regards,
>   Eugene
>
>   

Re: compiler plugin: separate test compiler configuration

Posted by Eugene Kuleshov <eu...@md.pp.ru>.

Daniel Le Berre wrote:
> 
> I develop a library that needs to run on a 1.4 JVM (Eclipse requirements).
> 

Can you please elaborate on this? As far as I know Eclipse runs perfectly on
1.5 and despite Eclipse Platform being compatible with 1.4, more and more
Eclipse projects actually require 1.5 to run. For instance, Ganymede
(Eclipse 3.4) bundles for Java and J2EE developers require Java 5 to run.
First due to Mylyn and second - due to WTP.

Besides, nothing actually stops you from using jsr14 target in Eclipse. More
over m2eclipse will configure that for you and most likely your junit4 tests
would work too.

  regards,
  Eugene

-- 
View this message in context: http://www.nabble.com/compiler-plugin%3A-separate-test-compiler-configuration-tp20058021p20061248.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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


Re: compiler plugin: separate test compiler configuration

Posted by Daniel Le Berre <le...@cril.univ-artois.fr>.
Dear all,

I am the one that asked for such feature :) Let me explain why.

I develop a library that needs to run on a 1.4 JVM (Eclipse requirements).

Since I like Java 5+ features, the code is written in 1.5 type and I use
the compiler jsr14 target to produce 1.4 bytecode.

The project being a few years old, my initial unit tests were in JUnit
3.8 style, so no problem.

Since JUnit4 style unit tests are available, I do prefer to write my
tests the JUnit 4 way. So I have a mix of JUnit3 and JUnit4 tests.

Because I currently compile the JUnit4 tests with the jsr14 target, I
loose all the JUnit4 annotations needed for JUnit4 tests, so those test
currently fail within Maven test cycle.

I use Eclipse to develop. Indeed, I do not have separate compiler
options under Eclipse: I use Java 1.5 settings and I can run both JUnit3
and JUnit4 tests without problem.
The jsr14 target is only used during integration. And it is important
for me to run all my tests then.

I guess that I am not the only one in that situation (i.e. production
code with some requirements and tests with other requirements).

Cheers,

    Daniel

Oleg Gusakov a écrit :
>
> This could be arranged, but Eugene has a very valid question - Eclipse
> sets all those on the project level and might misbehave as soon as
> somebody starts debugging such a project.
>
> Milos, you can say that's eclipse's problem. But is't a majority of
> users, whether it's good or bad, we need to respect that use case.
>
> So the question remains - should we modify the compiler plugin to
> allow separate configurations for test compiler? Or if such a need
> comes - it's an indication that it's time to move tests into a
> separate project?
>
> Anyone ?
>
> � wrote:
>> Yes Milos, it was my question.
>>
>> In fact, it's nice to can specify specific configuration for both
>> source and
>> test.
>>
>> For instance, we want to be able to define the source and target
>> level but
>> also some other configuration such as compilerArgument and so on
>>
>> R�my
>>
>>   
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
>


-- 
             Daniel Le Berre mailto:leberre@cril.univ-artois.fr
             MCF,    CRIL-CNRS UMR 8188,    Universite d'Artois
             http://www.cril.univ-artois.fr/~leberre


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


Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
This could be arranged, but Eugene has a very valid question - Eclipse 
sets all those on the project level and might misbehave as soon as 
somebody starts debugging such a project.

Milos, you can say that's eclipse's problem. But is't a majority of 
users, whether it's good or bad, we need to respect that use case.

So the question remains - should we modify the compiler plugin to allow 
separate configurations for test compiler? Or if such a need comes - 
it's an indication that it's time to move tests into a separate project?

Anyone ?

� wrote:
> Yes Milos, it was my question.
>
> In fact, it's nice to can specify specific configuration for both source and
> test.
>
> For instance, we want to be able to define the source and target level but
> also some other configuration such as compilerArgument and so on
>
> R�my
>
>   

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


Re: compiler plugin: separate test compiler configuration

Posted by Rémy Sanlaville <re...@gmail.com>.
Yes Milos, it was my question.

In fact, it's nice to can specify specific configuration for both source and
test.

For instance, we want to be able to define the source and target level but
also some other configuration such as compilerArgument and so on

Rémy

Re: compiler plugin: separate test compiler configuration

Posted by Milos Kleint <mk...@gmail.com>.
well, I suppose the question was if configuring just the testCompile
execution doesn't work.
I suppose having a general config at sourcelevel 1.4 and then specific
one for testCompile execution shall work.

...maven-compiler-plugin...

<executions>
  <execution>
      <id>xxx</id>
      <goals>
             <goal>testCompile</goal>
      </goals>
     <configuration>
              1.5
     </configuration>
   <execution>
....
<configuration>
    1.4
</configuration>


Milos

On Sun, Oct 19, 2008 at 10:03 PM, Oleg Gusakov
<ol...@gmail.com> wrote:
> This exactly the proposal - use test-specific settings to enable
> source/target, different from compile mojo. So that if nothing is configured
> - it's all the same, if testSource/testTarget is set - use them for
> testCompile only.
>
> � wrote:
>>
>> Hi,
>>
>> We are also interesting for a such feature.
>> I just wonder if it is not possible to use the testCompile goal for that ?
>>
>> Thanks,
>>
>> R�my
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: compiler plugin: separate test compiler configuration

Posted by Oleg Gusakov <ol...@gmail.com>.
This exactly the proposal - use test-specific settings to enable 
source/target, different from compile mojo. So that if nothing is 
configured - it's all the same, if testSource/testTarget is set - use 
them for testCompile only.

� wrote:
> Hi,
>
> We are also interesting for a such feature.
> I just wonder if it is not possible to use the testCompile goal for that ?
>
> Thanks,
>
> R�my
>
>   

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


Re: compiler plugin: separate test compiler configuration

Posted by Rémy Sanlaville <re...@gmail.com>.
Hi,

We are also interesting for a such feature.
I just wonder if it is not possible to use the testCompile goal for that ?

Thanks,

Rémy

Re: compiler plugin: separate test compiler configuration

Posted by Brett Porter <br...@apache.org>.
I think the use case is valid - I have seen it a number of times  
before. At runtime they are already separate (you can run surefire  
with whatever JVM you want, regardless of what you target for  
compilation).

The other parameter that needs to be changed is the ability to fork  
your own javac, which I think is related to what you mentioned.

However, instead of overloading all the parameters - I think this is  
the time to push toolchains forward. So a user could choose a tests  
toolchain that would pick up the values from there, and if it isn't  
specified it falls back to the values from the main compiler plugin  
that it is using now.

Does that make sense?

Cheers,
Brett

On 20/10/2008, at 3:52 AM, Oleg Gusakov wrote:

> One of the users requested a separate source/target configuration  
> for test compiler for the reason of running junit4 tests and yet  
> being java 1.4 in the main classes.
>
> It's a trivial change in the compiler plugin, but I decided to ask  
> here before changing it.
>
> The proposed change - add two configuration parameters:
>
>     <plugin>
>       <artifactId>maven-compiler-plugin</artifactId>
>       <configuration>
>         <testSource>1.5</testSource>
>         <testTarget>1.5</testTarget>
>       </configuration>
>     </plugin>
>
>
> Please let me know if it breaks anything. Please also indicate if  
> you need more separation (like memory, etc)?
>
> Thanks,
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


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


Re: compiler plugin: separate test compiler configuration

Posted by Milos Kleint <mk...@gmail.com>.
just FYI, it should work fine in NetBeans. (after adding code to
recognize the new parameters)
But I'm not sure if the setting itself is enough to be truly useful.
Since the sourcelevel is to be set to 1.5+ jdk javac only (as the 1.4
javac would spill on the 1.5 source level value), the maven build
needs to be run with jdk 1.5. That in turn allows some 1.5 features to
leak into the 1.4 based source root. But I guess that's not only the
case for the new parameter but to the existing one as well..

Milos

On Sun, Oct 19, 2008 at 8:06 PM, Eugene Kuleshov <eu...@md.pp.ru> wrote:
>
>
>  This won't work very well in the IDEs. For example, Eclipse does not allow
> to specify different compiler settings per-source folder (i.e. main code vs.
> tests). So, I would advise against encouraging such feature. Besides users
> can still use older junit versions that work on 1.4, or they could move
> tests into a separate project.
>
>  regards,
>  Eugene
>
>
>
> Oleg Gusakov wrote:
>>
>> One of the users requested a separate source/target configuration for
>> test compiler for the reason of running junit4 tests and yet being java
>> 1.4 in the main classes.
>>
>> It's a trivial change in the compiler plugin, but I decided to ask here
>> before changing it.
>>
>> The proposed change - add two configuration parameters:
>>
>>       <plugin>
>>         <artifactId>maven-compiler-plugin</artifactId>
>>         <configuration>
>>           <testSource>1.5</testSource>
>>           <testTarget>1.5</testTarget>
>>         </configuration>
>>       </plugin>
>>
>> Please let me know if it breaks anything. Please also indicate if you
>> need more separation (like memory, etc)?
>>
>
> --
> View this message in context: http://www.nabble.com/compiler-plugin%3A-separate-test-compiler-configuration-tp20058021p20058447.html
> Sent from the Maven Developers mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: compiler plugin: separate test compiler configuration

Posted by Eugene Kuleshov <eu...@md.pp.ru>.

  This won't work very well in the IDEs. For example, Eclipse does not allow
to specify different compiler settings per-source folder (i.e. main code vs.
tests). So, I would advise against encouraging such feature. Besides users
can still use older junit versions that work on 1.4, or they could move
tests into a separate project.

  regards,
  Eugene



Oleg Gusakov wrote:
> 
> One of the users requested a separate source/target configuration for 
> test compiler for the reason of running junit4 tests and yet being java 
> 1.4 in the main classes.
> 
> It's a trivial change in the compiler plugin, but I decided to ask here 
> before changing it.
> 
> The proposed change - add two configuration parameters:
> 
>       <plugin>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <testSource>1.5</testSource>
>           <testTarget>1.5</testTarget>
>         </configuration>
>       </plugin>
> 
> Please let me know if it breaks anything. Please also indicate if you 
> need more separation (like memory, etc)?
> 

-- 
View this message in context: http://www.nabble.com/compiler-plugin%3A-separate-test-compiler-configuration-tp20058021p20058447.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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