You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by anarkhos <an...@gmail.com> on 2006/09/04 11:02:04 UTC

product codes at java 1.4, test sources at java 1.5

hi,
i would like to use java 1.5 in my test classes but i have a constraint to
use java 1.4 in my product code. how can i tell maven to compile and execute
tests in 1.5 level, while compiling and testing product code in java 1.4 ?
thanks in advance,
cheers
-- 
View this message in context: http://www.nabble.com/product-codes-at-java-1.4%2C-test-sources-at-java-1.5-tf2213975.html#a6132083
Sent from the Maven - Users forum at Nabble.com.


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


Re: product codes at java 1.4, test sources at java 1.5

Posted by anarkhos <an...@gmail.com>.
opss, false alarm :( it compiles but into class version 49 (which is
incompatible with jre1.4)

i have modified pom.xml accroding to your recommendations as follows: 

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
                <executions>
                    <execution>
                        <id>default</id>
                        <phase>compile</phase>
                        <configuration>
                            <source>1.4</source>
                            <target>1.4</target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

but it seems that the classes are compiled with 1.5, not caring about the
execution definition. why on the earth that execution is ignored?? any help
will be greatly appreciated

cheers 


anarkhos wrote:
> 
> thanks a lot nicolas, that worked :)
> but i wonder why i can not address test-compile phase?
> 
> 
> Nicolas De Loof wrote:
>> 
>> 
>> Use a top level configuration based on Java5, and define an <execution> 
>> with ID "default" for the compile phase, based on Java 1.4.
>> 
>> You should use the bootclasspath to avoid your compiled code to make 
>> reference to Java5 methods that does not exist in Java 1.4. This is a 
>> common bug using StringBuffers in Java 1.3/1.4. I don't yet know such 
>> error in Java5
>> 
>> 
>> anarkhos a écrit :
>>> thanks indeed for the answers, but i think i couldn't make my intent
>>> clear;
>>>
>>> the first proposed solution doesn't help,  because my unit tests are
>>> written
>>> in java1.5 syntax, so 1.3 tools can not compile them
>>> the second proposed solution doesn't help neither because I'll be
>>> needing
>>> both 1.4 and 1.5 level of compilation because compile phase must output
>>> in
>>> class version .48 and testCompile must output in class version .50 and
>>> run
>>> in a jre1.5+ . as far as I know, profiles are active throught the whole
>>> build process.
>>>
>>> after a little search on executions, i figured out if I can give
>>> different
>>> configuration parameters to compiler plugin for compile phase and
>>> test-compile phases, i'll manage to obtain a 1.4 compatible package that
>>> is
>>> tested with 1.5 dependent unit tests. thinking this solution, i have
>>> changed
>>> maven compiler plugin configuration in my pom.xml as follows:
>>>
>>>                 <plugin>
>>>                     <groupId>org.apache.maven.plugins</groupId>
>>>                     <artifactId>maven-compiler-plugin</artifactId>
>>>                     <version>2.0.1</version>
>>>                     <executions>
>>>                         <execution>
>>>                             <id>productClasses</id>
>>>                             <goals>
>>>                                 <goal>compile</goal>
>>>                             </goals>
>>>                             <phase>compile</phase>
>>>                             <configuration>
>>>                                 <source>1.4</source>
>>>                                 <target>1.4</target>
>>>                             </configuration>
>>>                         </execution>
>>>                         <execution>
>>>                             <id>testClasses</id>
>>>                             <goals>
>>>                                 <goal>testCompile</goal>
>>>                             </goals>
>>>                             <phase>test-compile</phase>
>>>                             <configuration>
>>>                                 <source>1.5</source>
>>>                                 <target>1.5</target>
>>>                             </configuration>
>>>                         </execution>
>>>                     </executions>
>>>                 </plugin>
>>>
>>> but this doesn't help me to instruct maven compiler plugin to use 1.5
>>> for
>>> compiling tests. any idea how to configure those compile and testCompile
>>> goals differently will be of great use for me.
>>>
>>> cheers ..
>>>
>>>
>>> Allan Ramirez wrote:
>>>   
>>>> See profiles 
>>>> http://maven.apache.org/guides/introduction/introduction-to-profiles.html
>>>>
>>>> -allan
>>>>
>>>> anarkhos wrote:
>>>>     
>>>>> hi,
>>>>> i would like to use java 1.5 in my test classes but i have a
>>>>> constraint
>>>>> to
>>>>> use java 1.4 in my product code. how can i tell maven to compile and
>>>>> execute
>>>>> tests in 1.5 level, while compiling and testing product code in java
>>>>> 1.4
>>>>> ?
>>>>> thanks in advance,
>>>>> cheers
>>>>>   
>>>>>       
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>
>>>   
>> 
>> This message contains information that may be privileged or confidential
>> and is the property of the Capgemini Group. It is intended only for the
>> person to whom it is addressed. If you are not the intended recipient, 
>> you are not authorized to read, print, retain, copy, disseminate, 
>> distribute, or use this message or any part thereof. If you receive this 
>> message in error, please notify the sender immediately and delete all 
>> copies of this message.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/product-codes-at-java-1.4%2C-test-sources-at-java-1.5-tf2213975.html#a6135343
Sent from the Maven - Users forum at Nabble.com.


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


