Skip to content
Search

Gradle:Wrapper

lastmod 2025-02-01created 2023-03-285 edits

Categories

Getting started

The recommended way to run a Gradle build is with the Gradle Wrapper. The Wrapper invokes a pre-declared version of Gradle, downloading it beforehand if necessary. The reason you don't have to match the CI environment to the project's build environment every time you build a Java project in CI is precisely that the Gradle Wrapper is used. In other words, you can build a project independently of the environment, and this is one of Gradle's powerful features.

You'd need a JDK first, right?

Running the gradle wrapper command generates the files shown below.

$ gradle wrapper

Output:

BUILD SUCCESSFUL in 545ms
1 actionable task: 1 executed

$ tree
.
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
└── gradlew.bat

2 directories, 4 files

Gradle Wrapper structure:

  • gradlew.bat - wrapper launch script for Windows.
  • gradlew - wrapper launch script for Unix. Used for compiling, building, and so on. Run it as ./gradlew {task}.
  • gradle/wrapper/gradle-wrapper.jar - the Wrapper file. When the launch script runs, it downloads the environment matching the Wrapper to the local cache, then runs the task corresponding to the actual command.
  • gradle/wrapper/gradle-wrapper.properties - the Gradle Wrapper configuration file.

See also

Favorite site

author Zer0 sitemap