Skip to content

Commit

Permalink
Merge pull request #24 from usefulness/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski authored Nov 14, 2023
2 parents df5b7cb + cbc1ab5 commit 2e45940
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 6 deletions.
59 changes: 56 additions & 3 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
```
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified images/generated_code_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/generated_code_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions licensee-for-android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.usefulness.licensee

import dev.drewhamilton.poko.Poko

@Poko
public class Artifact(
public val groupId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package io.github.usefulness.licensee

internal annotation class Poko
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.github.usefulness.licensee

class FakeLicensee(override val artifacts: List<Artifact>) : 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<SpdxLicense> = listOf(stubSpdxLicense()),
scm: Scm? = stubScm(),
unknownLicenses: List<UnknownLicense> = 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,
)
1 change: 1 addition & 0 deletions licensee-for-android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.stdlib.default.dependency=false

0 comments on commit 2e45940

Please sign in to comment.