Re: product codes at java 1.4, test sources at java 1.5

Posted by anarkhos <an...@gmail.com>.
thanks a lot nicolas, that worked :)
but i wonder why i can not address test-compile phase?


Nicolas De Loof wrote:
> 
> 
> Use a top level configuration based on Java5, and define an <execution> 
> with ID "default" for the compile phase, based on Java 1.4.
> 
> You should use the bootclasspath to avoid your compiled code to make 
> reference to Java5 methods that does not exist in Java 1.4. This is a 
> common bug using StringBuffers in Java 1.3/1.4. I don't yet know such 
> error in Java5
> 
> 
> anarkhos a écrit :
>> thanks indeed for the answers, but i think i couldn't make my intent
>> clear;
>>
>> the first proposed solution doesn't help,  because my unit tests are
>> written
>> in java1.5 syntax, so 1.3 tools can not compile them
>> the second proposed solution doesn't help neither because I'll be needing
>> both 1.4 and 1.5 level of compilation because compile phase must output
>> in
>> class version .48 and testCompile must output in class version .50 and
>> run
>> in a jre1.5+ . as far as I know, profiles are active throught the whole
>> build process.
>>
>> after a little search on executions, i figured out if I can give
>> different
>> configuration parameters to compiler plugin for compile phase and
>> test-compile phases, i'll manage to obtain a 1.4 compatible package that
>> is
>> tested with 1.5 dependent unit tests. thinking this solution, i have
>> changed
>> maven compiler plugin configuration in my pom.xml as follows:
>>
>>                 <plugin>
>>                     <groupId>org.apache.maven.plugins</groupId>
>>                     <artifactId>maven-compiler-plugin</artifactId>
>>                     <version>2.0.1</version>
>>                     <executions>
>>                         <execution>
>>                             <id>productClasses</id>
>>                             <goals>
>>                                 <goal>compile</goal>
>>                             </goals>
>>                             <phase>compile</phase>
>>                             <configuration>
>>                                 <source>1.4</source>
>>                                 <target>1.4</target>
>>                             </configuration>
>>                         </execution>
>>                         <execution>
>>                             <id>testClasses</id>
>>                             <goals>
>>                                 <goal>testCompile</goal>
>>                             </goals>
>>                             <phase>test-compile</phase>
>>                             <configuration>
>>                                 <source>1.5</source>
>>                                 <target>1.5</target>
>>                             </configuration>
>>                         </execution>
>>                     </executions>
>>                 </plugin>
>>
>> but this doesn't help me to instruct maven compiler plugin to use 1.5 for
>> compiling tests. any idea how to configure those compile and testCompile
>> goals differently will be of great use for me.
>>
>> cheers ..
>>
>>
>> Allan Ramirez wrote:
>>   
>>> See profiles 
>>> http://maven.apache.org/guides/introduction/introduction-to-profiles.html
>>>
>>> -allan
>>>
>>> anarkhos wrote:
>>>     
>>>> hi,
>>>> i would like to use java 1.5 in my test classes but i have a constraint
>>>> to
>>>> use java 1.4 in my product code. how can i tell maven to compile and
>>>> execute
>>>> tests in 1.5 level, while compiling and testing product code in java
>>>> 1.4
>>>> ?
>>>> thanks in advance,
>>>> cheers
>>>>   
>>>>       
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>>     
>>
>>   
> 
> This message contains information that may be privileged or confidential
> and is the property of the Capgemini Group. It is intended only for the
> person to whom it is addressed. If you are not the intended recipient, 
> you are not authorized to read, print, retain, copy, disseminate, 
> distribute, or use this message or any part thereof. If you receive this 
> message in error, please notify the sender immediately and delete all 
> copies of this message.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/product-codes-at-java-1.4%2C-test-sources-at-java-1.5-tf2213975.html#a6134821
Sent from the Maven - Users forum at Nabble.com.


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


