Mirko Friedenhagen <[email protected]> wrote:

> AFAIK profiles _may not_ be activated via project properties, only via 
> system-properties/environment variables.
> Thinking loud: maybe set this in .mvn/maven.config?

I think Tamás meant to suggest auto-activating profiles based on the JDK 
version 
(https://maven.apache.org/guides/introduction/introduction-to-profiles.html#jdk).

Something like this:

<profiles>
<profile>
    <activation>
      <jdk>21</jdk>
    </activation>
    <properties>
      
<docker-maven-plugin.from>docker.io/library/eclipse-temurin:21.0.9_10-jre-alpine-3.23</docker-maven-plugin.from>
    </properties>
  </profile>
  <profile>
    <activation>
      <jdk>25</jdk>
    </activation>
    <properties>
      
<docker-maven-plugin.from>docker.io/library/eclipse-temurin:25.0.1_8-jre-alpine-3.23</docker-maven-plugin.from>
    </properties>
  </profile>
</profiles>

Nils.

>> Am 07.01.2026 um 18:11 schrieb Tamás Cservenák <[email protected]>:
>> 
>> Howdy,
>> 
>> Would not doing this be simpler from a profile? Which is activated
>> based on the Java version?
>> 
>> T
>> 
>> On Wed, Jan 7, 2026 at 5:36 PM Mirko Friedenhagen <[email protected]> 
>> wrote:
>>> 
>>> Hi,
>>> 
>>> is it somehow possible to add or modify the project resp. its properties 
>>> during e.g. validate or initialize with this plugin?
>>> I defined the following and want
>>> 
>>> <properties>
>>> <docker-maven-plugin.from>docker.io/library/eclipse-temurin:21.0.9_10-jre-alpine-3.23</docker-maven-plugin.from>
>>> <java.version>21<java.version>
>>> </properties>
>>> 
>>> <plugins>
>>> <plugin>
>>>       <artifactId>maven-scripting-plugin</artifactId>
>>>       <version>3.1.0</version>
>>>       <executions>
>>>               <execution>
>>>                       <id>foo</id>
>>>                       <phase>initialize</phase>
>>>                       <goals><goal>eval</goal></goals>
>>>                       <configuration>
>>>                               <engineName>java</engineName>
>>>                               <script><![CDATA[
>>>                                       var props = $project.getProperties();
>>>                                       System.err.println("XXXXX " + 
>>> props.getProperty("docker-maven-plugin.from"));
>>>                                       var version = 
>>> props.getProperty("java.version");
>>>                                       switch (version) {
>>>                                               case "21" -> 
>>> props.setProperty("docker-maven-plugin.from", 
>>> "docker.io/library/eclipse-temurin:21.0.9_10-jre-alpine-3.23");
>>>                                               case "25" -> 
>>> props.setProperty("docker-maven-plugin.from", 
>>> "docker.io/library/eclipse-temurin:25.0.1_8-jre-alpine-3.23");
>>>                                               default -> throw new 
>>> IllegalArgumentException("Not supported“);
>>>                                       }
>>>                                       System.err.println("YYYYY " + 
>>> props.getProperty("docker-maven-plugin.from"));
>>>                               ]]>
>>>                               </script>
>>>                       </configuration>
>>>               </execution>
>>>       </executions>
>>> </plugin>
>>> <plugins>
>>> 
>>> The println statement are executed and show the „correct“ result, however 
>>> when I lateron reference reference property docker-maven-plugin.from in a 
>>> plugin it still has the value of the definition in the standard properties 
>>> section.
>>> 
>>> 
>>> Mit freundlichen Grüßen
>>> Mirko Friedenhagen


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

Reply via email to