Managing Gradle with JFrog CLI

JFrog Applications and CLI Documentation

 

The JFrog CLI extends the capabilities of the Gradle build tool, enabling seamless integration with Artifactory for dependency resolution and artifact deployment.

When you use jf gradle commands (for example, jf gradle build, jf gradle publish), the CLI acts as an intermediary layer that provides Artifactory-aware capabilities such as:

  • Centralized and consistent authentication

  • Repository-aware dependency resolution

  • Automatic build-info collection

  • Xray security scanning integration

Prerequisites & Technical Limitations

Before configuring your project, please note the following requirements and technical behaviors:

  • Gradle Version: The minimum recommended Gradle version is 5.0.

  • Build Script Parsing: Artifact deployment paths are identified via a fuzzy search algorithm. The CLI scans property keys and placeholders in build.gradle for the following substrings:

    • repo

    • url

    • deploy

  • Checksum Calculation: Module dependencies are resolved from the local Gradle cache. Checksum calculation is performed only for dependencies present in the cache. Dependencies that are not found locally will have checksum calculation skipped.

Modes of Operation

Wrapped Mode (Default)

In Wrapped Mode, the JFrog CLI actively participates in the Gradle workflow. It reads configuration from .jfrog/projects/gradle.yaml and uses the Artifactory Gradle plugin to inject repository settings.

Requirements:

  • Run jf gradle-config before first use

  • Configuration file at .jfrog/projects/gradle.yaml

  • Optional: JFrog Gradle plugin in your build script

Native Mode (Manual Setup)

For Native Mode with Gradle, you should:

  1. Configure repositories directly in build.gradle or build.gradle.kts

  2. Use native gradle commands instead of jf gradle

  3. Optionally use the Artifactory Gradle plugin with the artifactoryPublish task for build-info collection. Build-info collection is supported only through artifactoryPublish, not standard Gradle publish tasks.

When to Use Each Approach

Use Wrapped Mode (jf gradle) when you want:

  • Minimal configuration overhead

  • Automated repository injection

  • Simplified onboarding for teams

  • Automatic integration with Artifactory

  • Build-info collection without plugin setup

Use Native Gradle Commands when you need:

  • Zero modification to build behavior

  • Fully deterministic builds

  • All configuration version-controlled in build files

Command Reference

Syntax

jf gradle <tasks and options> [command options]
    

Command Options

Flag

Description

Default

--build-name

Build name for build-info collection. Requires --build-number.

None

--build-number

Build number for build-info collection. Requires --build-name.

None

--project

JFrog Project key for the build-info.

None

--deployment-threads

Number of threads for parallel deployment.

3

--detailed-summary

Include list of affected files in command summary.

false

--scan

Scan deployed artifacts with Xray before upload.

false

--format

Output format for scan results (table, json, simple-json).

table

Configuration Command: jf gradle-config

Configure Gradle build settings for Wrapped Mode.

jf gradle-config [command options]
    

Alias: jf gradlec

Environment Variables

Variable

Description

JFROG_RUN_NATIVE

When set to true, enables run native mode for supported build tools

JFROG_CLI_RELEASES_REPO

Repository for downloading CLI dependencies

JFROG_CLI_DEPENDENCIES_DIR

Directory for CLI dependencies

GRADLE_USER_HOME

Gradle user home directory

GRADLE_OPTS

JVM options for Gradle daemon

Frequently Asked Questions (FAQ)

Q: Why do I get "no config file was found" error?

A: In Wrapped Mode, you must run jf gradle-config before running jf gradle. This creates the required configuration file at .jfrog/projects/gradle.yaml.

Q: What's the difference between --uses-plugin and not using it?

A: When --uses-plugin=true, the CLI expects the Artifactory Gradle plugin to be configured and leverages it for enhanced integration. Without it, the CLI handles repository injection automatically.

Q: Can I use jf gradle with Kotlin DSL (build.gradle.kts)?

A: Yes. The CLI works with both Groovy and Kotlin DSL build files.

Q: How do I configure authentication for private repositories?

A: In Wrapped Mode, authentication is handled automatically through the configured server. In Native Mode, configure credentials in your build.gradle or gradle.properties.