From 917d6b49e3c853c7942abc5d65ec4a0f58afcd6a Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Wed, 26 Nov 2025 10:13:19 +0530 Subject: [PATCH 01/16] resolving merged changes --- buildtools/cli.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/buildtools/cli.go b/buildtools/cli.go index e3b9482eb..1c2248ded 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -631,6 +631,24 @@ func GradleCmd(c *cli.Context) (err error) { return err } + // do we need to restrict it for the artifactoryPublish command? + // FlexPack native mode for Gradle (bypasses config file requirements) + if os.Getenv("JFROG_RUN_NATIVE") == "true" { + log.Debug("Routing to Gradle FlexPack implementation") + if c.NArg() < 1 { + return cliutils.WrongNumberOfArgumentsHandler(c) + } + args := cliutils.ExtractCommand(c) + filteredGradleArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args) + if err != nil { + return err + } + + // Create Gradle command with FlexPack (no config file needed) + gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath("") + return commands.Exec(gradleCmd) + } + configFilePath, err := getProjectConfigPathOrThrow(project.Gradle, "gradle", "gradle-config") if err != nil { return err From 98967473363eb1fc228cce783be01c5431f112c0 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Wed, 26 Nov 2025 10:27:38 +0530 Subject: [PATCH 02/16] removing comment --- buildtools/cli.go | 1 - 1 file changed, 1 deletion(-) diff --git a/buildtools/cli.go b/buildtools/cli.go index 1c2248ded..90ba9cdb7 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -631,7 +631,6 @@ func GradleCmd(c *cli.Context) (err error) { return err } - // do we need to restrict it for the artifactoryPublish command? // FlexPack native mode for Gradle (bypasses config file requirements) if os.Getenv("JFROG_RUN_NATIVE") == "true" { log.Debug("Routing to Gradle FlexPack implementation") From 209cce3ff0f93e3cc889dee7875a19f52e65aa8d Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 11 Dec 2025 16:17:11 +0530 Subject: [PATCH 03/16] updating dependencies --- .../build/libs/minimal-example-1.0.jar | Bin 0 -> 743 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar diff --git a/testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar b/testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..1d6a7749b1289ad0bb76a5df61ae040d8583738f GIT binary patch literal 743 zcmWIWW@h1HVBp|j(2k!J%>V>UAOZ+Df!NnI#8KDN&rP41Apk|;rh2A#(m(~0KrDi+ z(AUw=)6F$FM9$QFt15_jQ+eY!qwhcQ zqXt{FX09mFe19myT{SRr-;_ev?$f6iU9b#vx;i~gZNAPj#=Z+n-`~2-xH)*mt}C8S zZa1v!*sE91{~a=S)|=$!Ro6KbHh6kSC$Ba=AGP_g{e_3?v$rd3nL7Eg{=rD~oa?6! z>IZl;GKnzbj$lyGGcX7+ymbW8@aRU@h92D@#UQYxQ4>hQwIM}5x(OiFu#^RgV+a6Q pTn1#qVjNu;dW^&LEoq#Gqzfhf1H4(;K+0Hv@Dq@}4@@i!3;-&#+_wM# literal 0 HcmV?d00001 From 086046d0fbaca8f68ac1ffa2a050989971ce04dc Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Fri, 12 Dec 2025 15:07:54 +0530 Subject: [PATCH 04/16] checking config file exist or not --- buildtools/cli.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/buildtools/cli.go b/buildtools/cli.go index 90ba9cdb7..8f1a51f57 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -631,8 +631,14 @@ func GradleCmd(c *cli.Context) (err error) { return err } + nativeMode := os.Getenv("JFROG_RUN_NATIVE") == "true" + configFilePath, configExists, err := project.GetProjectConfFilePath(project.Gradle) + if err != nil { + return err + } + // FlexPack native mode for Gradle (bypasses config file requirements) - if os.Getenv("JFROG_RUN_NATIVE") == "true" { + if nativeMode && !configExists { log.Debug("Routing to Gradle FlexPack implementation") if c.NArg() < 1 { return cliutils.WrongNumberOfArgumentsHandler(c) @@ -648,9 +654,11 @@ func GradleCmd(c *cli.Context) (err error) { return commands.Exec(gradleCmd) } - configFilePath, err := getProjectConfigPathOrThrow(project.Gradle, "gradle", "gradle-config") - if err != nil { - return err + // If config file is missing and not in native mode, return the standard missing-config error. + if !configExists { + if configFilePath, err = getProjectConfigPathOrThrow(project.Gradle, "gradle", "gradle-config"); err != nil { + return err + } } // Found a config file. Continue as native command. From 8818c2193a4b73af60f97fb212555a1d97aa136d Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Wed, 17 Dec 2025 22:19:21 +0530 Subject: [PATCH 05/16] added test cases --- buildtools/cli.go | 58 ++- gradle_test.go | 668 +++++++++++++++++++++++++++++++- utils/buildinfo/buildinfo.go | 3 +- utils/cliutils/commandsflags.go | 2 +- 4 files changed, 715 insertions(+), 16 deletions(-) diff --git a/buildtools/cli.go b/buildtools/cli.go index 8f1a51f57..bee1987e2 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -15,6 +15,7 @@ import ( "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container/strategies" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup" + artutils "github.com/jfrog/jfrog-cli-artifactory/artifactory/utils" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils" "github.com/jfrog/jfrog-cli-security/utils/techutils" @@ -560,8 +561,13 @@ func MvnCmd(c *cli.Context) (err error) { return err } - // FlexPack bypasses all config file requirements - if os.Getenv("JFROG_RUN_NATIVE") == "true" { + configFilePath, configExists, err := project.GetProjectConfFilePath(project.Maven) + if err != nil { + return err + } + + // FlexPack bypasses all config file requirements (only when no config exists) + if artutils.ShouldRunNative(configFilePath) && !configExists { log.Debug("Routing to Maven native implementation") // Extract build configuration for FlexPack args := cliutils.ExtractCommand(c) @@ -574,9 +580,11 @@ func MvnCmd(c *cli.Context) (err error) { return commands.Exec(mvnCmd) } - configFilePath, err := getProjectConfigPathOrThrow(project.Maven, "mvn", "mvn-config") - if err != nil { - return err + // If config file is missing and not in native mode, return the standard missing-config error. + if !configExists { + if configFilePath, err = getProjectConfigPathOrThrow(project.Maven, "mvn", "mvn-config"); err != nil { + return err + } } if c.NArg() < 1 { @@ -631,11 +639,35 @@ func GradleCmd(c *cli.Context) (err error) { return err } - nativeMode := os.Getenv("JFROG_RUN_NATIVE") == "true" + resolveServer := func(args []string) ([]string, *coreConfig.ServerDetails, error) { + cleanedArgs, serverID, err := coreutils.ExtractServerIdFromCommand(args) + if err != nil { + return nil, nil, fmt.Errorf("failed to extract server ID: %w", err) + } + + if serverID == "" { + serverDetails, err := coreConfig.GetDefaultServerConf() + if err != nil { + return cleanedArgs, nil, err + } + if serverDetails == nil { + return cleanedArgs, nil, fmt.Errorf("no default server configuration found. Please configure a server using 'jfrog config add' or specify a server using --server-id") + } + return cleanedArgs, serverDetails, nil + } + + serverDetails, err := coreConfig.GetSpecificConfig(serverID, true, true) + if err != nil { + return nil, nil, fmt.Errorf("failed to get server configuration for ID '%s': %w", serverID, err) + } + return cleanedArgs, serverDetails, nil + } + configFilePath, configExists, err := project.GetProjectConfFilePath(project.Gradle) if err != nil { return err } + nativeMode := artutils.ShouldRunNative(configFilePath) // FlexPack native mode for Gradle (bypasses config file requirements) if nativeMode && !configExists { @@ -644,13 +676,17 @@ func GradleCmd(c *cli.Context) (err error) { return cliutils.WrongNumberOfArgumentsHandler(c) } args := cliutils.ExtractCommand(c) + args, serverDetails, err := resolveServer(args) + if err != nil { + return err + } filteredGradleArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args) if err != nil { return err } // Create Gradle command with FlexPack (no config file needed) - gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath("") + gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath("").SetServerDetails(serverDetails) return commands.Exec(gradleCmd) } @@ -666,6 +702,10 @@ func GradleCmd(c *cli.Context) (err error) { return cliutils.WrongNumberOfArgumentsHandler(c) } args := cliutils.ExtractCommand(c) + args, serverDetails, err := resolveServer(args) + if err != nil { + return err + } filteredGradleArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args) if err != nil { return err @@ -697,7 +737,7 @@ func GradleCmd(c *cli.Context) (err error) { return err } printDeploymentView := log.IsStdErrTerminal() - gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath(configFilePath).SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetXrayScan(xrayScan).SetScanOutputFormat(scanOutputFormat) + gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath(configFilePath).SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetXrayScan(xrayScan).SetScanOutputFormat(scanOutputFormat).SetServerDetails(serverDetails) err = commands.Exec(gradleCmd) result := gradleCmd.Result() defer cliutils.CleanupResult(result, &err) @@ -1536,7 +1576,7 @@ func pythonCmd(c *cli.Context, projectType project.ProjectType) error { } // FlexPack native mode for Poetry (bypasses config file requirements) - if os.Getenv("JFROG_RUN_NATIVE") == "true" && projectType == project.Poetry { + if artutils.ShouldRunNative("") && projectType == project.Poetry { log.Debug("Routing to Poetry native implementation") args := cliutils.ExtractCommand(c) filteredArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args) diff --git a/gradle_test.go b/gradle_test.go index 84a060c15..0d8925195 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -3,11 +3,6 @@ package main import ( "errors" "fmt" - "github.com/jfrog/gofrog/io" - "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle" - coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests" - "github.com/jfrog/jfrog-client-go/http/httpclient" - "github.com/stretchr/testify/require" "net/http" "os" "os/exec" @@ -15,6 +10,12 @@ import ( "strings" "testing" + "github.com/jfrog/gofrog/io" + "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle" + coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests" + "github.com/jfrog/jfrog-client-go/http/httpclient" + "github.com/stretchr/testify/require" + "github.com/jfrog/jfrog-cli/utils/cliutils" "github.com/jfrog/jfrog-client-go/utils/log" @@ -254,6 +255,648 @@ func TestSetupGradleCommand(t *testing.T) { } } +// TestGradleBuildWithFlexPack tests Gradle build with JFROG_RUN_NATIVE=true (FlexPack mode) +func TestGradleBuildWithFlexPack(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle without config file to trigger FlexPack mode + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath) + assert.NoError(t, err) + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackBuildInfo tests Gradle build info collection with JFROG_RUN_NATIVE=true +func TestGradleBuildWithFlexPackBuildInfo(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack build info test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle with build info (FlexPack mode - no config file) + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created with FlexPack dependencies + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate build info structure + buildInfo := publishedBuildInfo.BuildInfo + assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules") + if len(buildInfo.Modules) > 0 { + module := buildInfo.Modules[0] + assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") + assert.NotEmpty(t, module.Id, "Module should have ID") + + // FlexPack should collect dependencies + if len(module.Dependencies) > 0 { + // Validate dependency structure + for _, dep := range module.Dependencies { + assert.NotEmpty(t, dep.Id, "Dependency should have ID") + // FlexPack should provide checksums + hasChecksum := dep.Sha1 != "" || dep.Sha256 != "" || dep.Md5 != "" + assert.True(t, hasChecksum, "Dependency %s should have at least one checksum", dep.Id) + } + } + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackAndPublish tests Gradle publish with JFROG_RUN_NATIVE=true +func TestGradleBuildWithFlexPackAndPublish(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack publish test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-publish" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle with publish task (FlexPack mode - no config file) + // This tests that FlexPack correctly handles publish/artifactoryPublish tasks + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "publish", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + if err != nil { + // Publish may fail if not properly configured - that's OK for this test + // The important thing is that FlexPack mode was activated + t.Logf("Gradle publish command returned error (may be expected if publish not configured): %v", err) + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackFullValidation is the native equivalent of TestGradleBuildWithServerID +// It validates complete build info structure including module type validation +func TestGradleBuildWithFlexPackFullValidation(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack full validation test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-full" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle build with build info collection (FlexPack mode - no config file) + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate build info structure - FlexPack collects dependencies only (no artifacts without deployment) + buildInfo := publishedBuildInfo.BuildInfo + assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules") + if len(buildInfo.Modules) > 0 { + module := buildInfo.Modules[0] + // Validate module type is Gradle + assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") + assert.NotEmpty(t, module.Id, "Module should have ID") + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackProjectWithPlugin tests FlexPack with the projectwithplugin test project +// This is the native equivalent of TestGradleBuildWithServerIDWithUsesPlugin but runs in FlexPack mode +func TestGradleBuildWithFlexPackProjectWithPlugin(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack projectwithplugin test") + } + + // Create gradle project with plugin configuration + buildGradlePath := createGradleProject(t, "projectwithplugin") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-plugin" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle build (FlexPack mode - no config file, plugin is ignored in native mode) + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate build info structure + buildInfo := publishedBuildInfo.BuildInfo + assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules") + if len(buildInfo.Modules) > 0 { + module := buildInfo.Modules[0] + assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") + assert.NotEmpty(t, module.Id, "Module should have ID") + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackMultipleTasks tests FlexPack with multiple Gradle tasks +// Similar to how traditional tests run "clean artifactoryPublish" +func TestGradleBuildWithFlexPackMultipleTasks(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack multiple tasks test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-multi" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle with multiple tasks (FlexPack mode) + err := runJfrogCliWithoutAssertion("gradle", "clean", "compileJava", "test", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate build info structure + assert.NotEmpty(t, publishedBuildInfo.BuildInfo.Modules, "Build info should have modules") + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackNoBuildInfo tests FlexPack without build info collection +// This is the native equivalent of running gradle without --build-name/--build-number +func TestGradleBuildWithFlexPackNoBuildInfo(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack no build info test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle without build info flags (FlexPack mode - just execute gradle) + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath) + assert.NoError(t, err) + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackTestTask tests 'jf gradle test' with JFROG_RUN_NATIVE=true +func TestGradleBuildWithFlexPackTestTask(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack test task test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-test" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle test task (FlexPack mode) + err := runJfrogCliWithoutAssertion("gradle", "clean", "test", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + // Test may fail if no tests exist, but command should execute + if err != nil { + t.Logf("Gradle test command returned error (may be expected if no tests exist): %v", err) + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackEnvVars tests build info collection using JFROG_CLI_BUILD_NAME and JFROG_CLI_BUILD_NUMBER +func TestGradleBuildWithFlexPackEnvVars(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack env vars test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-env" + buildNumber := "123" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Set build name and number via environment variables + setBuildNameCallback := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_CLI_BUILD_NAME", buildName) + defer setBuildNameCallback() + setBuildNumberCallback := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_CLI_BUILD_NUMBER", buildNumber) + defer setBuildNumberCallback() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle without explicit build name/number flags - should use env vars + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created with the env var values + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found with env var build name/number") + return + } + + // Validate build info has the correct build name and number + assert.Equal(t, buildName, publishedBuildInfo.BuildInfo.Name, "Build name should match env var") + assert.Equal(t, buildNumber, publishedBuildInfo.BuildInfo.Number, "Build number should match env var") + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackInvalidArgs tests 'jf gradle build' with invalid Gradle arguments +func TestGradleBuildWithFlexPackInvalidArgs(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack invalid args test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle with invalid task name - should fail + err := runJfrogCliWithoutAssertion("gradle", "nonExistentTask", "-b"+buildGradlePath) + assert.Error(t, err, "Gradle should fail with invalid task name") + + // Run gradle with invalid option + err = runJfrogCliWithoutAssertion("gradle", "build", "--invalid-option-xyz", "-b"+buildGradlePath) + assert.Error(t, err, "Gradle should fail with invalid option") + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackDependencySHA validates that dependency SHA checksums are collected +func TestGradleBuildWithFlexPackDependencySHA(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack dependency SHA test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-sha" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle build + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate that dependencies have SHA checksums + assert.NotEmpty(t, publishedBuildInfo.BuildInfo.Modules, "Build info should have modules") + for _, module := range publishedBuildInfo.BuildInfo.Modules { + for _, dep := range module.Dependencies { + // FlexPack should provide at least one SHA checksum + hasSHA := dep.Sha1 != "" || dep.Sha256 != "" + assert.True(t, hasSHA, "Dependency %s should have SHA1 or SHA256 checksum", dep.Id) + } + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackDependencyScope validates that dependency scopes/configurations are collected +func TestGradleBuildWithFlexPackDependencyScope(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack dependency scope test") + } + + buildGradlePath := createGradleProject(t, "gradleproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-scope" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle build + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate that dependencies have scopes + assert.NotEmpty(t, publishedBuildInfo.BuildInfo.Modules, "Build info should have modules") + for _, module := range publishedBuildInfo.BuildInfo.Modules { + for _, dep := range module.Dependencies { + // FlexPack should collect scopes (Gradle configurations) + assert.NotEmpty(t, dep.Scopes, "Dependency %s should have scopes/configurations", dep.Id) + } + } + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackFallback verifies that gradle falls back to traditional approach +// when JFROG_RUN_NATIVE is not set (covered by existing traditional tests, this is explicit verification) +func TestGradleBuildWithFlexPackFallback(t *testing.T) { + initGradleTest(t) + + // Explicitly ensure JFROG_RUN_NATIVE is NOT set + _ = os.Unsetenv("JFROG_RUN_NATIVE") + + buildGradlePath := createGradleProject(t, "gradleproject") + configFilePath := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "buildspecs", tests.GradleConfig) + destPath := filepath.Join(filepath.Dir(buildGradlePath), ".jfrog", "projects") + createConfigFile(destPath, configFilePath, t) + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-fallback" + buildNumber := "1" + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle with config file (traditional approach) + runJfrogCli(t, "gradle", "clean", "artifactoryPublish", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + + // Validate artifacts were deployed (traditional approach deploys to Artifactory) + searchSpec, err := tests.CreateSpec(tests.SearchAllGradle) + assert.NoError(t, err) + inttestutils.VerifyExistInArtifactory(tests.GetGradleDeployedArtifacts(), searchSpec, serverDetails, t) + + cleanGradleTest(t) +} + +// TestGradleHelpCommand verifies 'jf gradle --help' displays correct usage instructions +func TestGradleHelpCommand(t *testing.T) { + initGradleTest(t) + + // Run gradle help command + jfrogCli := coretests.NewJfrogCli(execMain, "jfrog", "") + err := jfrogCli.Exec("gradle", "--help") + // Help command should succeed + assert.NoError(t, err, "gradle --help should succeed") + + cleanGradleTest(t) +} + +// TestGradleBuildWithFlexPackKotlinDSL tests build info collection for Kotlin DSL (build.gradle.kts) +// Note: This test requires a Kotlin DSL project to be available +func TestGradleBuildWithFlexPackKotlinDSL(t *testing.T) { + initGradleTest(t) + + // Check if Gradle is available in the environment + if _, err := exec.LookPath("gradle"); err != nil { + t.Skip("Gradle not found in PATH, skipping Gradle FlexPack Kotlin DSL test") + } + + // Check if Kotlin DSL project exists + kotlinProjectPath := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", "kotlinproject") + if _, err := os.Stat(kotlinProjectPath); os.IsNotExist(err) { + t.Skip("Kotlin DSL project not found, skipping Kotlin DSL test") + } + + // Create gradle project with Kotlin DSL + buildGradlePath := createGradleProjectKotlin(t, "kotlinproject") + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) + defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) + + buildName := tests.GradleBuildName + "-flexpack-kotlin" + buildNumber := "1" + + // Set environment for native FlexPack implementation + setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") + defer setEnvCallBack() + + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") + + // Run gradle build + err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) + assert.NoError(t, err) + + // Publish build info + assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) + + // Validate build info was created + publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) + if err != nil { + assert.NoError(t, err) + return + } + if !found { + assert.True(t, found, "build info was expected to be found") + return + } + + // Validate build info structure + buildInfo := publishedBuildInfo.BuildInfo + assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules") + if len(buildInfo.Modules) > 0 { + module := buildInfo.Modules[0] + assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") + } + + cleanGradleTest(t) +} + func createGradleProject(t *testing.T, projectName string) string { srcBuildFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "build.gradle") buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, "") @@ -266,10 +909,25 @@ func createGradleProject(t *testing.T, projectName string) string { return buildGradlePath } +// createGradleProjectKotlin creates a Kotlin DSL gradle project for testing +func createGradleProjectKotlin(t *testing.T, projectName string) string { + srcBuildFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "build.gradle.kts") + buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, "") + assert.NoError(t, err) + + srcSettingsFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "settings.gradle.kts") + _, err = tests.ReplaceTemplateVariables(srcSettingsFile, "") + assert.NoError(t, err) + + return buildGradlePath +} + func initGradleTest(t *testing.T) { if !*tests.TestGradle { t.Skip("Skipping Gradle test. To run Gradle test add the '-test.gradle=true' option.") } + // Ensure clean state - unset native flag so traditional tests run correctly + _ = os.Unsetenv("JFROG_RUN_NATIVE") createJfrogHomeConfig(t, true) } diff --git a/utils/buildinfo/buildinfo.go b/utils/buildinfo/buildinfo.go index 1dedee1fb..4952c9a55 100644 --- a/utils/buildinfo/buildinfo.go +++ b/utils/buildinfo/buildinfo.go @@ -12,6 +12,7 @@ import ( buildinfo "github.com/jfrog/build-info-go/entities" "github.com/jfrog/build-info-go/flexpack" "github.com/jfrog/gofrog/crypto" + artutils "github.com/jfrog/jfrog-cli-artifactory/artifactory/utils" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" buildUtils "github.com/jfrog/jfrog-cli-core/v2/common/build" "github.com/jfrog/jfrog-cli-core/v2/common/project" @@ -302,7 +303,7 @@ func extractRepositoryConfigForProject(projectType project.ProjectType) (*projec log.Debug("Extracting repository config for project type") // In native mode, completely ignore YAML and infer from pyproject.toml - if os.Getenv("JFROG_RUN_NATIVE") == "true" { + if artutils.ShouldRunNative("") { log.Info("Native mode enabled: inferring Poetry config from pyproject.toml") return inferPoetryConfigFromToml(projectType) } diff --git a/utils/cliutils/commandsflags.go b/utils/cliutils/commandsflags.go index c56741c43..7c3e1ebc2 100644 --- a/utils/cliutils/commandsflags.go +++ b/utils/cliutils/commandsflags.go @@ -1865,7 +1865,7 @@ var commandFlags = map[string][]string{ BuildName, BuildNumber, deploymentThreads, InsecureTls, Project, detailedSummary, xrayScan, xrOutput, }, Gradle: { - BuildName, BuildNumber, deploymentThreads, Project, detailedSummary, xrayScan, xrOutput, + BuildName, BuildNumber, deploymentThreads, Project, serverId, detailedSummary, xrayScan, xrOutput, }, Docker: { BuildName, BuildNumber, module, Project, From 0fcfcf50c9c7e6d23149827b33b6899c0d1d9262 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 00:08:23 +0530 Subject: [PATCH 06/16] adding test cases --- gradle_test.go | 61 ++----------------- testdata/gradle/gradleproject/build.gradle | 4 ++ .../src/main/java/example/Example.java | 14 +++++ 3 files changed, 22 insertions(+), 57 deletions(-) create mode 100644 testdata/gradle/gradleproject/src/main/java/example/Example.java diff --git a/gradle_test.go b/gradle_test.go index 0d8925195..acae7d2e9 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -135,7 +135,8 @@ func TestGradleBuildWithServerID(t *testing.T) { return } buildInfo := publishedBuildInfo.BuildInfo - validateBuildInfo(buildInfo, t, 0, 1, gradleModuleId, buildinfo.Gradle) + // Expect 1 dependency (junit:4.7) since the project has source code using JUnit + validateBuildInfo(buildInfo, t, 1, 1, gradleModuleId, buildinfo.Gradle) cleanGradleTest(t) } @@ -184,7 +185,8 @@ func TestGradleBuildWithServerIDAndDetailedSummary(t *testing.T) { return } buildInfo := publishedBuildInfo.BuildInfo - validateBuildInfo(buildInfo, t, 0, 1, gradleModuleId, buildinfo.Gradle) + // Expect 1 dependency (junit:4.7) since the project has source code using JUnit + validateBuildInfo(buildInfo, t, 1, 1, gradleModuleId, buildinfo.Gradle) cleanGradleTest(t) } @@ -436,61 +438,6 @@ func TestGradleBuildWithFlexPackFullValidation(t *testing.T) { cleanGradleTest(t) } -// TestGradleBuildWithFlexPackProjectWithPlugin tests FlexPack with the projectwithplugin test project -// This is the native equivalent of TestGradleBuildWithServerIDWithUsesPlugin but runs in FlexPack mode -func TestGradleBuildWithFlexPackProjectWithPlugin(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack projectwithplugin test") - } - - // Create gradle project with plugin configuration - buildGradlePath := createGradleProject(t, "projectwithplugin") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-plugin" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle build (FlexPack mode - no config file, plugin is ignored in native mode) - err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - assert.NoError(t, err) - - // Publish build info - assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) - - // Validate build info was created - publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) - if err != nil { - assert.NoError(t, err) - return - } - if !found { - assert.True(t, found, "build info was expected to be found") - return - } - - // Validate build info structure - buildInfo := publishedBuildInfo.BuildInfo - assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules") - if len(buildInfo.Modules) > 0 { - module := buildInfo.Modules[0] - assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") - assert.NotEmpty(t, module.Id, "Module should have ID") - } - - cleanGradleTest(t) -} - // TestGradleBuildWithFlexPackMultipleTasks tests FlexPack with multiple Gradle tasks // Similar to how traditional tests run "clean artifactoryPublish" func TestGradleBuildWithFlexPackMultipleTasks(t *testing.T) { diff --git a/testdata/gradle/gradleproject/build.gradle b/testdata/gradle/gradleproject/build.gradle index eeac79246..55a0d6e90 100644 --- a/testdata/gradle/gradleproject/build.gradle +++ b/testdata/gradle/gradleproject/build.gradle @@ -1,6 +1,10 @@ apply plugin: 'groovy' apply plugin: 'idea' +repositories { + mavenCentral() +} + dependencies { implementation "junit:junit:4.7" } diff --git a/testdata/gradle/gradleproject/src/main/java/example/Example.java b/testdata/gradle/gradleproject/src/main/java/example/Example.java new file mode 100644 index 000000000..b82e7d562 --- /dev/null +++ b/testdata/gradle/gradleproject/src/main/java/example/Example.java @@ -0,0 +1,14 @@ +package example; + +import org.junit.Assert; + +/** + * Simple example class that uses JUnit to ensure the dependency is resolved. + */ +public class Example { + public boolean isTrue() { + Assert.assertTrue(true); + return true; + } +} + From 0ad7f42cc9b7c7bdeeb6d9b01ba2c815e43d584a Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 13:26:26 +0530 Subject: [PATCH 07/16] Delete testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar --- .../build/libs/minimal-example-1.0.jar | Bin 743 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar diff --git a/testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar b/testdata/gradle/gradleproject/build/libs/minimal-example-1.0.jar deleted file mode 100644 index 1d6a7749b1289ad0bb76a5df61ae040d8583738f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 743 zcmWIWW@h1HVBp|j(2k!J%>V>UAOZ+Df!NnI#8KDN&rP41Apk|;rh2A#(m(~0KrDi+ z(AUw=)6F$FM9$QFt15_jQ+eY!qwhcQ zqXt{FX09mFe19myT{SRr-;_ev?$f6iU9b#vx;i~gZNAPj#=Z+n-`~2-xH)*mt}C8S zZa1v!*sE91{~a=S)|=$!Ro6KbHh6kSC$Ba=AGP_g{e_3?v$rd3nL7Eg{=rD~oa?6! z>IZl;GKnzbj$lyGGcX7+ymbW8@aRU@h92D@#UQYxQ4>hQwIM}5x(OiFu#^RgV+a6Q pTn1#qVjNu;dW^&LEoq#Gqzfhf1H4(;K+0Hv@Dq@}4@@i!3;-&#+_wM# From 5e3e2ace191e6ee16489667ff97f4417c721da58 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 13:44:18 +0530 Subject: [PATCH 08/16] fixing the test case --- gradle_test.go | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/gradle_test.go b/gradle_test.go index acae7d2e9..d07b786ff 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -845,12 +845,20 @@ func TestGradleBuildWithFlexPackKotlinDSL(t *testing.T) { } func createGradleProject(t *testing.T, projectName string) string { - srcBuildFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "build.gradle") - buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, "") + // Copy the entire project directory including source files + projectSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName) + projectTarget := filepath.Join(tests.Temp, projectName) + err := io.CopyDir(projectSrc, projectTarget, true, nil) assert.NoError(t, err) - srcSettingsFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "settings.gradle") - _, err = tests.ReplaceTemplateVariables(srcSettingsFile, "") + // Replace template variables in build.gradle + srcBuildFile := filepath.Join(projectTarget, "build.gradle") + buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, projectTarget) + assert.NoError(t, err) + + // Replace template variables in settings.gradle + srcSettingsFile := filepath.Join(projectTarget, "settings.gradle") + _, err = tests.ReplaceTemplateVariables(srcSettingsFile, projectTarget) assert.NoError(t, err) return buildGradlePath @@ -858,12 +866,20 @@ func createGradleProject(t *testing.T, projectName string) string { // createGradleProjectKotlin creates a Kotlin DSL gradle project for testing func createGradleProjectKotlin(t *testing.T, projectName string) string { - srcBuildFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "build.gradle.kts") - buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, "") + // Copy the entire project directory including source files + projectSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName) + projectTarget := filepath.Join(tests.Temp, projectName) + err := io.CopyDir(projectSrc, projectTarget, true, nil) + assert.NoError(t, err) + + // Replace template variables in build.gradle.kts + srcBuildFile := filepath.Join(projectTarget, "build.gradle.kts") + buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, projectTarget) assert.NoError(t, err) - srcSettingsFile := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName, "settings.gradle.kts") - _, err = tests.ReplaceTemplateVariables(srcSettingsFile, "") + // Replace template variables in settings.gradle.kts + srcSettingsFile := filepath.Join(projectTarget, "settings.gradle.kts") + _, err = tests.ReplaceTemplateVariables(srcSettingsFile, projectTarget) assert.NoError(t, err) return buildGradlePath From 898bd25ee8527fc6104e245ec7ff1fac0248be5a Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 14:22:41 +0530 Subject: [PATCH 09/16] adding test case --- .../src/main/java/example/Example.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testdata/gradle/gradleproject/src/main/java/example/Example.java b/testdata/gradle/gradleproject/src/main/java/example/Example.java index b82e7d562..9827ad7d5 100644 --- a/testdata/gradle/gradleproject/src/main/java/example/Example.java +++ b/testdata/gradle/gradleproject/src/main/java/example/Example.java @@ -1,14 +1,19 @@ package example; -import org.junit.Assert; - /** - * Simple example class that uses JUnit to ensure the dependency is resolved. + * Simple example class for the gradle test project. + * Note: We intentionally don't use JUnit here because dependency resolution + * may not work when the JFrog Gradle plugin configures the resolver to use + * the test Artifactory repository (which may not have JUnit cached). */ public class Example { public boolean isTrue() { - Assert.assertTrue(true); return true; } + + public static void main(String[] args) { + Example example = new Example(); + System.out.println("Example.isTrue() = " + example.isTrue()); + } } From d7dd68aea5a1d2dd72b4f8fb788222b21fa2a599 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 14:55:50 +0530 Subject: [PATCH 10/16] compacting gradle test file --- buildtools/cli.go | 6 +- gradle_test.go | 353 +++++----------------------------------------- main_test.go | 4 +- 3 files changed, 38 insertions(+), 325 deletions(-) diff --git a/buildtools/cli.go b/buildtools/cli.go index bee1987e2..b3c4d963b 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -702,10 +702,6 @@ func GradleCmd(c *cli.Context) (err error) { return cliutils.WrongNumberOfArgumentsHandler(c) } args := cliutils.ExtractCommand(c) - args, serverDetails, err := resolveServer(args) - if err != nil { - return err - } filteredGradleArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args) if err != nil { return err @@ -737,7 +733,7 @@ func GradleCmd(c *cli.Context) (err error) { return err } printDeploymentView := log.IsStdErrTerminal() - gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath(configFilePath).SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetXrayScan(xrayScan).SetScanOutputFormat(scanOutputFormat).SetServerDetails(serverDetails) + gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath(configFilePath).SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetXrayScan(xrayScan).SetScanOutputFormat(scanOutputFormat) err = commands.Exec(gradleCmd) result := gradleCmd.Result() defer cliutils.CleanupResult(result, &err) diff --git a/gradle_test.go b/gradle_test.go index d07b786ff..bbdd319bd 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -333,220 +333,21 @@ func TestGradleBuildWithFlexPackBuildInfo(t *testing.T) { assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") assert.NotEmpty(t, module.Id, "Module should have ID") - // FlexPack should collect dependencies - if len(module.Dependencies) > 0 { - // Validate dependency structure - for _, dep := range module.Dependencies { - assert.NotEmpty(t, dep.Id, "Dependency should have ID") - // FlexPack should provide checksums - hasChecksum := dep.Sha1 != "" || dep.Sha256 != "" || dep.Md5 != "" - assert.True(t, hasChecksum, "Dependency %s should have at least one checksum", dep.Id) - } + // FlexPack should collect dependencies with scopes and checksums. + assert.NotEmpty(t, module.Dependencies, "FlexPack build info should include dependencies") + for _, dep := range module.Dependencies { + assert.NotEmpty(t, dep.Id, "Dependency should have ID") + // FlexPack should provide checksums + hasChecksum := dep.Sha1 != "" || dep.Sha256 != "" || dep.Md5 != "" + assert.True(t, hasChecksum, "Dependency %s should have at least one checksum", dep.Id) + // FlexPack should provide scopes (Gradle configurations) + assert.NotEmpty(t, dep.Scopes, "Dependency %s should have scopes/configurations", dep.Id) } } cleanGradleTest(t) } -// TestGradleBuildWithFlexPackAndPublish tests Gradle publish with JFROG_RUN_NATIVE=true -func TestGradleBuildWithFlexPackAndPublish(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack publish test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-publish" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle with publish task (FlexPack mode - no config file) - // This tests that FlexPack correctly handles publish/artifactoryPublish tasks - err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "publish", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - if err != nil { - // Publish may fail if not properly configured - that's OK for this test - // The important thing is that FlexPack mode was activated - t.Logf("Gradle publish command returned error (may be expected if publish not configured): %v", err) - } - - cleanGradleTest(t) -} - -// TestGradleBuildWithFlexPackFullValidation is the native equivalent of TestGradleBuildWithServerID -// It validates complete build info structure including module type validation -func TestGradleBuildWithFlexPackFullValidation(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack full validation test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-full" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle build with build info collection (FlexPack mode - no config file) - err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - assert.NoError(t, err) - - // Publish build info - assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) - - // Validate build info was created - publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) - if err != nil { - assert.NoError(t, err) - return - } - if !found { - assert.True(t, found, "build info was expected to be found") - return - } - - // Validate build info structure - FlexPack collects dependencies only (no artifacts without deployment) - buildInfo := publishedBuildInfo.BuildInfo - assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules") - if len(buildInfo.Modules) > 0 { - module := buildInfo.Modules[0] - // Validate module type is Gradle - assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle") - assert.NotEmpty(t, module.Id, "Module should have ID") - } - - cleanGradleTest(t) -} - -// TestGradleBuildWithFlexPackMultipleTasks tests FlexPack with multiple Gradle tasks -// Similar to how traditional tests run "clean artifactoryPublish" -func TestGradleBuildWithFlexPackMultipleTasks(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack multiple tasks test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-multi" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle with multiple tasks (FlexPack mode) - err := runJfrogCliWithoutAssertion("gradle", "clean", "compileJava", "test", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - assert.NoError(t, err) - - // Publish build info - assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) - - // Validate build info was created - publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) - if err != nil { - assert.NoError(t, err) - return - } - if !found { - assert.True(t, found, "build info was expected to be found") - return - } - - // Validate build info structure - assert.NotEmpty(t, publishedBuildInfo.BuildInfo.Modules, "Build info should have modules") - - cleanGradleTest(t) -} - -// TestGradleBuildWithFlexPackNoBuildInfo tests FlexPack without build info collection -// This is the native equivalent of running gradle without --build-name/--build-number -func TestGradleBuildWithFlexPackNoBuildInfo(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack no build info test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle without build info flags (FlexPack mode - just execute gradle) - err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath) - assert.NoError(t, err) - - cleanGradleTest(t) -} - -// TestGradleBuildWithFlexPackTestTask tests 'jf gradle test' with JFROG_RUN_NATIVE=true -func TestGradleBuildWithFlexPackTestTask(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack test task test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-test" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle test task (FlexPack mode) - err := runJfrogCliWithoutAssertion("gradle", "clean", "test", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - // Test may fail if no tests exist, but command should execute - if err != nil { - t.Logf("Gradle test command returned error (may be expected if no tests exist): %v", err) - } - - cleanGradleTest(t) -} - // TestGradleBuildWithFlexPackEnvVars tests build info collection using JFROG_CLI_BUILD_NAME and JFROG_CLI_BUILD_NUMBER func TestGradleBuildWithFlexPackEnvVars(t *testing.T) { initGradleTest(t) @@ -632,113 +433,6 @@ func TestGradleBuildWithFlexPackInvalidArgs(t *testing.T) { cleanGradleTest(t) } -// TestGradleBuildWithFlexPackDependencySHA validates that dependency SHA checksums are collected -func TestGradleBuildWithFlexPackDependencySHA(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack dependency SHA test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-sha" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle build - err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - assert.NoError(t, err) - - // Publish build info - assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) - - // Validate build info was created - publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) - if err != nil { - assert.NoError(t, err) - return - } - if !found { - assert.True(t, found, "build info was expected to be found") - return - } - - // Validate that dependencies have SHA checksums - assert.NotEmpty(t, publishedBuildInfo.BuildInfo.Modules, "Build info should have modules") - for _, module := range publishedBuildInfo.BuildInfo.Modules { - for _, dep := range module.Dependencies { - // FlexPack should provide at least one SHA checksum - hasSHA := dep.Sha1 != "" || dep.Sha256 != "" - assert.True(t, hasSHA, "Dependency %s should have SHA1 or SHA256 checksum", dep.Id) - } - } - - cleanGradleTest(t) -} - -// TestGradleBuildWithFlexPackDependencyScope validates that dependency scopes/configurations are collected -func TestGradleBuildWithFlexPackDependencyScope(t *testing.T) { - initGradleTest(t) - - // Check if Gradle is available in the environment - if _, err := exec.LookPath("gradle"); err != nil { - t.Skip("Gradle not found in PATH, skipping Gradle FlexPack dependency scope test") - } - - buildGradlePath := createGradleProject(t, "gradleproject") - oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) - defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) - - buildName := tests.GradleBuildName + "-flexpack-scope" - buildNumber := "1" - - // Set environment for native FlexPack implementation - setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true") - defer setEnvCallBack() - - // Windows compatibility - buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") - - // Run gradle build - err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) - assert.NoError(t, err) - - // Publish build info - assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) - - // Validate build info was created - publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) - if err != nil { - assert.NoError(t, err) - return - } - if !found { - assert.True(t, found, "build info was expected to be found") - return - } - - // Validate that dependencies have scopes - assert.NotEmpty(t, publishedBuildInfo.BuildInfo.Modules, "Build info should have modules") - for _, module := range publishedBuildInfo.BuildInfo.Modules { - for _, dep := range module.Dependencies { - // FlexPack should collect scopes (Gradle configurations) - assert.NotEmpty(t, dep.Scopes, "Dependency %s should have scopes/configurations", dep.Id) - } - } - - cleanGradleTest(t) -} - // TestGradleBuildWithFlexPackFallback verifies that gradle falls back to traditional approach // when JFROG_RUN_NATIVE is not set (covered by existing traditional tests, this is explicit verification) func TestGradleBuildWithFlexPackFallback(t *testing.T) { @@ -848,18 +542,29 @@ func createGradleProject(t *testing.T, projectName string) string { // Copy the entire project directory including source files projectSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName) projectTarget := filepath.Join(tests.Temp, projectName) - err := io.CopyDir(projectSrc, projectTarget, true, nil) + // Use absolute paths to avoid issues when tests change working directory and pass relative -b flags. + // (e.g. running from tmp/gradleproject and passing -btmp/gradleproject/build.gradle results in duplicated paths) + var err error + projectTarget, err = filepath.Abs(projectTarget) + assert.NoError(t, err) + err = io.CopyDir(projectSrc, projectTarget, true, nil) assert.NoError(t, err) // Replace template variables in build.gradle srcBuildFile := filepath.Join(projectTarget, "build.gradle") buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, projectTarget) assert.NoError(t, err) + buildGradlePath, err = filepath.Abs(buildGradlePath) + assert.NoError(t, err) + assert.FileExists(t, buildGradlePath) // Replace template variables in settings.gradle srcSettingsFile := filepath.Join(projectTarget, "settings.gradle") - _, err = tests.ReplaceTemplateVariables(srcSettingsFile, projectTarget) + settingsPath, err := tests.ReplaceTemplateVariables(srcSettingsFile, projectTarget) assert.NoError(t, err) + settingsPath, err = filepath.Abs(settingsPath) + assert.NoError(t, err) + assert.FileExists(t, settingsPath) return buildGradlePath } @@ -869,18 +574,28 @@ func createGradleProjectKotlin(t *testing.T, projectName string) string { // Copy the entire project directory including source files projectSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "gradle", projectName) projectTarget := filepath.Join(tests.Temp, projectName) - err := io.CopyDir(projectSrc, projectTarget, true, nil) + // Use absolute paths to avoid issues when tests change working directory and pass relative -b flags. + var err error + projectTarget, err = filepath.Abs(projectTarget) + assert.NoError(t, err) + err = io.CopyDir(projectSrc, projectTarget, true, nil) assert.NoError(t, err) // Replace template variables in build.gradle.kts srcBuildFile := filepath.Join(projectTarget, "build.gradle.kts") buildGradlePath, err := tests.ReplaceTemplateVariables(srcBuildFile, projectTarget) assert.NoError(t, err) + buildGradlePath, err = filepath.Abs(buildGradlePath) + assert.NoError(t, err) + assert.FileExists(t, buildGradlePath) // Replace template variables in settings.gradle.kts srcSettingsFile := filepath.Join(projectTarget, "settings.gradle.kts") - _, err = tests.ReplaceTemplateVariables(srcSettingsFile, projectTarget) + settingsPath, err := tests.ReplaceTemplateVariables(srcSettingsFile, projectTarget) + assert.NoError(t, err) + settingsPath, err = filepath.Abs(settingsPath) assert.NoError(t, err) + assert.FileExists(t, settingsPath) return buildGradlePath } diff --git a/main_test.go b/main_test.go index 60ae5bf54..304b93dd6 100644 --- a/main_test.go +++ b/main_test.go @@ -263,8 +263,10 @@ func createConfigFile(inDir, configFilePath string, t *testing.T) { if _, err := os.Stat(inDir); os.IsNotExist(err) { assert.NoError(t, os.MkdirAll(inDir, 0o777)) } - _, err := tests.ReplaceTemplateVariables(configFilePath, inDir) + createdPath, err := tests.ReplaceTemplateVariables(configFilePath, inDir) assert.NoError(t, err) + // Fail early with a descriptive error if the config file wasn't actually created. + assert.FileExists(t, createdPath) } // Validate that all CLI commands' aliases are unique, and that two commands don't use the same alias. From 011be908f79be3426c81f85fe9c6900dc45c6539 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 15:15:03 +0530 Subject: [PATCH 11/16] path passing --- gradle_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gradle_test.go b/gradle_test.go index bbdd319bd..5c519ac38 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -430,7 +430,9 @@ func TestGradleBuildWithFlexPackInvalidArgs(t *testing.T) { err = runJfrogCliWithoutAssertion("gradle", "build", "--invalid-option-xyz", "-b"+buildGradlePath) assert.Error(t, err, "Gradle should fail with invalid option") - cleanGradleTest(t) + // This test intentionally fails before any deployment/build-info publish. + clientTestUtils.UnSetEnvAndAssert(t, coreutils.HomeDir) + tests.CleanFileSystem() } // TestGradleBuildWithFlexPackFallback verifies that gradle falls back to traditional approach @@ -557,6 +559,8 @@ func createGradleProject(t *testing.T, projectName string) string { buildGradlePath, err = filepath.Abs(buildGradlePath) assert.NoError(t, err) assert.FileExists(t, buildGradlePath) + // Gradle accepts forward slashes on all platforms, and this avoids Windows path edge-cases. + buildGradlePath = filepath.ToSlash(buildGradlePath) // Replace template variables in settings.gradle srcSettingsFile := filepath.Join(projectTarget, "settings.gradle") @@ -588,6 +592,8 @@ func createGradleProjectKotlin(t *testing.T, projectName string) string { buildGradlePath, err = filepath.Abs(buildGradlePath) assert.NoError(t, err) assert.FileExists(t, buildGradlePath) + // Gradle accepts forward slashes on all platforms, and this avoids Windows path edge-cases. + buildGradlePath = filepath.ToSlash(buildGradlePath) // Replace template variables in settings.gradle.kts srcSettingsFile := filepath.Join(projectTarget, "settings.gradle.kts") From e8f46edad06c5c3ab73b54d40415301db63553a6 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 15:30:51 +0530 Subject: [PATCH 12/16] catching gradle cmd output --- gradle_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gradle_test.go b/gradle_test.go index 5c519ac38..2e3e35b54 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -15,6 +15,7 @@ import ( coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests" "github.com/jfrog/jfrog-client-go/http/httpclient" "github.com/stretchr/testify/require" + urfavecli "github.com/urfave/cli" "github.com/jfrog/jfrog-cli/utils/cliutils" "github.com/jfrog/jfrog-client-go/utils/log" @@ -411,6 +412,11 @@ func TestGradleBuildWithFlexPackInvalidArgs(t *testing.T) { t.Skip("Gradle not found in PATH, skipping Gradle FlexPack invalid args test") } + // The CLI uses urfave/cli, which may call os.Exit(1) for ExitError (e.g., external tool exit code). + origOsExiter := urfavecli.OsExiter + urfavecli.OsExiter = func(code int) {} + defer func() { urfavecli.OsExiter = origOsExiter }() + buildGradlePath := createGradleProject(t, "gradleproject") oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) From 964323c99230cdef34bc973201e8443eddfc0dcd Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Thu, 18 Dec 2025 16:54:35 +0530 Subject: [PATCH 13/16] fixing test case to be compatible with 8+ --- gradle_test.go | 8 +++-- inttestutils/artifactory.go | 31 ++++++++++++++----- testdata/gradle/gradleproject/build.gradle | 16 ++++++++++ .../gradle/projectwithplugin/build.gradle | 16 ++++++++++ 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/gradle_test.go b/gradle_test.go index 2e3e35b54..5275bb70e 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -453,6 +453,12 @@ func TestGradleBuildWithFlexPackFallback(t *testing.T) { configFilePath := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "buildspecs", tests.GradleConfig) destPath := filepath.Join(filepath.Dir(buildGradlePath), ".jfrog", "projects") createConfigFile(destPath, configFilePath, t) + + // Create the search spec before changing the working directory. + // tests.GetTestResourcesPath() is relative ("testdata"), so creating the spec after chdir may fail on CI. + searchSpec, err := tests.CreateSpec(tests.SearchAllGradle) + require.NoError(t, err) + oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) @@ -466,8 +472,6 @@ func TestGradleBuildWithFlexPackFallback(t *testing.T) { runJfrogCli(t, "gradle", "clean", "artifactoryPublish", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber) // Validate artifacts were deployed (traditional approach deploys to Artifactory) - searchSpec, err := tests.CreateSpec(tests.SearchAllGradle) - assert.NoError(t, err) inttestutils.VerifyExistInArtifactory(tests.GetGradleDeployedArtifacts(), searchSpec, serverDetails, t) cleanGradleTest(t) diff --git a/inttestutils/artifactory.go b/inttestutils/artifactory.go index 29d6a5481..1448a4c99 100644 --- a/inttestutils/artifactory.go +++ b/inttestutils/artifactory.go @@ -9,6 +9,7 @@ import ( "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli/utils/tests" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // Verify the input slice exist in Artifactory @@ -17,23 +18,39 @@ import ( // serverDetails - Target Artifactory server details // t - Tests object func VerifyExistInArtifactory(expected []string, specFile string, serverDetails *config.ServerDetails, t *testing.T) { - results, _ := SearchInArtifactory(specFile, serverDetails, t) + results, err := SearchInArtifactory(specFile, serverDetails, t) + require.NoError(t, err) tests.CompareExpectedVsActual(expected, results, t) } func SearchInArtifactory(specFile string, serverDetails *config.ServerDetails, t *testing.T) ([]utils.SearchResult, error) { - searchSpec, _ := spec.CreateSpecFromFile(specFile, nil) + searchSpec, err := spec.CreateSpecFromFile(specFile, nil) + if err != nil { + return nil, err + } + if searchSpec == nil { + return nil, assert.AnError + } searchCmd := generic.NewSearchCommand() searchCmd.SetServerDetails(serverDetails).SetSpec(searchSpec) reader, err := searchCmd.Search() - assert.NoError(t, err) + if err != nil { + return nil, err + } var resultItems []utils.SearchResult readerNoDate, err := utils.SearchResultNoDate(reader) - assert.NoError(t, err) + if err != nil { + _ = reader.Close() + return nil, err + } for searchResult := new(utils.SearchResult); readerNoDate.NextRecord(searchResult) == nil; searchResult = new(utils.SearchResult) { resultItems = append(resultItems, *searchResult) } - assert.NoError(t, reader.Close(), "Couldn't close reader") - assert.NoError(t, reader.GetError(), "Couldn't get reader error") - return resultItems, err + if cerr := reader.Close(); cerr != nil { + return resultItems, cerr + } + if rerr := reader.GetError(); rerr != nil { + return resultItems, rerr + } + return resultItems, nil } diff --git a/testdata/gradle/gradleproject/build.gradle b/testdata/gradle/gradleproject/build.gradle index 55a0d6e90..cd34354f7 100644 --- a/testdata/gradle/gradleproject/build.gradle +++ b/testdata/gradle/gradleproject/build.gradle @@ -5,6 +5,22 @@ repositories { mavenCentral() } +// Gradle 8+ blocks http:// repositories unless allowInsecureProtocol=true is set. +// The JFrog Gradle integration (traditional extractor flow) may add an Artifactory resolver repo using http://localhost in tests. +// This block is safe across Gradle versions because it checks for the property before setting it. +allprojects { + repositories.all { repo -> + try { + def urlStr = repo.respondsTo('getUrl') && repo.url != null ? repo.url.toString() : "" + if (urlStr.startsWith("http://") && repo.hasProperty("allowInsecureProtocol")) { + repo.allowInsecureProtocol = true + } + } catch (Throwable ignored) { + // Best-effort; ignore repositories that don't support URL/allowInsecureProtocol. + } + } +} + dependencies { implementation "junit:junit:4.7" } diff --git a/testdata/gradle/projectwithplugin/build.gradle b/testdata/gradle/projectwithplugin/build.gradle index d06c9fa99..796fcb9b3 100644 --- a/testdata/gradle/projectwithplugin/build.gradle +++ b/testdata/gradle/projectwithplugin/build.gradle @@ -11,6 +11,22 @@ apply plugin: 'idea' apply plugin: 'com.jfrog.artifactory' apply plugin: 'maven-publish' +// Gradle 8+ blocks http:// repositories unless allowInsecureProtocol=true is set. +// The JFrog Gradle integration / Artifactory plugin may add an Artifactory resolver repo using http://localhost in tests. +// This block is safe across Gradle versions because it checks for the property before setting it. +allprojects { + repositories.all { repo -> + try { + def urlStr = repo.respondsTo('getUrl') && repo.url != null ? repo.url.toString() : "" + if (urlStr.startsWith("http://") && repo.hasProperty("allowInsecureProtocol")) { + repo.allowInsecureProtocol = true + } + } catch (Throwable ignored) { + // Best-effort; ignore repositories that don't support URL/allowInsecureProtocol. + } + } +} + version = 1.0 task initProject(description: 'Initialize project directory structure.') { doLast { From f2c7da0140562b65337c561818ee0b75d3ce1b17 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Mon, 5 Jan 2026 15:59:25 +0530 Subject: [PATCH 14/16] updating dependency --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index d04389f15..0d6a166a2 100644 --- a/go.sum +++ b/go.sum @@ -1218,8 +1218,6 @@ github.com/jfrog/jfrog-cli-application v1.0.2-0.20251231144110-a68c3ac11c7a h1:X github.com/jfrog/jfrog-cli-application v1.0.2-0.20251231144110-a68c3ac11c7a/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw= github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c h1:M+rFtXyVuK//0zDk7dtA3Yu8cKHJrT9us2pxYPsoIq4= github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c/go.mod h1:RneaDbEkoOAAHs6mAVxK666EB8GrNaCyNwyS452vVd0= -github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105134514-c8ec00cfd2cc h1:YOpq/LS+mQfeL2FQvyVxDvCLUx/dG1NG4Jh1QqjxRD8= -github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105134514-c8ec00cfd2cc/go.mod h1:REkU0OfnLYZbQIjD2Cg85DAVP0SRZuV/PxiDfCJiJOc= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105150109-78d708a6d70e h1:3zPWT3HDxBe9xxUZVBP77pLh9x++CR131Y9GXNeAGJM= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105150109-78d708a6d70e/go.mod h1:REkU0OfnLYZbQIjD2Cg85DAVP0SRZuV/PxiDfCJiJOc= github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251225153025-9d8ac181d615 h1:y5an0bojHL00ipHP1QuBUrVcP+XK+yZHHOJ/r1I0RUM= From 15005ef7f31e6e105ea956a523b52b1327eafca7 Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Tue, 6 Jan 2026 13:57:22 +0530 Subject: [PATCH 15/16] updating cli-artifactory and bi dependency --- go.mod | 4 ++-- go.sum | 8 ++++---- inttestutils/artifactory.go | 31 +++++++------------------------ main_test.go | 4 +--- 4 files changed, 14 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index a42f09b79..412fd548a 100644 --- a/go.mod +++ b/go.mod @@ -16,10 +16,10 @@ require ( github.com/docker/docker v28.5.2+incompatible github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 github.com/jfrog/archiver/v3 v3.6.1 - github.com/jfrog/build-info-go v1.13.1-0.20251230063402-e9f0a3564df1 + github.com/jfrog/build-info-go v1.13.1-0.20260106060835-a1a07c967546 github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-cli-application v1.0.2-0.20251231144110-a68c3ac11c7a - github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c + github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260106082024-e160d4dd8c43 github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105150109-78d708a6d70e github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251225153025-9d8ac181d615 github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e diff --git a/go.sum b/go.sum index 0d6a166a2..e3997a76d 100644 --- a/go.sum +++ b/go.sum @@ -1204,8 +1204,8 @@ github.com/jellydator/ttlcache/v3 v3.4.0 h1:YS4P125qQS0tNhtL6aeYkheEaB/m8HCqdMMP github.com/jellydator/ttlcache/v3 v3.4.0/go.mod h1:Hw9EgjymziQD3yGsQdf1FqFdpp7YjFMd4Srg5EJlgD4= github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI= github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw= -github.com/jfrog/build-info-go v1.13.1-0.20251230063402-e9f0a3564df1 h1:ZT/hph6QcpTi9Fam9MJiouJ6g0H8Hx9p2Mnah2zPnks= -github.com/jfrog/build-info-go v1.13.1-0.20251230063402-e9f0a3564df1/go.mod h1:+OCtMb22/D+u7Wne5lzkjJjaWr0LRZcHlDwTH86Mpwo= +github.com/jfrog/build-info-go v1.13.1-0.20260106060835-a1a07c967546 h1:fgwqFjfRJ/P9tmk0xPO3FE3gXeHMFFoBV7MOIlcDRc0= +github.com/jfrog/build-info-go v1.13.1-0.20260106060835-a1a07c967546/go.mod h1:+OCtMb22/D+u7Wne5lzkjJjaWr0LRZcHlDwTH86Mpwo= github.com/jfrog/froggit-go v1.20.6 h1:Xp7+LlEh0m1KGrQstb+u0aGfjRUtv1eh9xQBV3571jQ= github.com/jfrog/froggit-go v1.20.6/go.mod h1:obSG1SlsWjktkuqmKtpq7MNTTL63e0ot+ucTnlOMV88= github.com/jfrog/go-mockhttp v0.3.1 h1:/wac8v4GMZx62viZmv4wazB5GNKs+GxawuS1u3maJH8= @@ -1216,8 +1216,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-application v1.0.2-0.20251231144110-a68c3ac11c7a h1:XoJ3w2AFi7zniimALNK3idw9bzY9MwB/FM45TMgxYAY= github.com/jfrog/jfrog-cli-application v1.0.2-0.20251231144110-a68c3ac11c7a/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c h1:M+rFtXyVuK//0zDk7dtA3Yu8cKHJrT9us2pxYPsoIq4= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c/go.mod h1:RneaDbEkoOAAHs6mAVxK666EB8GrNaCyNwyS452vVd0= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260106082024-e160d4dd8c43 h1:GXj/A+EXsPPJQmvfWq4NeT7R8wSEO0bHYQM18lY3YhE= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260106082024-e160d4dd8c43/go.mod h1:blx8Hf2ohjzfyS0sbovtWXpzYW4CT/tEHO37+0MWsco= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105150109-78d708a6d70e h1:3zPWT3HDxBe9xxUZVBP77pLh9x++CR131Y9GXNeAGJM= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260105150109-78d708a6d70e/go.mod h1:REkU0OfnLYZbQIjD2Cg85DAVP0SRZuV/PxiDfCJiJOc= github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251225153025-9d8ac181d615 h1:y5an0bojHL00ipHP1QuBUrVcP+XK+yZHHOJ/r1I0RUM= diff --git a/inttestutils/artifactory.go b/inttestutils/artifactory.go index 1448a4c99..29d6a5481 100644 --- a/inttestutils/artifactory.go +++ b/inttestutils/artifactory.go @@ -9,7 +9,6 @@ import ( "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli/utils/tests" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) // Verify the input slice exist in Artifactory @@ -18,39 +17,23 @@ import ( // serverDetails - Target Artifactory server details // t - Tests object func VerifyExistInArtifactory(expected []string, specFile string, serverDetails *config.ServerDetails, t *testing.T) { - results, err := SearchInArtifactory(specFile, serverDetails, t) - require.NoError(t, err) + results, _ := SearchInArtifactory(specFile, serverDetails, t) tests.CompareExpectedVsActual(expected, results, t) } func SearchInArtifactory(specFile string, serverDetails *config.ServerDetails, t *testing.T) ([]utils.SearchResult, error) { - searchSpec, err := spec.CreateSpecFromFile(specFile, nil) - if err != nil { - return nil, err - } - if searchSpec == nil { - return nil, assert.AnError - } + searchSpec, _ := spec.CreateSpecFromFile(specFile, nil) searchCmd := generic.NewSearchCommand() searchCmd.SetServerDetails(serverDetails).SetSpec(searchSpec) reader, err := searchCmd.Search() - if err != nil { - return nil, err - } + assert.NoError(t, err) var resultItems []utils.SearchResult readerNoDate, err := utils.SearchResultNoDate(reader) - if err != nil { - _ = reader.Close() - return nil, err - } + assert.NoError(t, err) for searchResult := new(utils.SearchResult); readerNoDate.NextRecord(searchResult) == nil; searchResult = new(utils.SearchResult) { resultItems = append(resultItems, *searchResult) } - if cerr := reader.Close(); cerr != nil { - return resultItems, cerr - } - if rerr := reader.GetError(); rerr != nil { - return resultItems, rerr - } - return resultItems, nil + assert.NoError(t, reader.Close(), "Couldn't close reader") + assert.NoError(t, reader.GetError(), "Couldn't get reader error") + return resultItems, err } diff --git a/main_test.go b/main_test.go index 304b93dd6..60ae5bf54 100644 --- a/main_test.go +++ b/main_test.go @@ -263,10 +263,8 @@ func createConfigFile(inDir, configFilePath string, t *testing.T) { if _, err := os.Stat(inDir); os.IsNotExist(err) { assert.NoError(t, os.MkdirAll(inDir, 0o777)) } - createdPath, err := tests.ReplaceTemplateVariables(configFilePath, inDir) + _, err := tests.ReplaceTemplateVariables(configFilePath, inDir) assert.NoError(t, err) - // Fail early with a descriptive error if the config file wasn't actually created. - assert.FileExists(t, createdPath) } // Validate that all CLI commands' aliases are unique, and that two commands don't use the same alias. From 612e1402e77fd13359f2c4287ec3484f17ebb98f Mon Sep 17 00:00:00 2001 From: nitinp19 Date: Tue, 6 Jan 2026 16:31:20 +0530 Subject: [PATCH 16/16] nitpic changes --- testdata/gradle/gradleproject/build.gradle | 3 --- .../gradleproject/src/main/java/example/Example.java | 7 ------- testdata/gradle/projectwithplugin/build.gradle | 3 --- 3 files changed, 13 deletions(-) diff --git a/testdata/gradle/gradleproject/build.gradle b/testdata/gradle/gradleproject/build.gradle index cd34354f7..8f0013885 100644 --- a/testdata/gradle/gradleproject/build.gradle +++ b/testdata/gradle/gradleproject/build.gradle @@ -5,9 +5,6 @@ repositories { mavenCentral() } -// Gradle 8+ blocks http:// repositories unless allowInsecureProtocol=true is set. -// The JFrog Gradle integration (traditional extractor flow) may add an Artifactory resolver repo using http://localhost in tests. -// This block is safe across Gradle versions because it checks for the property before setting it. allprojects { repositories.all { repo -> try { diff --git a/testdata/gradle/gradleproject/src/main/java/example/Example.java b/testdata/gradle/gradleproject/src/main/java/example/Example.java index 9827ad7d5..2a4f506f1 100644 --- a/testdata/gradle/gradleproject/src/main/java/example/Example.java +++ b/testdata/gradle/gradleproject/src/main/java/example/Example.java @@ -1,11 +1,4 @@ package example; - -/** - * Simple example class for the gradle test project. - * Note: We intentionally don't use JUnit here because dependency resolution - * may not work when the JFrog Gradle plugin configures the resolver to use - * the test Artifactory repository (which may not have JUnit cached). - */ public class Example { public boolean isTrue() { return true; diff --git a/testdata/gradle/projectwithplugin/build.gradle b/testdata/gradle/projectwithplugin/build.gradle index 796fcb9b3..8a4614aef 100644 --- a/testdata/gradle/projectwithplugin/build.gradle +++ b/testdata/gradle/projectwithplugin/build.gradle @@ -11,9 +11,6 @@ apply plugin: 'idea' apply plugin: 'com.jfrog.artifactory' apply plugin: 'maven-publish' -// Gradle 8+ blocks http:// repositories unless allowInsecureProtocol=true is set. -// The JFrog Gradle integration / Artifactory plugin may add an Artifactory resolver repo using http://localhost in tests. -// This block is safe across Gradle versions because it checks for the property before setting it. allprojects { repositories.all { repo -> try {