diff --git a/buildtools/cli.go b/buildtools/cli.go index cb9cd308a..b9cbe380d 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -910,6 +910,13 @@ func GradleCmd(c *cli.Context) (err error) { if err != nil { return err } + filteredGradleArgs, includeSharedBuild, err := coreutils.ExtractBoolFlagFromArgs(filteredGradleArgs, "include-shared-build") + if err != nil { + return err + } + if includeSharedBuild { + return errorutils.CheckErrorf("--include-shared-build is not supported yet in Gradle FlexPack (native) mode; it is currently only supported with Gradle Classic, which requires a gradle-config file") + } // Create Gradle command with FlexPack (no config file needed) gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath("").SetServerDetails(serverDetails) @@ -947,6 +954,10 @@ func GradleCmd(c *cli.Context) (err error) { if xrayScan { commandsUtils.ConditionalUploadScanFunc = scan.ConditionalUploadDefaultScanFunc } + filteredGradleArgs, includeSharedBuild, err := coreutils.ExtractBoolFlagFromArgs(filteredGradleArgs, "include-shared-build") + if err != nil { + return err + } filteredGradleArgs, format, err := coreutils.ExtractXrayOutputFormatFromArgs(filteredGradleArgs) if err != nil { return err @@ -964,7 +975,7 @@ func GradleCmd(c *cli.Context) (err error) { } } 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).SetIncludeSharedBuild(includeSharedBuild) err = commands.ExecWithPackageManager(gradleCmd, project.Gradle.String()) result := gradleCmd.Result() defer cliutils.CleanupResult(result, &err) diff --git a/docs/buildtools/gradle/help.go b/docs/buildtools/gradle/help.go index 982388374..cc57516d5 100644 --- a/docs/buildtools/gradle/help.go +++ b/docs/buildtools/gradle/help.go @@ -31,12 +31,14 @@ Common patterns: $ jf gradle clean build $ jf gradle artifactoryPublish --build-name=my-build --build-number=1 $ jf gradle build -b path/to/build.gradle + $ jf gradle clean artifactoryPublish --include-shared-build Gotchas: - 'jf gradle-config' must be run first; the command fails with a clear error if missing. - --build-name and --build-number are required together for build-info. - Gradle daemon caches can hide config changes; use --no-daemon when debugging. - Set JFROG_CLI_RELEASES_REPO to fetch the Gradle extractor through a private repo (air-gapped builds). +- --include-shared-build requires a gradle-config file (Gradle Classic); it errors out in Gradle FlexPack (native) mode, which has no gradle-config file. Related: jf gradle-config, jf rt build-publish` } diff --git a/utils/cliutils/commandsflags.go b/utils/cliutils/commandsflags.go index 74dba544b..788a2898c 100644 --- a/utils/cliutils/commandsflags.go +++ b/utils/cliutils/commandsflags.go @@ -391,6 +391,9 @@ const ( ivyDescPattern = "ivy-desc-pattern" ivyArtifactsPattern = "ivy-artifacts-pattern" + // Unique gradle (runtime "jf gradle") flags - not wired into gradle-config + includeSharedBuild = "include-shared-build" + // Build tool flags deploymentThreads = "deployment-threads" skipLogin = "skip-login" @@ -1431,6 +1434,10 @@ var flagsMap = map[string]cli.Flag{ Name: repoDeploy, Usage: "[Optional] Repository for artifacts deployment.` `", }, + includeSharedBuild: cli.BoolFlag{ + Name: includeSharedBuild, + Usage: "[Default: false] Set to true to collect buildSrc and included-build modules in build-info.` `", + }, usesPlugin: cli.BoolFlag{ Name: usesPlugin, Usage: "[Default: false] Set to true if the Gradle Artifactory Plugin is already applied in the build script.` `", @@ -2205,7 +2212,7 @@ var commandFlags = map[string][]string{ BuildName, BuildNumber, deploymentThreads, InsecureTls, Project, serverIdMvn, detailedSummary, xrayScan, XrFormat, }, Gradle: { - BuildName, BuildNumber, deploymentThreads, Project, serverId, detailedSummary, xrayScan, XrFormat, + BuildName, BuildNumber, deploymentThreads, Project, serverId, detailedSummary, xrayScan, XrFormat, includeSharedBuild, }, Docker: { BuildName, BuildNumber, module, Project,