Updated on 2024-11-21 GMT+08:00

Building with Gradle

Build a Java, Groovy, or Scala project with Gradle.

Build on GUI

Add Build with Gradle, when configuring build actions. Set the parameters according to Table 1.

Table 1 Parameters for building with Gradle

Parameter

Description

Action Name

Assign a custom name to the build action. The name can contain:

  • Letters, digits, hyphens (-), underscores (_), commas (,), semicolons (;), colons (:), periods (.), slashes (/), and parentheses.
  • 1 to 128 characters.

Gradle

Select a tool version that matches your current development environment.

For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

JDK

Select a tool version that matches your current development environment.

For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

Commands

Configure the Gradle commands, or use the default ones. If you have special build requirements, enter your custom build script in the text box. For more commands, see the Gradle official website.

Continue After Failure

Specify whether to proceed after the current action fails by setting the parameter to either Yes or No.

Build with Code

Modify the code in the BUILD block in Creating a YAML File for Your Code-based Build by referring to the following sample code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
version: 2.0 # The value must be 2.0.
steps:
  BUILD:
    - gradle:
        inputs:
            gradle: 4.8
            jdk: 1.8
            command: |
                # Gradle Wrapper provided by CodeArts is used for cache acceleration.
                cp /cache/android/wrapper/gradle-wrapper.jar ./gradle/wrapper/gradle-wrapper.jar
                # Build an unsigned APK.
                /bin/bash ./gradlew build --init-script  ./.codeci/.gradle/init_template.gradle -Dorg.gradle.daemon=false -Dorg.gradle.internal.http.connectionTimeout=800000
            ignore_fail: true
Table 2 Parameters in the sample code

Parameter

Type

Description

command

String

Configure the Gradle commands. For more commands, see the Gradle official website.

gradle

String

Select a tool version that matches your current development environment.

For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

jdk

String

Select a tool version that matches your current development environment.

For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

ignore_fail

String

Whether to proceed after the current action fails.
  • true: Yes
  • Empty: No