Skip to content

fixes #108: only propagate git properties to other maven modules #157

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

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
10 changes: 6 additions & 4 deletions src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class GitCommitIdMojo extends AbstractMojo {
* For details about why you might want to skip this, read this issue: https://github.com/ktoso/maven-git-commit-id-plugin/pull/65
* Basically, injecting into all projects may slow down the build and you don't always need this feature.
*
* @parameter default-value="true"
* @parameter default-value="false"
*/
@SuppressWarnings("UnusedDeclaration")
private boolean injectAllReactorProjects;
Expand Down Expand Up @@ -359,7 +359,7 @@ public void execute() throws MojoExecutionException {
}

if (injectAllReactorProjects) {
appendPropertiesToReactorProjects(properties);
appendPropertiesToReactorProjects(properties, prefixDot);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -408,14 +408,16 @@ private void handlePluginFailure(Exception e) throws MojoExecutionException {
}
}

private void appendPropertiesToReactorProjects(@NotNull Properties properties) {
private void appendPropertiesToReactorProjects(@NotNull Properties properties, @NotNull String trimmedPrefixWithDot) {
for (MavenProject mavenProject : reactorProjects) {
Properties mavenProperties = mavenProject.getProperties();

log(mavenProject.getName(), "] project", mavenProject.getName());

for (Object key : properties.keySet()) {
mavenProperties.put(key, properties.get(key));
if (key.toString().startsWith(trimmedPrefixWithDot)) {
mavenProperties.put(key, properties.get(key));
}
}
}
}
Expand Down