You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mirko Friedenhagen <mf...@gmx.de> on 2026/01/07 16:35:43 UTC
Modifying $project properties with maven-scripting-plugin?
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Mirko Friedenhagen <mf...@gmx.de>.
Thanks to everyone, I obviously forgot about the JDK version based activation myself :facepalm:
Mit freundlichen Grüßen
Mirko Friedenhagen
—
> Am 09.01.2026 um 05:15 schrieb Alexander Kriegisch <al...@kriegisch.name>:
>
> I was not following the docs link, which is why I am ugly and stupid.
> Thanks for the correction and explanation. 🙂🙏
> --
> Alexander Kriegisch
> https://scrum-master.de
>
>
> Nils Breunese schrieb am 09.01.2026 um 09:54:
>> Alexander Kriegisch <al...@kriegisch.name> wrote:
>>
>>> I have not tried, but in Nils' solution both profiles might be active,
>>> and I am unsure which property would win.
>>
>> How could both profiles be active? The docs I linked say the following for providing a single JDK version: “(…) in particular it won’t be active for newer versions (…)”, so my solution more closely matches what was attempted.
>>
>> But yes, it is indeed also possible to use ranges, as documented.
>>
>> Nils.
>>
>>> In some of my project, I
>>> rather did this:
>>>
>>> <jdk>[1.8,16)</jdk>
>>> ...
>>> <jdk>[16,24)</jdk>
>>> ...
>>> <jdk>[24,)</jdk>
>>> ...
>>>
>>> --
>>> Alexander Kriegisch
>>> https://scrum-master.de
>>>
>>>
>>> Nils Breunese schrieb am 09.01.2026 um 05:49:
>>>> Mirko Friedenhagen <mf...@gmx.de> 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 <ta...@cservenak.net>:
>>>>>>
>>>>>> 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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
I was not following the docs link, which is why I am ugly and stupid.
Thanks for the correction and explanation. 🙂🙏
--
Alexander Kriegisch
https://scrum-master.de
Nils Breunese schrieb am 09.01.2026 um 09:54:
> Alexander Kriegisch <al...@kriegisch.name> wrote:
>
>> I have not tried, but in Nils' solution both profiles might be active,
>> and I am unsure which property would win.
>
> How could both profiles be active? The docs I linked say the following for providing a single JDK version: “(…) in particular it won’t be active for newer versions (…)”, so my solution more closely matches what was attempted.
>
> But yes, it is indeed also possible to use ranges, as documented.
>
> Nils.
>
>> In some of my project, I
>> rather did this:
>>
>> <jdk>[1.8,16)</jdk>
>> ...
>> <jdk>[16,24)</jdk>
>> ...
>> <jdk>[24,)</jdk>
>> ...
>>
>> --
>> Alexander Kriegisch
>> https://scrum-master.de
>>
>>
>> Nils Breunese schrieb am 09.01.2026 um 05:49:
>>> Mirko Friedenhagen <mf...@gmx.de> 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 <ta...@cservenak.net>:
>>>>>
>>>>> 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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Nils Breunese <ni...@breun.nl>.
Alexander Kriegisch <al...@kriegisch.name> wrote:
> I have not tried, but in Nils' solution both profiles might be active,
> and I am unsure which property would win.
How could both profiles be active? The docs I linked say the following for providing a single JDK version: “(…) in particular it won’t be active for newer versions (…)”, so my solution more closely matches what was attempted.
But yes, it is indeed also possible to use ranges, as documented.
Nils.
> In some of my project, I
> rather did this:
>
> <jdk>[1.8,16)</jdk>
> ...
> <jdk>[16,24)</jdk>
> ...
> <jdk>[24,)</jdk>
> ...
>
> --
> Alexander Kriegisch
> https://scrum-master.de
>
>
> Nils Breunese schrieb am 09.01.2026 um 05:49:
>> Mirko Friedenhagen <mf...@gmx.de> 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 <ta...@cservenak.net>:
>>>>
>>>> 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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
I have not tried, but in Nils' solution both profiles might be active,
and I am unsure which property would win. In some of my project, I
rather did this:
<jdk>[1.8,16)</jdk>
...
<jdk>[16,24)</jdk>
...
<jdk>[24,)</jdk>
...
--
Alexander Kriegisch
https://scrum-master.de
Nils Breunese schrieb am 09.01.2026 um 05:49:
> Mirko Friedenhagen <mf...@gmx.de> 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 <ta...@cservenak.net>:
>>>
>>> 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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Nils Breunese <ni...@breun.nl>.
Mirko Friedenhagen <mf...@gmx.de> 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 <ta...@cservenak.net>:
>>
>> 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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Mirko Friedenhagen <mf...@gmx.de>.
AFAIK profiles _may not_ be activated via project properties, only via system-properties/environment variables.
Thinking loud: maybe set this in .mvn/maven.config?
Mit freundlichen Grüßen
Mirko Friedenhagen
—
> Am 07.01.2026 um 18:11 schrieb Tamás Cservenák <ta...@cservenak.net>:
>
> 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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
Wow, I never tried that before, just read the mojo documentation. This
sounds intriguing and very powerful. (I mean it.)
However, I want to just think aloud about possible consequences of
scripting a build like that: Your IDE might not be able to build and/or
run the project correctly anymore after importing/refreshing from the
Maven build, because it cannot interpret or emulate whatever you
scripted there. So, you might want to test that before happily
committing your clever solution.
--
Alexander Kriegisch
https://scrum-master.de
Greg Chabala schrieb am 08.01.2026 um 09:23:
> Not sure if it's possible from the scripting plugin, but I've definitely
> run a bit of Java code with the exec-maven-plugin and used the injected
> projectPropertiesUpdater callback to adjust project properties:
> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Greg Chabala <gr...@gmail.com>.
Not sure if it's possible from the scripting plugin, but I've definitely
run a bit of Java code with the exec-maven-plugin and used the injected
projectPropertiesUpdater callback to adjust project properties:
https://www.mojohaus.org/exec-maven-plugin/java-mojo.html
Greg Chabala
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Tamás Cservenák <ta...@cservenak.net>.
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 <mf...@gmx.de> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Modifying $project properties with maven-scripting-plugin?
Posted by Mirko Friedenhagen <mf...@gmx.de>.
Sorry for talking to myself:
* While overriding is not possible, creating a *property* works...
Mit freundlichen Grüßen
Mirko Friedenhagen
—
> Am 07.01.2026 um 17:35 schrieb Mirko Friedenhagen <mf...@gmx.de>:
>
> 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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org