Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 110 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -19,46 +18,139 @@ jobs:
lint-and-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
uses: gradle/actions/wrapper-validation@0723195856401067f7a2779048b490ace7a47d7c # ratchet:gradle/actions/wrapper-validation@v5.0.2
- name: Lint GitHub Actions
uses: abcxyz/actions/.github/actions/lint-github-actions@e32ec3bd6af6d87d79fe7c441f435eb7ad11d527 # main
uses: abcxyz/actions/.github/actions/lint-github-actions@e32ec3bd6af6d87d79fe7c441f435eb7ad11d527 # ratchet:abcxyz/actions/.github/actions/lint-github-actions@main
- name: Ratchet Check
uses: sethvargo/ratchet@8b4ca256dbed184350608a3023620f267f0a5253 # main
uses: sethvargo/ratchet@8b4ca256dbed184350608a3023620f267f0a5253 # ratchet:sethvargo/ratchet@main
with:
files: .github/workflows/*.yml

# This workflow contains a single job called "build"
# Build the simple plugins (no special test infrastructure needed)
build:
needs: lint-and-check
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Runs this job in parallel for each sub-project
strategy:
matrix:
project-dir:
- strict-version-matcher-plugin
- google-services-plugin
- oss-licenses-plugin

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2

- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # ratchet:actions/setup-java@v5.2.0
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # ratchet:gradle/actions/setup-gradle@v5.0.2
with:
dependency-graph: generate-and-submit

# Runs a build which includes `check` and `test` tasks
- name: Perform a Gradle build
run: ./gradlew build
working-directory: ./${{ matrix.project-dir }}

# Build and test the oss-licenses plugin, then publish for downstream jobs.
oss-licenses-build:
needs: lint-and-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2

- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # ratchet:actions/setup-java@v5.2.0
with:
java-version: '17'
distribution: 'temurin'

- name: Set up JDK 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # ratchet:actions/setup-java@v5.2.0
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # ratchet:gradle/actions/setup-gradle@v5.0.2
with:
dependency-graph: generate-and-submit

- name: Build and test
run: ./gradlew build
working-directory: ./oss-licenses-plugin

- name: Publish to local repo
run: ./gradlew publish
working-directory: ./oss-licenses-plugin

- name: Upload local repo artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4.6.2
with:
name: oss-licenses-local-repo
path: oss-licenses-plugin/build/repo/

# Verify the plugin works with the standalone testapp.
oss-licenses-testapp:
needs: oss-licenses-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2

- name: Download local repo artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # ratchet:actions/download-artifact@v4.3.0
with:
name: oss-licenses-local-repo
path: oss-licenses-plugin/build/repo/

- name: Set up JDK 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # ratchet:actions/setup-java@v5.2.0
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # ratchet:gradle/actions/setup-gradle@v5.0.2

- name: Build testapp
run: ./gradlew build -PusePublishedPluginFrom=../build/repo
working-directory: oss-licenses-plugin/testapp

# Configuration cache verification for the oss-licenses plugin.
# Expected to FAIL until the plugin's CC bug is fixed (PR #381).
oss-licenses-testapp-cc:
needs: oss-licenses-build
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2

- name: Download local repo artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # ratchet:actions/download-artifact@v4.3.0
with:
name: oss-licenses-local-repo
path: oss-licenses-plugin/build/repo/

- name: Set up JDK 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # ratchet:actions/setup-java@v5.2.0
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # ratchet:gradle/actions/setup-gradle@v5.0.2

- name: Build testapp (prime configuration cache)
run: ./gradlew build -PusePublishedPluginFrom=../build/repo
working-directory: oss-licenses-plugin/testapp

- name: Clean testapp outputs
run: ./gradlew clean -PusePublishedPluginFrom=../build/repo
working-directory: oss-licenses-plugin/testapp

- name: Rebuild testapp (verify configuration cache reuse)
run: ./gradlew build -PusePublishedPluginFrom=../build/repo
working-directory: oss-licenses-plugin/testapp
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
repo/
.kotlin/
.DS_Store
2 changes: 2 additions & 0 deletions oss-licenses-plugin/gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is generated by updateDaemonJvm
toolchainVersion=21
4 changes: 4 additions & 0 deletions oss-licenses-plugin/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}

rootProject.name = 'oss-licenses-plugin'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ import static com.android.tools.build.libraries.metadata.Library.LibraryOneofCas
* Plugin into a JSON format that will be consumed by the {@link LicensesTask}.
*
* If the protobuf is not present (e.g. debug variants) it writes a single
* dependency on the {@link DependencyUtil#ABSENT_ARTIFACT}.
* dependency on the {@link #ABSENT_ARTIFACT}.
*/
@CacheableTask
abstract class DependencyTask extends DefaultTask {
private static final logger = LoggerFactory.getLogger(DependencyTask.class)

// Sentinel written to the JSON when AGP does not provide a dependency report (e.g. debug
// variants). LicensesTask detects this and renders a placeholder message instead of licenses.
protected static final ArtifactInfo ABSENT_ARTIFACT =
new ArtifactInfo("absent", "absent", "absent")

@OutputFile
abstract RegularFileProperty getDependenciesJson()

Expand Down Expand Up @@ -75,7 +80,7 @@ abstract class DependencyTask extends DefaultTask {
private Set<ArtifactInfo> loadArtifactInfo() {
if (!libraryDependenciesReport.isPresent()) {
logger.info("$name not provided with AppDependencies proto file.")
return [DependencyUtil.ABSENT_ARTIFACT]
return [ABSENT_ARTIFACT]
}

AppDependencies appDependencies = loadDependenciesFile()
Expand Down

This file was deleted.

Loading
Loading