From f0a092817aa1bc0f20ad487ebb9a19095d5d5c2a Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 1 Oct 2024 14:38:17 +0200 Subject: [PATCH 1/2] [MNG-8133] Fix project interpolation The interpolation of external parents is broken when referencing ${project.rootDirectory} --- .../impl/model/DefaultModelInterpolator.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java index ea2eee3ead76..b769e04a8a22 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java @@ -212,24 +212,24 @@ public Object getValue(String expression) { false); valueSources.add(baseUriValueSource); valueSources.add(new BuildTimestampValueSource(request.getSession().getStartTime(), modelProperties)); - } - valueSources.add(new PrefixedValueSourceWrapper( - new AbstractValueSource(false) { - @Override - public Object getValue(String expression) { - if ("rootDirectory".equals(expression)) { - Path root = rootLocator.findMandatoryRoot(projectDir); - return root.toFile().getPath(); - } else if (expression.startsWith("rootDirectory.")) { - Path root = rootLocator.findMandatoryRoot(projectDir); - return new ObjectBasedValueSource(root) - .getValue(expression.substring("rootDirectory.".length())); + valueSources.add(new PrefixedValueSourceWrapper( + new AbstractValueSource(false) { + @Override + public Object getValue(String expression) { + if ("rootDirectory".equals(expression)) { + Path root = rootLocator.findMandatoryRoot(projectDir); + return root.toFile().getPath(); + } else if (expression.startsWith("rootDirectory.")) { + Path root = rootLocator.findMandatoryRoot(projectDir); + return new ObjectBasedValueSource(root) + .getValue(expression.substring("rootDirectory.".length())); + } + return null; } - return null; - } - }, - getProjectPrefixes(request))); + }, + getProjectPrefixes(request))); + } valueSources.add(projectPrefixValueSource); From d05c2929242481492aab33e41b22cacc62ccf547 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 2 Oct 2024 23:35:50 +0200 Subject: [PATCH 2/2] Update DefaultModelInterpolator.java --- .../maven/internal/impl/model/DefaultModelInterpolator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java index 5d4915a2155f..927ed72f359a 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelInterpolator.java @@ -128,7 +128,7 @@ protected List getProjectPrefixes(ModelBuilderRequest request) { : PROJECT_PREFIXES_3_1; } - String callback( + String callback( Model model, Path projectDir, ModelBuilderRequest request,