Skip to content

Commit 1732e8e

Browse files
authored
Allows git hook to run maven with thread count option (#185)
1 parent 9a116f2 commit 1732e8e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

core/src/main/java/com/cosium/code/format/InstallHooksMojo.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ public class InstallHooksMojo extends AbstractMavenGitCodeFormatMojo {
7474
@Parameter(property = "gcf.preCommitHookPipeline", defaultValue = "")
7575
private String preCommitHookPipeline;
7676

77+
/**
78+
* If present, this value will be passed to '-T, --threads Thread count, for instance 2.0C where C
79+
* is core multiplied'
80+
*/
81+
@Parameter(property = "gcf.hookMavenThreadCount")
82+
private String hookMavenThreadCount;
83+
7784
public void execute() throws MojoExecutionException {
7885
if (!isExecutionRoot()) {
7986
getLog().debug("Not in execution root. Do not execute.");
@@ -143,11 +150,14 @@ private String mavenCliArguments() {
143150
.filter(prop -> System.getProperty(prop) != null)
144151
.map(prop -> "-D" + prop + "=" + System.getProperty(prop));
145152

146-
Stream<String> properties = Stream.concat(propagatedProperties, Stream.of(propertiesToAdd));
153+
Stream<String> arguments = Stream.concat(propagatedProperties, Stream.of(propertiesToAdd));
147154
if (preCommitHookPipeline != null && !preCommitHookPipeline.isEmpty()) {
148-
properties = Stream.concat(properties, Stream.of(preCommitHookPipeline));
155+
arguments = Stream.concat(arguments, Stream.of(preCommitHookPipeline));
156+
}
157+
if (hookMavenThreadCount != null && !hookMavenThreadCount.isEmpty()) {
158+
arguments = Stream.concat(arguments, Stream.of("-T " + hookMavenThreadCount));
149159
}
150-
return properties.collect(Collectors.joining(" "));
160+
return arguments.collect(Collectors.joining(" "));
151161
}
152162

153163
private Path prepareHooksDirectory() {

core/src/test/projects/non-root-module/module/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
</dependency>
3535
</dependencies>
3636
<configuration>
37+
<hookMavenThreadCount>1C</hookMavenThreadCount>
3738
<propertiesToAdd>
3839
<prop>-X</prop>
3940
</propertiesToAdd>

0 commit comments

Comments
 (0)