[ 
https://issues.apache.org/jira/browse/MNG-8486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17910819#comment-17910819
 ] 

Tamas Cservenak edited comment on MNG-8486 at 1/7/25 9:59 PM:
--------------------------------------------------------------

[~breun] please report this bug to Jib project, as IMHO this is their bug. In 
short, they document to set _Maven User Property_, but in reality their code 
looks into Maven System Properties and in Maven Project properties. Maven User 
property are not in neither of those two (it is nor System nor Project but User 
Property).

Refs:
tag is get here
https://github.com/GoogleContainerTools/jib/blob/5d9beaee002e21fdeeb868edbc09e3727696937c/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java#L460
that calls here
https://github.com/GoogleContainerTools/jib/blob/5d9beaee002e21fdeeb868edbc09e3727696937c/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java#L866-L868
that calls here
https://github.com/GoogleContainerTools/jib/blob/5d9beaee002e21fdeeb868edbc09e3727696937c/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java#L144-L153

But as you can see in last method (where it all end up):
{noformat}
  @Nullable
  public static String getProperty(
      String propertyName, @Nullable MavenProject project, @Nullable 
MavenSession session) {
    if (session != null && 
session.getSystemProperties().containsKey(propertyName)) {
      return session.getSystemProperties().getProperty(propertyName);
    }
    if (project != null && project.getProperties().containsKey(propertyName)) {
      return project.getProperties().getProperty(propertyName);
    }
    return null;
  }
{noformat}

This method is wrong. They should consult {{session.getUserProperties()}} as 
well, or, simpler would be to consult {{session.getConfigProperties()}} only, 
as that are "effective" properties (system + user overlaid, in this order).


was (Author: cstamas):
[~breun] please report this bug to Jib project, as IMHO this is their bug. In 
short, they document to set _Maven User Property_, but in reality their code 
looks into Maven System Properties and in Project properties. Maven User 
property are not in neither of those two (it is nor System nor Project but User 
Property).

Refs:
tag is get here
https://github.com/GoogleContainerTools/jib/blob/5d9beaee002e21fdeeb868edbc09e3727696937c/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java#L460
that calls here
https://github.com/GoogleContainerTools/jib/blob/5d9beaee002e21fdeeb868edbc09e3727696937c/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java#L866-L868
that calls here
https://github.com/GoogleContainerTools/jib/blob/5d9beaee002e21fdeeb868edbc09e3727696937c/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java#L144-L153

But as you can see in last method (where it all end up):
{noformat}
  @Nullable
  public static String getProperty(
      String propertyName, @Nullable MavenProject project, @Nullable 
MavenSession session) {
    if (session != null && 
session.getSystemProperties().containsKey(propertyName)) {
      return session.getSystemProperties().getProperty(propertyName);
    }
    if (project != null && project.getProperties().containsKey(propertyName)) {
      return project.getProperties().getProperty(propertyName);
    }
    return null;
  }
{noformat}

This method is wrong. They should consult {{session.getUserProperties()}} as 
well, or, simpler would be to consult {{session.getConfigProperties()}} only, 
as that are "effective" properties (system + user overlaid, in this order).

> User properties no longer pushed to system properties
> -----------------------------------------------------
>
>                 Key: MNG-8486
>                 URL: https://issues.apache.org/jira/browse/MNG-8486
>             Project: Maven
>          Issue Type: Bug
>    Affects Versions: 4.0.0-rc-2
>            Reporter: Nils Breunese
>            Priority: Major
>             Fix For: 4.0.0-rc-3
>
>
> I’m using {{jib-maven-plugin}} with some properties provided on the command 
> line to build a container image. According to 
> https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#system-properties
>  this can be done as follows:
> {code}
> mvn compile jib:build -Djib.to.image=myregistry/myimage:latest
> {code}
> I’ve been successfully using the syntax above with Maven 3.9.9, but when I 
> try this with Maven 4.0.0-rc-2 it seems that the {{jib.to.image}} property is 
> not picked up by {{jib-maven-plugin}}.
> When I do this, it does work:
> {code}
> MAVEN_OPTS="-Djib.to.image=myregistry/myimage:latest” compile jib:build
> {code}
> I noticed that the Jib Maven Plugin documentation says that {{jib.to.image}} 
> is a (Java) _system_ property, while technically `-D` on the Maven command 
> line is for (Maven) _user_ properties.
> I've [reported this on the Maven users 
> mailinglist|https://lists.apache.org/thread/56fsshgwpb358dtw314khlpdylyffl4y] 
> and [~cstamas] explained that although at some point Maven wants to stop 
> pushing Maven user properties to Java system properties, this is not an 
> intentional change for Maven 4.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to