mirror of
https://github.com/Graylog2/graylog-project-cli.git
synced 2026-03-13 08:02:57 +08:00
60 lines
2.2 KiB
Go
60 lines
2.2 KiB
Go
package apply
|
|
|
|
import (
|
|
"github.com/Graylog2/graylog-project-cli/project"
|
|
"github.com/Graylog2/graylog-project-cli/utils"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type CommonMaven struct {
|
|
Applier Applier
|
|
Profiles []string
|
|
}
|
|
|
|
func (common CommonMaven) MavenRunWithProfiles(profiles []string, args ...string) {
|
|
commands := []string{utils.MavenBin() + " --show-version --batch-mode --fail-fast"}
|
|
|
|
// Force maven color output when executed on Jenkins to prettify the logs
|
|
if os.Getenv("BUILD_ID") != "" {
|
|
commands = append(commands, "-Dstyle.color=always")
|
|
}
|
|
|
|
if len(profiles) > 0 {
|
|
commands = append(commands, "--activate-profiles")
|
|
commands = append(commands, strings.Join(profiles, ","))
|
|
}
|
|
|
|
commands = append(commands, strings.Join(args, " "))
|
|
|
|
common.Applier.MavenExec(commands)
|
|
}
|
|
|
|
func (common CommonMaven) MavenRun(args ...string) {
|
|
common.MavenRunWithProfiles([]string{}, args...)
|
|
}
|
|
|
|
func (common CommonMaven) MavenVersionsSet(newVersion string) {
|
|
common.MavenRunWithProfiles(common.Profiles, "-DnewVersion="+newVersion, "versions:set", "versions:commit")
|
|
}
|
|
|
|
func (common CommonMaven) MavenScmCheckinRelease(moduleName string, moduleVersion string) {
|
|
common.MavenRunWithProfiles(common.Profiles, "-Dmessage=\"["+moduleName+"] prepare release "+moduleVersion+"\"", "-Dincludes=\"**/pom.xml\"", "-Dexcludes=\"**/target/**/pom.xml\"", "scm:checkin")
|
|
}
|
|
|
|
func (common CommonMaven) MavenScmCheckinDevelopment(moduleName string) {
|
|
common.MavenRunWithProfiles(common.Profiles, "-Dmessage=\"["+moduleName+"] prepare for next development iteration\"", "-Dincludes=\"**/pom.xml\"", "-Dexcludes=\"**/target/**/pom.xml\"", "scm:checkin")
|
|
}
|
|
|
|
func (common CommonMaven) MavenScmTag(moduleTag string) {
|
|
common.MavenRunWithProfiles(common.Profiles, "-Dtag="+moduleTag, "scm:tag")
|
|
}
|
|
|
|
func (common CommonMaven) MavenScmBranch(moduleBranch string) {
|
|
common.MavenRunWithProfiles(common.Profiles, "-Dbranch="+moduleBranch, "scm:branch")
|
|
}
|
|
|
|
func (common CommonMaven) MavenDependencyVersionSet(module project.Module, groupId string, artifactId string, newVersion string) {
|
|
common.MavenRunWithProfiles(common.Profiles, "versions:use-dep-version", "-DdepVersion="+newVersion, "-DforceVersion", "-Dincludes="+groupId+":"+artifactId)
|
|
}
|