Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8402] System properties can take precedence over builtin expressions #1947

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compat/maven-embedder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ under the License.
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
1 change: 0 additions & 1 deletion impl/maven-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ under the License.
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
5 changes: 5 additions & 0 deletions impl/maven-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ under the License.
<artifactId>maven-resolver-transport-apache</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ String doCallback(
}
}
}
// un-prefixed model reflection
String value = projectProperty(model, projectDir, expression, false);
// user properties
String value = request.getUserProperties().get(expression);
if (value == null) {
value = request.getUserProperties().get(expression);
}
// model properties
if (value == null) {
value = model.getProperties().get(expression);
Expand All @@ -198,11 +202,7 @@ String doCallback(
if (value == null) {
value = request.getSystemProperties().get("env." + expression);
}
if (value != null) {
return value;
}
// model reflection
return projectProperty(model, projectDir, expression, false);
return value;
}

String projectProperty(Model model, Path projectDir, String subExpr, boolean prefixed) {
Expand All @@ -223,7 +223,7 @@ String projectProperty(Model model, Path projectDir, String subExpr, boolean pre
} else if (prefixed && subExpr.startsWith("baseUri.")) {
try {
Object value = ReflectionValueExtractor.evaluate(
subExpr, projectDir.toAbsolutePath().toUri(), false);
subExpr, projectDir.toAbsolutePath().toUri(), true);
if (value != null) {
return value.toString();
}
Expand All @@ -234,8 +234,8 @@ String projectProperty(Model model, Path projectDir, String subExpr, boolean pre
return rootLocator.findMandatoryRoot(projectDir).toString();
} else if (prefixed && subExpr.startsWith("rootDirectory.")) {
try {
Object value = ReflectionValueExtractor.evaluate(
subExpr, projectDir.toAbsolutePath().toUri(), false);
Object value =
ReflectionValueExtractor.evaluate(subExpr, rootLocator.findMandatoryRoot(projectDir), true);
if (value != null) {
return value.toString();
}
Expand Down
Loading
Loading