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

fix: Support back-to-back properties and file.separator in SpoonPom #5156

Merged
Merged
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
6 changes: 4 additions & 2 deletions src/main/java/spoon/support/compiler/SpoonPom.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ public List<File> getClasspathTmpFiles(String fileName) {
}

// Pattern corresponding to maven properties ${propertyName}
private static Pattern mavenProperty = Pattern.compile("\\$\\{.*\\}");
private static final Pattern MAVEN_PROPERTY = Pattern.compile("\\$\\{.*?}");

/**
* Extract the variable from a string
*/
private String extractVariable(String value) {
String val = value;
if (value != null && value.contains("$")) {
Matcher matcher = mavenProperty.matcher(value);
Matcher matcher = MAVEN_PROPERTY.matcher(value);
while (matcher.find()) {
String var = matcher.group();
val = val.replace(var, getProperty(var.substring(2, var.length() - 1)));
Expand Down Expand Up @@ -353,6 +353,8 @@ private String getProperty(String key) {
}
} else if ("project.basedir".equals(key) || "pom.basedir".equals(key) || "basedir".equals(key)) {
return pomFile.getParent();
} else if ("file.separator".equals(key)) {

This comment was marked as spam.

return File.separator;
}
String value = extractVariable(model.getProperties().getProperty(key));
if (value == null) {
Expand Down