Re: product codes at java 1.4, test sources at java 1.5

Posted by Nicolas De Loof <ni...@capgemini.com>.
Use a top level configuration based on Java5, and define an <execution> 
with ID "default" for the compile phase, based on Java 1.4.

You should use the bootclasspath to avoid your compiled code to make 
reference to Java5 methods that does not exist in Java 1.4. This is a 
common bug using StringBuffers in Java 1.3/1.4. I don't yet know such 
error in Java5


anarkhos a écrit :
> thanks indeed for the answers, but i think i couldn't make my intent clear;
>
> the first proposed solution doesn't help,  because my unit tests are written
> in java1.5 syntax, so 1.3 tools can not compile them
> the second proposed solution doesn't help neither because I'll be needing
> both 1.4 and 1.5 level of compilation because compile phase must output in
> class version .48 and testCompile must output in class version .50 and run
> in a jre1.5+ . as far as I know, profiles are active throught the whole
> build process.
>
> after a little search on executions, i figured out if I can give different
> configuration parameters to compiler plugin for compile phase and
> test-compile phases, i'll manage to obtain a 1.4 compatible package that is
> tested with 1.5 dependent unit tests. thinking this solution, i have changed
> maven compiler plugin configuration in my pom.xml as follows:
>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-compiler-plugin</artifactId>
>                     <version>2.0.1</version>
>                     <executions>
>                         <execution>
>                             <id>productClasses</id>
>                             <goals>
>                                 <goal>compile</goal>
>                             </goals>
>                             <phase>compile</phase>
>                             <configuration>
>                                 <source>1.4</source>
>                                 <target>1.4</target>
>                             </configuration>
>                         </execution>
>                         <execution>
>                             <id>testClasses</id>
>                             <goals>
>                                 <goal>testCompile</goal>
>                             </goals>
>                             <phase>test-compile</phase>
>                             <configuration>
>                                 <source>1.5</source>
>                                 <target>1.5</target>
>                             </configuration>
>                         </execution>
>                     </executions>
>                 </plugin>
>
> but this doesn't help me to instruct maven compiler plugin to use 1.5 for
> compiling tests. any idea how to configure those compile and testCompile
> goals differently will be of great use for me.
>
> cheers ..
>
>
> Allan Ramirez wrote:
>   
>> See profiles 
>> http://maven.apache.org/guides/introduction/introduction-to-profiles.html
>>
>> -allan
>>
>> anarkhos wrote:
>>     
>>> hi,
>>> i would like to use java 1.5 in my test classes but i have a constraint
>>> to
>>> use java 1.4 in my product code. how can i tell maven to compile and
>>> execute
>>> tests in 1.5 level, while compiling and testing product code in java 1.4
>>> ?
>>> thanks in advance,
>>> cheers
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>>     
>
>   

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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


