Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow searching for the .mvn dir recursively by other modules that use this module #279

Merged
merged 4 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 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
// Path to the root project directory in maven multi-module project. May contain .mvn directory.
rootProjectDir string
galusben marked this conversation as resolved.
Show resolved Hide resolved
}

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

func (mm *MavenModule) SetMavenRootDir(rootDir string) {
func (mm *MavenModule) SetrootProjectDir(rootDir string) {
galusben marked this conversation as resolved.
Show resolved Hide resolved
mm.rootProjectDir = rootDir
}

Expand Down
35 changes: 24 additions & 11 deletions build/maven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,32 @@ 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,
java: "myJava",
plexusClassworlds: "myPlexus",
cleassworldsConfig: "myCleassworldsConfig",
mavenHome: "myMavenHome",
pluginDependencies: "myPluginDependencies",
workspace: "myWorkspace",
goals: []string{"myGoal1", "myGoal2"},
buildInfoProperties: "myBuildInfoProperties",
mavenOpts: []string{"myMavenOpt1", "myMavenOpt2"},
logger: nil,
outputWriter: nil,
rootProjectDir: "root",
rootProjectDir: "myRootProjectDir",
}
cmd := mvnc.GetCmd()
assert.Equal(t, "-Dmaven.multiModuleProjectDirectory=root", cmd.Args[7])
assert.Equal(t, "myJava", cmd.Args[0])
assert.Equal(t, "-classpath", cmd.Args[1])
assert.Equal(t, "myPlexus", cmd.Args[2])
assert.Contains(t, cmd.Args, "-DbuildInfoConfig.propertiesFile=myBuildInfoProperties")
assert.Contains(t, cmd.Args, "-Dclassworlds.conf=myCleassworldsConfig")
assert.Contains(t, cmd.Args, "-Dclassworlds.conf=myCleassworldsConfig")
assert.Contains(t, cmd.Args, "-Dmaven.home=myMavenHome")
assert.Contains(t, cmd.Args, "-Dm3plugin.lib=myPluginDependencies")
assert.Contains(t, cmd.Args, "myGoal1")
assert.Contains(t, cmd.Args, "myGoal2")
assert.Contains(t, cmd.Args, "-DbuildInfoConfig.propertiesFile=myBuildInfoProperties")
assert.Contains(t, cmd.Args, "myMavenOpt1")
assert.Contains(t, cmd.Args, "myMavenOpt2")
assert.Contains(t, cmd.Args, "-Dmaven.multiModuleProjectDirectory=myRootProjectDir")
}
Loading