From 300517a65a92ab467126c359903c49985b8db5e3 Mon Sep 17 00:00:00 2001 From: keegan morrissey Date: Tue, 27 Jun 2023 08:13:24 -0500 Subject: [PATCH 1/3] Bug fix: gradle args with spaces --- artifactory/commands/gradle/gradle.go | 4 ++-- utils/gradle/utils.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/artifactory/commands/gradle/gradle.go b/artifactory/commands/gradle/gradle.go index 376ef3067..334dcafad 100644 --- a/artifactory/commands/gradle/gradle.go +++ b/artifactory/commands/gradle/gradle.go @@ -14,7 +14,7 @@ import ( ) type GradleCommand struct { - tasks string + tasks []string configPath string configuration *utils.BuildConfiguration serverDetails *config.ServerDetails @@ -179,7 +179,7 @@ func (gc *GradleCommand) SetConfigPath(configPath string) *GradleCommand { return gc } -func (gc *GradleCommand) SetTasks(tasks string) *GradleCommand { +func (gc *GradleCommand) SetTasks(tasks []string) *GradleCommand { gc.tasks = tasks return gc } diff --git a/utils/gradle/utils.go b/utils/gradle/utils.go index 093e941c7..180a52a62 100644 --- a/utils/gradle/utils.go +++ b/utils/gradle/utils.go @@ -3,7 +3,6 @@ package gradleutils import ( "fmt" "path/filepath" - "strings" "github.com/jfrog/build-info-go/build" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" @@ -18,7 +17,7 @@ const ( useWrapper = "usewrapper" ) -func RunGradle(vConfig *viper.Viper, tasks, deployableArtifactsFile string, configuration *utils.BuildConfiguration, threads int, disableDeploy bool) error { +func RunGradle(vConfig *viper.Viper, tasks []string, deployableArtifactsFile string, configuration *utils.BuildConfiguration, threads int, disableDeploy bool) error { buildInfoService := utils.CreateBuildInfoService() buildName, err := configuration.GetBuildName() if err != nil { @@ -44,7 +43,7 @@ func RunGradle(vConfig *viper.Viper, tasks, deployableArtifactsFile string, conf if err != nil { return err } - gradleModule.SetExtractorDetails(dependencyLocalPath, filepath.Join(coreutils.GetCliPersistentTempDirPath(), utils.PropertiesTempPath), strings.Split(tasks, " "), wrapper, plugin, utils.DownloadExtractor, props) + gradleModule.SetExtractorDetails(dependencyLocalPath, filepath.Join(coreutils.GetCliPersistentTempDirPath(), utils.PropertiesTempPath), tasks, wrapper, plugin, utils.DownloadExtractor, props) return coreutils.ConvertExitCodeError(gradleModule.CalcDependencies()) } From 03601dc50757c025364b8f9e91635c3e62c321cb Mon Sep 17 00:00:00 2001 From: keegan morrissey Date: Fri, 30 Jun 2023 15:28:28 -0500 Subject: [PATCH 2/3] way for space to be include in values for sys properties in gradle --- utils/gradle/utils.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/gradle/utils.go b/utils/gradle/utils.go index 180a52a62..55089436c 100644 --- a/utils/gradle/utils.go +++ b/utils/gradle/utils.go @@ -68,6 +68,11 @@ func createGradleRunConfig(vConfig *viper.Viper, deployableArtifactsFile string, if err != nil { return } + + for key, value := range props { + props[key] = `"` + value + `"` + } + if deployableArtifactsFile != "" { // Save the path to a temp file, where buildinfo project will write the deployable artifacts details. props[utils.DeployableArtifacts] = fmt.Sprint(vConfig.Get(utils.DeployableArtifacts)) From 6f7b9112f224e21788f1058a8f0ae5357a9e72d1 Mon Sep 17 00:00:00 2001 From: keegan morrissey Date: Sun, 6 Aug 2023 17:33:24 -0500 Subject: [PATCH 3/3] adding additional change for gradle opts --- utils/gradle/utils.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/utils/gradle/utils.go b/utils/gradle/utils.go index 55089436c..2dc64da0c 100644 --- a/utils/gradle/utils.go +++ b/utils/gradle/utils.go @@ -2,7 +2,9 @@ package gradleutils import ( "fmt" + "os" "path/filepath" + "strings" "github.com/jfrog/build-info-go/build" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" @@ -39,11 +41,25 @@ func RunGradle(vConfig *viper.Viper, tasks []string, deployableArtifactsFile str if err != nil { return err } + var gradleOpts []string + if v := os.Getenv("GRADLE_OPTS"); v!=""{ + gradleOpts = strings.Fields(v) + } + if v, ok := props["buildInfoConfig.artifactoryResolutionEnabled"]; ok { + gradleOpts = append(gradleOpts, "-DbuildInfoConfig.artifactoryResolutionEnabled="+v) + } dependencyLocalPath, err := getGradleDependencyLocalPath() if err != nil { return err } - gradleModule.SetExtractorDetails(dependencyLocalPath, filepath.Join(coreutils.GetCliPersistentTempDirPath(), utils.PropertiesTempPath), tasks, wrapper, plugin, utils.DownloadExtractor, props) + gradleModule.SetExtractorDetails(dependencyLocalPath, + filepath.Join(coreutils.GetCliPersistentTempDirPath(), utils.PropertiesTempPath), + tasks, + wrapper, + plugin, + utils.DownloadExtractor, + props) + gradleModule.SetGradleOpts(gradleOpts...) return coreutils.ConvertExitCodeError(gradleModule.CalcDependencies()) }