Re: product codes at java 1.4, test sources at java 1.5

Posted by anarkhos <an...@gmail.com>.
thanks indeed for the answers, but i think i couldn't make my intent clear;

the first proposed solution doesn't help,  because my unit tests are written
in java1.5 syntax, so 1.3 tools can not compile them
the second proposed solution doesn't help neither because I'll be needing
both 1.4 and 1.5 level of compilation because compile phase must output in
class version .48 and testCompile must output in class version .50 and run
in a jre1.5+ . as far as I know, profiles are active throught the whole
build process.

after a little search on executions, i figured out if I can give different
configuration parameters to compiler plugin for compile phase and
test-compile phases, i'll manage to obtain a 1.4 compatible package that is
tested with 1.5 dependent unit tests. thinking this solution, i have changed
maven compiler plugin configuration in my pom.xml as follows:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.1</version>
                    <executions>
                        <execution>
                            <id>productClasses</id>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <phase>compile</phase>
                            <configuration>
                                <source>1.4</source>
                                <target>1.4</target>
                            </configuration>
                        </execution>
                        <execution>
                            <id>testClasses</id>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                            <phase>test-compile</phase>
                            <configuration>
                                <source>1.5</source>
                                <target>1.5</target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

but this doesn't help me to instruct maven compiler plugin to use 1.5 for
compiling tests. any idea how to configure those compile and testCompile
goals differently will be of great use for me.

cheers ..


Allan Ramirez wrote:
> 
> See profiles 
> http://maven.apache.org/guides/introduction/introduction-to-profiles.html
> 
> -allan
> 
> anarkhos wrote:
>> hi,
>> i would like to use java 1.5 in my test classes but i have a constraint
>> to
>> use java 1.4 in my product code. how can i tell maven to compile and
>> execute
>> tests in 1.5 level, while compiling and testing product code in java 1.4
>> ?
>> thanks in advance,
>> cheers
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/product-codes-at-java-1.4%2C-test-sources-at-java-1.5-tf2213975.html#a6133902
Sent from the Maven - Users forum at Nabble.com.


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


Re: product codes at java 1.4, test sources at java 1.5

Posted by Allan Ramirez <ar...@exist.com>.
See profiles 
http://maven.apache.org/guides/introduction/introduction-to-profiles.html

-allan

anarkhos wrote:
> hi,
> i would like to use java 1.5 in my test classes but i have a constraint to
> use java 1.4 in my product code. how can i tell maven to compile and execute
> tests in 1.5 level, while compiling and testing product code in java 1.4 ?
> thanks in advance,
> cheers
>   

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


Re: product codes at java 1.4, test sources at java 1.5

Posted by Nicolas De Loof <ni...@capgemini.com>.
I'm using Java5 to run maven and other tools and I'm using the 
bootclasspath to force compiler to use java1.3 jre Runtime for compilation :

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.3</source>
                <target>1.3</target>
                <compilerArguments>
                  
<bootclasspath>${settings.localRepository}/com/sun/rt/1.3.1_08/rt-1.3.1_08.jar</bootclasspath>
                </compilerArguments>
            </configuration>
            <dependencies>
               <dependency>
                  <groupId>com.sun</groupId>
                  <artifactId>rt</artifactId>
                  <version>1.3.1_08</version>
               </dependency>
            </dependencies>
          </plugin>  

Nico.

anarkhos a écrit :
> hi,
> i would like to use java 1.5 in my test classes but i have a constraint to
> use java 1.4 in my product code. how can i tell maven to compile and execute
> tests in 1.5 level, while compiling and testing product code in java 1.4 ?
> thanks in advance,
> cheers
>   

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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