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

Make sure the Maven plugin module has relevant project properties set #350

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
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
Loading