添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Structuring Projects with Gradle
  • Declaring Dependencies between Subprojects
  • Sharing Build Logic between Subprojects
  • Composite Builds
  • Configuration on Demand
  • Understanding Tasks
  • Controlling Task Execution
  • Organizing Tasks
  • Implementing Custom Tasks
  • Configuring Tasks Lazily
  • Developing Parallel Tasks
  • Developing Advanced Tasks
  • Using Shared Build Services
  • Understanding Plugins
  • Understanding Implementation Options
  • Implementing Pre-compiled Script Plugins
  • Implementing Binary Plugins
  • Testing Plugins
  • Publishing Plugins
  • Understanding Properties and Providers
  • Understanding Collections
  • Understanding Services and Service Injection
  • Working with Files
  • Initialization Scripts
  • Dataflow Actions
  • Testing with TestKit
  • Using Ant from Gradle
  • Gradle-managed Directories
  • Configuring the Build Environment
  • Logging with Gradle
  • Dependency Management

  • Getting Started
  • 1. Declaring Dependencies
  • 2. Dependency Configurations
  • 3. Declaring Repositories
  • 4. Centralizing Dependencies
  • 5. Dependency Constraints and Conflict Resolution
  • 6. Dependency Resolution
  • 7. Variant Aware Dependency Resolution
  • Declaring Dependencies Basics
  • Viewing Dependencies
  • Declaring Versions and Ranges
  • Declaring Dependency Constraints
  • Creating Dependency Configurations
  • Declaring Repositories Basics
  • Centralizing Repository Declarations
  • Repository Types
  • Metadata Formats
  • Supported Protocols
  • Filtering Repository Content
  • Creating Platforms
  • Creating Version Catalogs
  • Using Catalogs with Platforms
  • Locking Versions
  • Using Resolution Rules
  • Modifying Dependency Metadata
  • Caching Dependencies
  • Understanding The Model
  • Capabilities
  • Variants and Attributes
  • Dependency Resolution Basics
  • Graph Resolution
  • Artifact Resolution
  • Artifact Transforms
  • Setting up Publishing
  • Understanding Gradle Module Metadata
  • Signing Artifacts
  • Customizing Publishing
  • Maven Publish Plugin
  • Ivy Publish Plugin
  • Verifying Dependencies
  • Aligning Dependencies
  • Modeling Feature Variants and Optional Dependencies
  • Android Studio

    As a variant of IntelliJ IDEA, Android Studio has built-in support for importing and building Gradle projects. You can also use the IDEA Plugin for Gradle to fine-tune the import process if that’s necessary.

    This IDE also has an extensive user guide to help you get the most out of the IDE and Gradle.

    Eclipse

    If you want to work on a project within Eclipse that has a Gradle build, you should use the Eclipse Buildship plugin . This will allow you to import and run Gradle builds. If you need to fine tune the import process so that the project loads correctly, you can use the Eclipse Plugins for Gradle . See the associated release announcement for details on what fine tuning you can do.

    IntelliJ IDEA

    IDEA has built-in support for importing Gradle projects. If you need to fine tune the import process so that the project loads correctly, you can use the IDEA Plugin for Gradle .

    NetBeans

    Built-in support for Gradle in Apache NetBeans

    Visual Studio

    For developing C++ projects, Gradle comes with a Visual Studio plugin .

    Xcode

    For developing C++ projects, Gradle comes with a Xcode plugin .

    CLion

    JetBrains supports building C++ projects with Gradle .

    Introduction to the Tooling API

    Gradle provides a programmatic API called the Tooling API, which you can use for embedding Gradle into your own software. This API allows you to execute and monitor builds and to query Gradle about the details of a build. The main audience for this API is IDE, CI server, other UI authors; however, the API is open for anyone who needs to embed Gradle in their application.

    Eclipse Buildship uses the Tooling API for importing your Gradle project and running tasks.

    IntelliJ IDEA uses the Tooling API for importing your Gradle project and running tasks.

    Tooling API Features

    A fundamental characteristic of the Tooling API is that it operates in a version independent way. This means that you can use the same API to work with builds that use different versions of Gradle, including versions that are newer or older than the version of the Tooling API that you are using. The Tooling API is Gradle wrapper aware and, by default, uses the same Gradle version as that used by the wrapper-powered build.

    Some features that the Tooling API provides:

    Query the details of a build, including the project hierarchy and the project dependencies, external dependencies (including source and Javadoc jars), source directories and tasks of each project.

    Execute a build and listen to stdout and stderr logging and progress messages (e.g. the messages shown in the 'status bar' when you run on the command line).

    Execute a specific test class or test method.

    Receive interesting events as a build executes, such as project configuration, task execution or test execution.

    Cancel a build that is running.

    Combine multiple separate Gradle builds into a single composite build.

    The Tooling API can download and install the appropriate Gradle version, similar to the wrapper.

    The implementation is lightweight, with only a small number of dependencies. It is also a well-behaved library, and makes no assumptions about your classloader structure or logging configuration. This makes the API easy to embed in your application.

    The Tooling API always uses the Gradle daemon. This means that subsequent calls to the Tooling API, be it model building requests or task executing requests will be executed in the same long-living process. Gradle Daemon contains more details about the daemon, specifically information on situations when new daemons are forked.

    Quickstart

    As the Tooling API is an interface for developers, the Javadoc is the main documentation for it.

    To use the Tooling API, add the following repository and dependency declarations to your build script:

    dependencies { implementation("org.gradle:gradle-tooling-api:$toolingApiVersion") // The tooling API need an SLF4J implementation available at runtime, replace this with any other implementation runtimeOnly("org.slf4j:slf4j-simple:1.7.10") dependencies { implementation "org.gradle:gradle-tooling-api:$toolingApiVersion" // The tooling API need an SLF4J implementation available at runtime, replace this with any other implementation runtimeOnly 'org.slf4j:slf4j-simple:1.7.10'

    The main entry point to the Tooling API is the GradleConnector . You can navigate from there to find code samples and explore the available Tooling API models. You can use GradleConnector.connect() to create a ProjectConnection . A ProjectConnection connects to a single Gradle project. Using the connection you can execute tasks, tests and retrieve models relative to this project.

    Compatibility of Java and Gradle versions

    The following components should be considered when implementing Gradle integration: the Tooling API version, The JVM running the Tooling API client (i.e. the IDE process), the JVM running the Gradle daemon, and the Gradle version.

    The Tooling API itself is a Java library published as part of the Gradle release. Each Gradle release has a corresponding Tooling API version with the same version number.

    The Tooling API classes are loaded into the client’s JVM, so they should have a matching version. The current version of the Tooling API library is compiled with Java 8 compatibility.

    The JVM running the Tooling API client and the one running the daemon can be different. At the same time, classes that are sent to the build via custom build actions need to be targeted to the lowest supported Java version. The JVM versions supported by Gradle is version-specific. The upper bound is defined in the compatibility matrix . The rule for the lower bound is the following:

    The Tooling API version is guaranteed to support running builds with all Gradle versions for the last five major releases. For example, the Tooling API 8.0 release is compatible with Gradle versions >= 3.0. Besides, the Tooling API is guaranteed to be compatible with future Gradle releases for the current and the next major. This means, for example, that the 8.1 version of the Tooling API will be able to run Gradle 9.x builds and might break with Gradle 10.0.