Skip to content

Commit

Permalink
Add Github CI step and action for building with Gradle
Browse files Browse the repository at this point in the history
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
  • Loading branch information
danysantiago authored and Dagger Team committed Dec 30, 2024
1 parent c43783a commit 1620e92
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/actions/gradle-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Gradle Build'
description: 'Builds artifacts using Gradle.'

runs:
using: "composite"
steps:
- name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE }}'
uses: actions/setup-java@v4
with:
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
java-version: '${{ env.USE_JAVA_VERSION_FOR_GRADLE }}'
- name: 'Check out repository'
uses: actions/checkout@v4
- name: 'Cache Gradle files'
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 'Build Gradle version'
run: ./util/build-gradle.sh
shell: bash
4 changes: 2 additions & 2 deletions .github/actions/test-gradle-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ description: 'Tests the Hilt Gradle plugin.'
runs:
using: "composite"
steps:
- name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_PLUGIN }}'
- name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE_PLUGIN }}'
uses: actions/setup-java@v4
with:
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
java-version: '${{ env.USE_JAVA_VERSION_FOR_PLUGIN }}'
java-version: '${{ env.USE_JAVA_VERSION_FOR_GRADLE_PLUGIN }}'
- name: 'Check out repository'
uses: actions/checkout@v4
- name: 'Cache local Maven repository'
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ env:
USE_JAVA_DISTRIBUTION: 'zulu'
USE_JAVA_VERSION: '11'
# This is required by Gradle 8.0+.
USE_JAVA_VERSION_FOR_PLUGIN: '17'
USE_JAVA_VERSION_FOR_GRADLE_PLUGIN: '17'
# Required by JDK Toolchain Configuration
USE_JAVA_VERSION_FOR_GRADLE: '18'
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
# https://issues.apache.org/jira/browse/MNG-7679
USE_MAVEN_VERSION: '3.8.7'
Expand Down Expand Up @@ -40,6 +42,14 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/bazel-test
gradle-build:
name: 'Gradle build'
runs-on:
group: large-runner-group
labels: ubuntu-22.04-16core
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/gradle-build
artifact-verification-tests:
name: 'Artifact verification tests'
needs: bazel-build
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ env:
USE_JAVA_DISTRIBUTION: 'zulu'
USE_JAVA_VERSION: '11'
# This is required by Gradle 8.0+.
USE_JAVA_VERSION_FOR_PLUGIN: '17'
USE_JAVA_VERSION_FOR_GRADLE_PLUGIN: '17'
# Required by JDK Toolchain Configuration
USE_JAVA_VERSION_FOR_GRADLE: '18'
DAGGER_RELEASE_VERSION: "${{ github.event.inputs.dagger_release_version }}"
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
# https://issues.apache.org/jira/browse/MNG-7679
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fun Project.daggerSources(block: DaggerSourceSet.() -> Unit) {
val javaExtension = extensions.findByType(JavaPluginExtension::class.java)
?: error("The daggerSources() configuration must be applied to a Kotlin (JVM) project.")
val daggerSources = DaggerSourceSet(this, kotlinExtension.sourceSets, javaExtension.sourceSets)
black.invoke(daggerSources)
block.invoke(daggerSources)
}

/**
Expand Down
2 changes: 2 additions & 0 deletions gradle-projects/dagger-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import dagger.gradle.build.daggerSources
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id(libs.plugins.kotlinJvm.get().pluginId)
Expand Down
5 changes: 5 additions & 0 deletions util/build-gradle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -ex

./gradlew build --no-daemon --stacktrace

0 comments on commit 1620e92

Please sign in to comment.