You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by intel radoux <in...@gmail.com> on 2015/04/22 20:42:42 UTC

maven compiler plugin + toolchains

Hello,

I wish to set something like this in my parent pom :

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <toolchains>
                        <jdk>

<version>${project.build.pluginsAsMap(org.apache.maven.plugins:maven-compiler-plugin).configuration.children[0].value}</version>

                        </jdk>
                    </toolchains>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

so that I can only set the source level in one place. The idea is that I
can set another level in one child module and toolchain will select the
correct JDK.
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

unfortunatly this don't work has ${project.build....... } is not resolved
when set in configuration element.
Do somebody have another idea on how to set this ? (why toolchain doesn't
work hand on hand with compiler plugins ? )

Thank you

Re: maven compiler plugin + toolchains

Posted by Jörg Schaible <jo...@gmx.de>.
intel radoux wrote:

> Hello,
> 
> Yes, I could use "maven.compiler.source"  properties, but i'm on a parent
> pom, and if somebody add a configuration like
> 
> <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <version>3.3</version>
>                 <configuration>
>                     <source>xxx</source>
>                     <target>xxx</target>
>                 </configuration>
>             </plugin>
> 
> on his module it will fail.
> 
> I was wondering if there was some kind of auto-link between source level
> in maven-compiler-plugin and toolchain plugin (it would be nice)
> 
> Anyway, I will go with this solution and hope for the best (anyway I will
> set the default jdk version to 1.5 so that if somebody update the source
> level by itself (not by the maven.compiler.source if will fail hard :D )

Define the plugin configuration in the parent pom in a pluginMgmt section 
and use the proposed property. Someone who inherits the POM may simply 
redefine the property then.

Cheers,
Jörg



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


Re: maven compiler plugin + toolchains

Posted by intel radoux <in...@gmail.com>.
Hello,

Yes, I could use "maven.compiler.source"  properties, but i'm on a parent
pom, and if somebody add a configuration like

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>xxx</source>
                    <target>xxx</target>
                </configuration>
            </plugin>

on his module it will fail.

I was wondering if there was some kind of auto-link between source level in
maven-compiler-plugin and toolchain plugin (it would be nice)

Anyway, I will go with this solution and hope for the best (anyway I will
set the default jdk version to 1.5 so that if somebody update the source
level by itself (not by the maven.compiler.source if will fail hard :D )

2015-04-22 20:56 GMT+02:00 Ron Wheeler <rw...@artifact-software.com>:

> Would setting a property ( <java_compliance_version>1.6
> </java_compliance_version>) in your parent and using the property as the
> value (<source>$java_compliance_version</source> )in the source, work?
>
> Ron
>
>
>
> On 22/04/2015 2:42 PM, intel radoux wrote:
>
>> Hello,
>>
>> I wish to set something like this in my parent pom :
>>
>>             <plugin>
>>                  <groupId>org.apache.maven.plugins</groupId>
>>                  <artifactId>maven-compiler-plugin</artifactId>
>>                  <version>3.3</version>
>>                  <configuration>
>>                      <source>1.6</source>
>>                      <target>1.6</target>
>>                  </configuration>
>>              </plugin>
>>              <plugin>
>>                  <groupId>org.apache.maven.plugins</groupId>
>>                  <artifactId>maven-toolchains-plugin</artifactId>
>>                  <version>1.1</version>
>>                  <configuration>
>>                      <toolchains>
>>                          <jdk>
>>
>>
>> <version>${project.build.pluginsAsMap(org.apache.maven.plugins:maven-compiler-plugin).configuration.children[0].value}</version>
>>
>>                          </jdk>
>>                      </toolchains>
>>                  </configuration>
>>                  <executions>
>>                      <execution>
>>                          <goals>
>>                              <goal>toolchain</goal>
>>                          </goals>
>>                      </execution>
>>                  </executions>
>>              </plugin>
>>
>> so that I can only set the source level in one place. The idea is that I
>> can set another level in one child module and toolchain will select the
>> correct JDK.
>>               <plugin>
>>                  <groupId>org.apache.maven.plugins</groupId>
>>                  <artifactId>maven-compiler-plugin</artifactId>
>>                  <version>3.3</version>
>>                  <configuration>
>>                      <source>1.7</source>
>>                      <target>1.7</target>
>>                  </configuration>
>>              </plugin>
>>
>> unfortunatly this don't work has ${project.build....... } is not resolved
>> when set in configuration element.
>> Do somebody have another idea on how to set this ? (why toolchain doesn't
>> work hand on hand with compiler plugins ? )
>>
>> Thank you
>>
>>
>
> --
> Ron Wheeler
> President
> Artifact Software Inc
> email: rwheeler@artifact-software.com
> skype: ronaldmwheeler
> phone: 866-970-2435, ext 102
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: maven compiler plugin + toolchains

Posted by Ron Wheeler <rw...@artifact-software.com>.
Would setting a property ( <java_compliance_version>1.6 
</java_compliance_version>) in your parent and using the property as the 
value (<source>$java_compliance_version</source> )in the source, work?

Ron


On 22/04/2015 2:42 PM, intel radoux wrote:
> Hello,
>
> I wish to set something like this in my parent pom :
>
>             <plugin>
>                  <groupId>org.apache.maven.plugins</groupId>
>                  <artifactId>maven-compiler-plugin</artifactId>
>                  <version>3.3</version>
>                  <configuration>
>                      <source>1.6</source>
>                      <target>1.6</target>
>                  </configuration>
>              </plugin>
>              <plugin>
>                  <groupId>org.apache.maven.plugins</groupId>
>                  <artifactId>maven-toolchains-plugin</artifactId>
>                  <version>1.1</version>
>                  <configuration>
>                      <toolchains>
>                          <jdk>
>
> <version>${project.build.pluginsAsMap(org.apache.maven.plugins:maven-compiler-plugin).configuration.children[0].value}</version>
>
>                          </jdk>
>                      </toolchains>
>                  </configuration>
>                  <executions>
>                      <execution>
>                          <goals>
>                              <goal>toolchain</goal>
>                          </goals>
>                      </execution>
>                  </executions>
>              </plugin>
>
> so that I can only set the source level in one place. The idea is that I
> can set another level in one child module and toolchain will select the
> correct JDK.
>               <plugin>
>                  <groupId>org.apache.maven.plugins</groupId>
>                  <artifactId>maven-compiler-plugin</artifactId>
>                  <version>3.3</version>
>                  <configuration>
>                      <source>1.7</source>
>                      <target>1.7</target>
>                  </configuration>
>              </plugin>
>
> unfortunatly this don't work has ${project.build....... } is not resolved
> when set in configuration element.
> Do somebody have another idea on how to set this ? (why toolchain doesn't
> work hand on hand with compiler plugins ? )
>
> Thank you
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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