Skip to content

Commit

Permalink
[gradle] do not define settings.gradle if at default location. Fixes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Oct 6, 2020
1 parent 981e37c commit b3a3e53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions gum/gradle.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type GradleCommand struct {
executable string
args *ParsedArgs
explicitProjectDir string
rootDir string
buildFile string
explicitBuildFile string
rootBuildFile string
Expand Down Expand Up @@ -95,8 +96,14 @@ func (c *GradleCommand) doConfigureGradle() {
banner = append(banner, "with settings at '"+c.explicitSettingsFile+"':")
}
} else if len(c.settingsFile) > 0 {
args = append(args, "-c")
args = append(args, c.settingsFile)
pwd, _ := filepath.Abs(c.context.GetWorkingDir())
settingsDir, _ := filepath.Abs(filepath.Dir(c.settingsFile))

if c.rootDir != settingsDir || c.rootDir != pwd {
args = append(args, "-c")
args = append(args, c.settingsFile)
}

if !buildFileSet {
banner = append(banner, "with settings at '"+c.settingsFile+"':")
}
Expand Down Expand Up @@ -201,6 +208,7 @@ func FindGradle(context Context, args *ParsedArgs) *GradleCommand {
config: config,
executable: executable,
args: args,
rootDir: rootdir,
explicitProjectDir: explicitProjectDir}
}

Expand All @@ -211,6 +219,7 @@ func FindGradle(context Context, args *ParsedArgs) *GradleCommand {
config: config,
executable: executable,
args: args,
rootDir: rootdir,
explicitBuildFile: explicitBuildFile,
explicitSettingsFile: explicitSettingsFile}
}
Expand All @@ -219,6 +228,7 @@ func FindGradle(context Context, args *ParsedArgs) *GradleCommand {
config: config,
executable: executable,
args: args,
rootDir: rootdir,
explicitBuildFile: explicitBuildFile,
settingsFile: settingsFile}
}
Expand All @@ -238,6 +248,7 @@ func FindGradle(context Context, args *ParsedArgs) *GradleCommand {
config: config,
executable: executable,
args: args,
rootDir: rootdir,
buildFile: buildFile,
rootBuildFile: rootBuildFile,
explicitSettingsFile: explicitSettingsFile}
Expand All @@ -261,6 +272,7 @@ func FindGradle(context Context, args *ParsedArgs) *GradleCommand {
config: config,
executable: executable,
args: args,
rootDir: rootdir,
buildFile: buildFile,
rootBuildFile: rootBuildFile,
settingsFile: settingsFile,
Expand All @@ -286,7 +298,9 @@ func resolveGradleRootDir(context Context,
} else if context.FileExists(settingsFile) {
return filepath.Dir(settingsFile)
}
return filepath.Dir(buildFile)

dir, _ := filepath.Abs(filepath.Dir(buildFile))
return dir
}

func resolveGradleWrapperExecutable(context Context, args *ParsedArgs) (string, error) {
Expand Down
1 change: 1 addition & 0 deletions gum/jbang.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (c *JbangCommand) doExecuteJbang() {
func (c *JbangCommand) debugJbang(config *Config, oargs []string) {
if c.config.general.debug {
fmt.Println("discovery = ", config.jbang.discovery)
fmt.Println("pwd = ", c.context.GetWorkingDir())
fmt.Println("sourceFile = ", c.sourceFile)
fmt.Println("explicitSourceFile = ", c.explicitSourceFile)
fmt.Println("original args = ", oargs)
Expand Down

0 comments on commit b3a3e53

Please sign in to comment.