Installation de Gradle et CLI
Installez Gradle, comprenez son interface de ligne de commande et exécutez des commandes de construction de base.
Installation de Gradle et CLI est une leçon Groovy & Gradle: JVM Automation and Build Engineering gratuite sur CoddyKit. Ceci est la leçon 1 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Groovy & Gradle: JVM Automation and Build Engineering, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Groovy & Gradle: JVM Automation and Build Engineering comprend 4 leçons au total.
Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.
Meet the Gradle CLI
The Gradle Command Line Interface (CLI) is your main tool for interacting with Gradle. It's how you tell Gradle what to do, like building your project or running tests.
Understanding the CLI is crucial for automating your build processes and managing your projects effectively.
Java is Required!
Before installing Gradle, you need to have the Java Development Kit (JDK) installed on your system. Gradle runs on the Java Virtual Machine (JVM), just like Java applications.
- Ensure you have JDK 8 or higher.
- You can check your Java version with:
java -version
How to Install Gradle
There are several ways to install Gradle. For beginners, using a version manager like SDKMAN! is highly recommended. It simplifies managing multiple SDK versions.
- SDKMAN!: Easy and flexible.
- Manual Download: More setup required.
- Package Managers: Homebrew (macOS), Chocolatey (Windows).
Install Gradle via SDKMAN!
SDKMAN! (Software Development Kit Manager) makes installing Gradle super easy. If you don't have SDKMAN!, install it first by following instructions on sdkman.io.
Once SDKMAN! is ready, open your terminal and run:
sdk install gradleCheck Your Gradle Version
After installation, it's a good practice to verify that Gradle is correctly installed and accessible from your terminal. This command shows the Gradle version and other environment details.
Run this in your terminal:
gradle -vDiscovering Gradle Tasks
The most common command to start with is gradle tasks. This command lists all available tasks for the current project. If you're not in a Gradle project, it shows generic tasks.
Let's try it:
gradle tasksWhat `gradle tasks` Shows
When you run gradle tasks, you'll see categories like "Build tasks", "Verification tasks", etc., each with a list of tasks and their descriptions.
- Tasks: Are the actual actions Gradle performs (e.g.,
build,clean,test). - Description: Explains what each task does.
This output helps you understand what operations your project supports.
Need Help? Use `gradle help`
Gradle has a built-in help system. If you want to know more about a specific task, you can use the help task with the --task option.
For example, to learn about the build task:
gradle help --task buildIntro to Gradle Wrapper (gradlew)
Many Gradle projects include a Gradle Wrapper (gradlew or gradlew.bat). This script ensures everyone uses the same Gradle version for a project, even if they don't have Gradle installed globally.
You'll often run commands like ./gradlew build instead of gradle build.
Test Your CLI Knowledge
Let's check your understanding of basic Gradle commands!
Recap: Gradle CLI Essentials
Great job! In this lesson, you learned how to:
- Understand the role of the Gradle CLI.
- Install Gradle using SDKMAN!.
- Verify your installation with
gradle -v. - List available tasks using
gradle tasks. - Get help for specific tasks with
gradle help --task <taskName>. - Briefly grasp the concept of the Gradle Wrapper.
Next, we'll dive into setting up a basic Gradle project!
Questions Fréquemment Posées
La leçon « Installation de Gradle et CLI » est-elle gratuite ?
Oui — le texte complet de « Installation de Gradle et CLI » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Groovy & Gradle: JVM Automation and Build Engineering, passe à CoddyKit PRO. Le cours Groovy & Gradle: JVM Automation and Build Engineering comprend 4 leçons au total.
Qu'est-ce que j'apprendrai dans « Installation de Gradle et CLI » ?
Installez Gradle, comprenez son interface de ligne de commande et exécutez des commandes de construction de base. Tu pratiques Groovy & Gradle: JVM Automation and Build Engineering avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.
Dois-je avoir de l'expérience pour commencer Groovy & Gradle: JVM Automation and Build Engineering ?
Aucune expérience préalable n'est requise. Groovy & Gradle: JVM Automation and Build Engineering sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 1 sur 4.
Combien de temps prend la leçon « Installation de Gradle et CLI » ?
La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.
Peux-tu écrire et exécuter du code dans cette leçon Groovy & Gradle: JVM Automation and Build Engineering ?
Oui. Chaque leçon Groovy & Gradle: JVM Automation and Build Engineering inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.
Toutes les leçons de ce cours
- Installation de Gradle et CLI
- Structure des projets Gradle
- Tâches et cycle de vie de la construction
- Compilations multi-projets et fichier de paramètres