mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Pass project settings to flatten command (#2269)
This commit is contained in:
parent
c2bd05fb3d
commit
6afb0ae507
@ -278,10 +278,12 @@ func warFile(dir, finalName string) string {
|
||||
|
||||
func flattenPom(command mavenExecRunner, o EvaluateOptions) error {
|
||||
mavenOptionsFlatten := ExecuteOptions{
|
||||
Goals: []string{"flatten:flatten"},
|
||||
Defines: []string{"-Dflatten.mode=resolveCiFriendliesOnly"},
|
||||
PomPath: "pom.xml",
|
||||
M2Path: o.M2Path,
|
||||
Goals: []string{"flatten:flatten"},
|
||||
Defines: []string{"-Dflatten.mode=resolveCiFriendliesOnly"},
|
||||
PomPath: "pom.xml",
|
||||
M2Path: o.M2Path,
|
||||
ProjectSettingsFile: o.ProjectSettingsFile,
|
||||
GlobalSettingsFile: o.GlobalSettingsFile,
|
||||
}
|
||||
_, err := Execute(&mavenOptionsFlatten, command)
|
||||
return err
|
||||
|
@ -197,15 +197,18 @@ func TestMavenInstall(t *testing.T) {
|
||||
utils.AddFile("pom.xml", []byte("<project></project>"))
|
||||
|
||||
options := EvaluateOptions{}
|
||||
|
||||
options.ProjectSettingsFile = "settings.xml"
|
||||
|
||||
execMockRunner := mock.ExecMockRunner{}
|
||||
execMockRunner.StdoutReturn = map[string]string{"mvn --file pom.xml -Dexpression=project.build.finalName -DforceStdout -q -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate": "foo"}
|
||||
execMockRunner.StdoutReturn = map[string]string{"mvn --settings settings.xml --file pom.xml -Dexpression=project.build.finalName -DforceStdout -q -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate": "foo"}
|
||||
err := doInstallMavenArtifacts(&execMockRunner, options, &utils)
|
||||
|
||||
assert.NoError(t, err)
|
||||
if assert.Equal(t, 5, len(execMockRunner.Calls)) {
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"--file", "pom.xml", "-Dflatten.mode=resolveCiFriendliesOnly", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "flatten:flatten"}}, execMockRunner.Calls[0])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"--file", "pom.xml", "-Dexpression=project.packaging", "-DforceStdout", "-q", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate"}}, execMockRunner.Calls[1])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"--file", "pom.xml", "-Dexpression=project.build.finalName", "-DforceStdout", "-q", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate"}}, execMockRunner.Calls[2])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"--settings", "settings.xml", "--file", "pom.xml", "-Dflatten.mode=resolveCiFriendliesOnly", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "flatten:flatten"}}, execMockRunner.Calls[0])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"--settings", "settings.xml", "--file", "pom.xml", "-Dexpression=project.packaging", "-DforceStdout", "-q", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate"}}, execMockRunner.Calls[1])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"--settings", "settings.xml", "--file", "pom.xml", "-Dexpression=project.build.finalName", "-DforceStdout", "-q", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate"}}, execMockRunner.Calls[2])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"-Dfile=" + filepath.Join(".", "target", "foo.jar"), "-Dpackaging=jar", "-DpomFile=pom.xml", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "install:install-file"}}, execMockRunner.Calls[3])
|
||||
assert.Equal(t, mock.ExecCall{Exec: "mvn", Params: []string{"-Dfile=" + filepath.Join(".", "target", "foo.war"), "-DpomFile=pom.xml", "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", "--batch-mode", "install:install-file"}}, execMockRunner.Calls[4])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user