Skip to content

Commit 1620e92

Browse files
danysantiagoDagger Team
authored and
Dagger Team
committed
Add Github CI step and action for building with Gradle
The Gradle projects is configured to use JDK 18 toolchain so a new env variable is added for it. RELNOTES=N/A PiperOrigin-RevId: 710748526
1 parent c43783a commit 1620e92

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Gradle Build'
2+
description: 'Builds artifacts using Gradle.'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE }}'
8+
uses: actions/setup-java@v4
9+
with:
10+
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
11+
java-version: '${{ env.USE_JAVA_VERSION_FOR_GRADLE }}'
12+
- name: 'Check out repository'
13+
uses: actions/checkout@v4
14+
- name: 'Cache Gradle files'
15+
uses: actions/cache@v4
16+
with:
17+
path: |
18+
~/.gradle/caches
19+
~/.gradle/wrapper
20+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
21+
restore-keys: |
22+
${{ runner.os }}-gradle-
23+
- name: 'Build Gradle version'
24+
run: ./util/build-gradle.sh
25+
shell: bash

.github/actions/test-gradle-plugin/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ description: 'Tests the Hilt Gradle plugin.'
44
runs:
55
using: "composite"
66
steps:
7-
- name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_PLUGIN }}'
7+
- name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE_PLUGIN }}'
88
uses: actions/setup-java@v4
99
with:
1010
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
11-
java-version: '${{ env.USE_JAVA_VERSION_FOR_PLUGIN }}'
11+
java-version: '${{ env.USE_JAVA_VERSION_FOR_GRADLE_PLUGIN }}'
1212
- name: 'Check out repository'
1313
uses: actions/checkout@v4
1414
- name: 'Cache local Maven repository'

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ env:
1212
USE_JAVA_DISTRIBUTION: 'zulu'
1313
USE_JAVA_VERSION: '11'
1414
# This is required by Gradle 8.0+.
15-
USE_JAVA_VERSION_FOR_PLUGIN: '17'
15+
USE_JAVA_VERSION_FOR_GRADLE_PLUGIN: '17'
16+
# Required by JDK Toolchain Configuration
17+
USE_JAVA_VERSION_FOR_GRADLE: '18'
1618
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
1719
# https://issues.apache.org/jira/browse/MNG-7679
1820
USE_MAVEN_VERSION: '3.8.7'
@@ -40,6 +42,14 @@ jobs:
4042
steps:
4143
- uses: actions/checkout@v4
4244
- uses: ./.github/actions/bazel-test
45+
gradle-build:
46+
name: 'Gradle build'
47+
runs-on:
48+
group: large-runner-group
49+
labels: ubuntu-22.04-16core
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: ./.github/actions/gradle-build
4353
artifact-verification-tests:
4454
name: 'Artifact verification tests'
4555
needs: bazel-build

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ env:
1111
USE_JAVA_DISTRIBUTION: 'zulu'
1212
USE_JAVA_VERSION: '11'
1313
# This is required by Gradle 8.0+.
14-
USE_JAVA_VERSION_FOR_PLUGIN: '17'
14+
USE_JAVA_VERSION_FOR_GRADLE_PLUGIN: '17'
15+
# Required by JDK Toolchain Configuration
16+
USE_JAVA_VERSION_FOR_GRADLE: '18'
1517
DAGGER_RELEASE_VERSION: "${{ github.event.inputs.dagger_release_version }}"
1618
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
1719
# https://issues.apache.org/jira/browse/MNG-7679

buildSrc/src/main/kotlin/dagger/gradle/build/SourceSetConfiguration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fun Project.daggerSources(block: DaggerSourceSet.() -> Unit) {
7272
val javaExtension = extensions.findByType(JavaPluginExtension::class.java)
7373
?: error("The daggerSources() configuration must be applied to a Kotlin (JVM) project.")
7474
val daggerSources = DaggerSourceSet(this, kotlinExtension.sourceSets, javaExtension.sourceSets)
75-
black.invoke(daggerSources)
75+
block.invoke(daggerSources)
7676
}
7777

7878
/**

gradle-projects/dagger-runtime/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import dagger.gradle.build.daggerSources
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
24

35
plugins {
46
id(libs.plugins.kotlinJvm.get().pluginId)

util/build-gradle.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
./gradlew build --no-daemon --stacktrace

0 commit comments

Comments
 (0)