Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions docs/buildtools/gradle/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
9 changes: 8 additions & 1 deletion utils/cliutils/commandsflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.` `",
Expand Down Expand Up @@ -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,
Expand Down
Loading