Skip to content

Commit

Permalink
2673 - Recursively search for .mvn dir
Browse files Browse the repository at this point in the history
  • Loading branch information
galusben committed Sep 29, 2024
1 parent c694d21 commit 4eeea50
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
11 changes: 9 additions & 2 deletions build/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type MavenModule struct {
// A pipe to write the maven extractor output to.
outputWriter io.Writer
// Path to the build info temp file that will be generated by the maven extractor.
buildInfoPath string
buildInfoPath string
rootProjectDir string
}

// Maven extractor is the engine for calculating the project dependencies.
Expand Down Expand Up @@ -161,6 +162,7 @@ func (mm *MavenModule) createMvnRunConfig() (*mvnRunConfig, error) {
buildInfoProperties: extractorProps,
mavenOpts: mm.extractorDetails.mavenOpts,
logger: mm.containingBuild.logger,
rootProjectDir: mm.rootProjectDir,
}, nil
}

Expand Down Expand Up @@ -288,6 +290,10 @@ func (mm *MavenModule) extractMavenPath(mavenVersionOutput bytes.Buffer) (mavenH
return
}

func (mm *MavenModule) SetMavenRootDir(rootDir string) {
mm.rootProjectDir = rootDir
}

func downloadMavenExtractor(downloadTo string, downloadExtractorFunc func(downloadTo, downloadPath string) error, logger utils.Log) error {
filename := fmt.Sprintf(MavenExtractorFileName, MavenExtractorDependencyVersion)
filePath := fmt.Sprintf(MavenExtractorRemotePath, MavenExtractorDependencyVersion)
Expand All @@ -313,7 +319,7 @@ func (config *mvnRunConfig) GetCmd() *exec.Cmd {
cmd = append(cmd, "-DbuildInfoConfig.propertiesFile="+config.buildInfoProperties)
cmd = append(cmd, "-Dm3plugin.lib="+config.pluginDependencies)
cmd = append(cmd, "-Dclassworlds.conf="+config.cleassworldsConfig)
cmd = append(cmd, "-Dmaven.multiModuleProjectDirectory="+config.workspace)
cmd = append(cmd, "-Dmaven.multiModuleProjectDirectory="+config.rootProjectDir)
if config.mavenOpts != nil {
cmd = append(cmd, config.mavenOpts...)
}
Expand All @@ -334,6 +340,7 @@ type mvnRunConfig struct {
mavenOpts []string
logger utils.Log
outputWriter io.Writer
rootProjectDir string
}

func (config *mvnRunConfig) SetOutputWriter(outputWriter io.Writer) *mvnRunConfig {
Expand Down
19 changes: 19 additions & 0 deletions build/maven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,22 @@ func TestAddColorToCmdOutput(t *testing.T) {
})
}
}

func TestCommandWithRootProjectDir(t *testing.T) {
mvnc := &mvnRunConfig{
java: "java",
plexusClassworlds: "plexus",
cleassworldsConfig: "",
mavenHome: "",
pluginDependencies: "",
workspace: "",
goals: nil,
buildInfoProperties: "",
mavenOpts: nil,
logger: nil,
outputWriter: nil,
rootProjectDir: "root",
}
cmd := mvnc.GetCmd()
assert.Equal(t, "-Dmaven.multiModuleProjectDirectory=root", cmd.Args[7])
}

0 comments on commit 4eeea50

Please sign in to comment.