Skip to content

Commit

Permalink
Make sure the Maven plugin module has relevant project properties set
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Sep 25, 2024
1 parent d85305c commit 94eff92
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
pom.setProperties(new Properties());
for (Map.Entry<?, ?> originalProp : originalProps.entrySet()) {
final String propName = originalProp.getKey().toString();
if (!project.getOriginalModel().getProperties().containsKey(propName)) {
// if it's not a version property, we add it
if (propName.startsWith("maven.") || getArtifactGroupIdsForVersionProperty(propName).isEmpty()) {
pom.getProperties().setProperty(propName, originalProp.getValue().toString());
}
}
Expand Down Expand Up @@ -2215,7 +2216,7 @@ private void mapProjectProperties(Properties props) {

private Collection<String> getArtifactGroupIdsForVersionProperty(final String versionProperty) {
var propExpr = "${" + versionProperty + "}";
Set<String> result = new HashSet<>();
Set<String> result = null;
for (String s : pomLines()) {
int coordsEnd = s.indexOf(propExpr);
// looking for <p>propExpr</p>, min length will be propExpr.length() + 3 + 4
Expand All @@ -2234,10 +2235,13 @@ private Collection<String> getArtifactGroupIdsForVersionProperty(final String ve
var coords = s.substring(coordsStart + 1, coordsEnd);
var arr = coords.split(COLON);
if (arr.length > 2 && arr.length < 6) {
if (result == null) {
result = new HashSet<>(2);
}
result.add(arr[0]);
}
}
return result;
return result == null ? Set.of() : result;
}

private void addDependencies(final Model pom, List<String> dependencies, boolean test) {
Expand Down

0 comments on commit 94eff92

Please sign in to comment.