diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 67ae1c5..2455427 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -15,7 +15,7 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} jobs: - generate-diff: + generate-diff-gradle: env: github_token: ${{ secrets.GITHUB_TOKEN }} runs-on: ubuntu-latest @@ -53,13 +53,66 @@ jobs: id: find_comment with: issue-number: ${{ github.event.pull_request.number }} - body-includes: Dependency diff + body-includes: Dependency diff (Gradle plugin) - uses: peter-evans/create-or-update-comment@v3 if: ${{ steps.dependency-diff.outputs.text-diff != null || steps.find_comment.outputs.comment-id != null }} with: body: | - Dependency diff: + Dependency diff (Gradle plugin): + ```diff + ${{ steps.dependency-diff.outputs.text-diff }} + ``` + edit-mode: replace + comment-id: ${{ steps.find_comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + token: ${{ secrets.GITHUB_TOKEN }} + + generate-diff-core: + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Write Gradle build properties to `~/.gradle/gradle.properties` + run: | + mkdir -p ~/.gradle + printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties + printf "org.gradle.vfs.watch=false\n" >> ~/.gradle/gradle.properties + shell: bash + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 21 + + - name: Assemble + uses: gradle/gradle-build-action@v2 + with: + arguments: assemble -m + + - id: dependency-diff + name: Generate dependency diff + uses: usefulness/dependency-tree-diff-action@v1 + with: + project: licensee-for-android-core + configuration: 'runtimeClasspath' + + - uses: peter-evans/find-comment@v2 + id: find_comment + with: + issue-number: ${{ github.event.pull_request.number }} + body-includes: Dependency diff (core module) + + - uses: peter-evans/create-or-update-comment@v3 + if: ${{ steps.dependency-diff.outputs.text-diff != null || steps.find_comment.outputs.comment-id != null }} + with: + body: | + Dependency diff (core module): ```diff ${{ steps.dependency-diff.outputs.text-diff }} ``` diff --git a/gradle.properties b/gradle.properties index e5699c5..c140154 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,3 @@ kotlin.code.style=official org.gradle.caching=true org.gradle.parallel=true org.gradle.jvmargs="-XX:+UseParallelGC" -kotlin.stdlib.default.dependency=false diff --git a/images/generated_code_dark.png b/images/generated_code_dark.png index e5664f7..87c820d 100644 Binary files a/images/generated_code_dark.png and b/images/generated_code_dark.png differ diff --git a/images/generated_code_light.png b/images/generated_code_light.png index 15d75ca..38ddc15 100644 Binary files a/images/generated_code_light.png and b/images/generated_code_light.png differ diff --git a/licensee-for-android-core/build.gradle b/licensee-for-android-core/build.gradle index b0982dc..ebc54d9 100644 --- a/licensee-for-android-core/build.gradle +++ b/licensee-for-android-core/build.gradle @@ -4,6 +4,7 @@ plugins { alias(libs.plugins.starter.library.kotlin) alias(libs.plugins.kotlinx.binarycompatibility) alias(libs.plugins.drewhamilton.poko) + id("java-test-fixtures") id("com.starter.publishing") } description = "core library for io.github.usefulness.licensee-for-android gradle plugin. Exposes shareable classes and interfaces, useful in multi-module projects" @@ -12,6 +13,10 @@ kotlin { explicitApi() } +poko { + pokoAnnotation.set "io.github.usefulness.licensee.Poko" +} + def targetVersion = JavaVersion.VERSION_1_8 tasks.withType(KotlinCompile).configureEach { it.kotlinOptions.jvmTarget = targetVersion.toString() diff --git a/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Artifact.kt b/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Artifact.kt index 7e3d24d..de5061d 100644 --- a/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Artifact.kt +++ b/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Artifact.kt @@ -1,7 +1,5 @@ package io.github.usefulness.licensee -import dev.drewhamilton.poko.Poko - @Poko public class Artifact( public val groupId: String, diff --git a/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Poko.kt b/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Poko.kt new file mode 100644 index 0000000..ec918b2 --- /dev/null +++ b/licensee-for-android-core/src/main/kotlin/io/github/usefulness/licensee/Poko.kt @@ -0,0 +1,3 @@ +package io.github.usefulness.licensee + +internal annotation class Poko diff --git a/licensee-for-android-core/src/testFixtures/kotlin/io/github/usefulness/licensee/Stubs.kt b/licensee-for-android-core/src/testFixtures/kotlin/io/github/usefulness/licensee/Stubs.kt new file mode 100644 index 0000000..ca2c5dc --- /dev/null +++ b/licensee-for-android-core/src/testFixtures/kotlin/io/github/usefulness/licensee/Stubs.kt @@ -0,0 +1,53 @@ +package io.github.usefulness.licensee + +class FakeLicensee(override val artifacts: List) : Licensee + +fun stubArtifact( + groupId: String = "com.example", + artifactId: String = "foo-bar", + version: String = "0.1.0-alpha04", + name: String? = "Fixture Name of $groupId:$artifactId:$version", + spdxLicenses: List = listOf(stubSpdxLicense()), + scm: Scm? = stubScm(), + unknownLicenses: List = listOf(stubUnknownLicense()), +) = Artifact( + groupId = groupId, + artifactId = artifactId, + version = version, + name = name, + spdxLicenses = spdxLicenses, + scm = scm, + unknownLicenses = unknownLicenses, +) + +fun stubSpdxLicense( + identifier: String = "Apache-2.0", + name: String = "Apache License 2.0", + url: String = "https://www.apache.org/licenses/LICENSE-2.0", +) = SpdxLicense( + identifier = identifier, + name = name, + url = url, +) + +fun stubApacheLicense() = stubSpdxLicense( + identifier = "Apache-2.0", + name = "Apache License 2.0", + url = "https://www.apache.org/licenses/LICENSE-2.0", +) + +fun stubMitLicense() = stubSpdxLicense( + identifier = "MIT", + name = "MIT License", + url = "https://opensource.org/licenses/MIT", +) + +fun stubScm(url: String = "url") = Scm(url = url) + +fun stubUnknownLicense( + name: String = "Android Software Development Kit License", + url: String = "https://developer.android.com/studio/terms.html", +) = UnknownLicense( + name = name, + url = url, +) diff --git a/licensee-for-android/gradle.properties b/licensee-for-android/gradle.properties new file mode 100644 index 0000000..0d6aa7b --- /dev/null +++ b/licensee-for-android/gradle.properties @@ -0,0 +1 @@ +kotlin.stdlib.default.dependency=false