configuring maven builds based on CPU quota if set any
@@ -26,6 +26,8 @@ import (
"os/exec"
"path"
"regexp"
+ "runtime"
+ "strconv"
"strings"
"github.com/pkg/errors"
@@ -74,6 +76,14 @@ func (c *Command) Do(ctx context.Context) error {
args = append(args, "--settings", settingsPath)
}
+ if !util.StringContainsPrefix(c.context.AdditionalArguments, "-Dmaven.artifact.threads") {
+ args = append(args, "-Dmaven.artifact.threads="+strconv.Itoa(runtime.GOMAXPROCS(0)))
+ }
+
+ if !util.StringSliceExists(c.context.AdditionalArguments, "-T") {
+ args = append(args, "-T", strconv.Itoa(runtime.GOMAXPROCS(0)))
+ }
+
cmd := exec.CommandContext(ctx, mvnCmd, args...)
cmd.Dir = c.context.Path
