From e50fd1a9f961a8b4caf2a7eeb9dbbea3fb54e4f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 06:05:04 +0000 Subject: [PATCH 1/6] Initial plan for issue From 2112c2928d3fe079540cdb13381794e8ec075fe1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 06:23:22 +0000 Subject: [PATCH 2/6] Add maven-publish plugin to core module and dependency to gross-plugin Co-authored-by: warting <657973+warting@users.noreply.github.com> --- core/build.gradle.kts | 14 +++++++++++++- gross-plugin/build.gradle.kts | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 64bec8c..c3fa272 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ plugins { kotlin("jvm") version "2.3.20" alias(libs.plugins.org.jetbrains.kotlin.plugin.serialization) alias(libs.plugins.io.gitlab.arturbosch.detekt) - + id("maven-publish") } detekt { @@ -32,3 +32,15 @@ dependencies { detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8") } + +publishing { + publications { + create("mavenJava") { + from(components["java"]) + + groupId = "se.premex.gross" + artifactId = "core" + version = "1.0" + } + } +} diff --git a/gross-plugin/build.gradle.kts b/gross-plugin/build.gradle.kts index 311ac10..481e9b3 100644 --- a/gross-plugin/build.gradle.kts +++ b/gross-plugin/build.gradle.kts @@ -49,6 +49,7 @@ dependencies { implementation(libs.org.jetbrains.kotlinx.kotlinx.serialization.json.okio) implementation(libs.com.squareup.okio) compileOnly(libs.com.squareup.licensee) + implementation("se.premex.gross:core:1.0") testImplementation(platform(libs.org.junit.junit.bom)) testImplementation(libs.org.junit.jupiter.junit.jupiter.api) From a94a4e644eaa46a4523616811750df56310f438e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 06:34:56 +0000 Subject: [PATCH 3/6] Fixed test cases to work with core module data classes Co-authored-by: warting <657973+warting@users.noreply.github.com> --- .../kotlin/se/premex/gross/core/Artifact.kt | 23 ------------------- .../se/premex/gross/ArtifactGeneratorTest.kt | 14 +++++------ 2 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 gross-plugin/src/main/kotlin/se/premex/gross/core/Artifact.kt diff --git a/gross-plugin/src/main/kotlin/se/premex/gross/core/Artifact.kt b/gross-plugin/src/main/kotlin/se/premex/gross/core/Artifact.kt deleted file mode 100644 index dca7d53..0000000 --- a/gross-plugin/src/main/kotlin/se/premex/gross/core/Artifact.kt +++ /dev/null @@ -1,23 +0,0 @@ -package se.premex.gross.core - -import kotlinx.serialization.Serializable - -@Serializable -data class SpdxLicenses(val identifier: String, val name: String, val url: String) - -@Serializable -data class Scm(val url: String) - -@Serializable -data class UnknownLicenses(val name: String, val url: String) - -@Serializable -data class Artifact( - val groupId: String, - val artifactId: String, - val version: String, - val name: String? = null, - val spdxLicenses: List? = null, - val scm: Scm? = null, - val unknownLicenses: List? = null, -) diff --git a/gross-plugin/src/test/kotlin/se/premex/gross/ArtifactGeneratorTest.kt b/gross-plugin/src/test/kotlin/se/premex/gross/ArtifactGeneratorTest.kt index d4b3071..46795ed 100644 --- a/gross-plugin/src/test/kotlin/se/premex/gross/ArtifactGeneratorTest.kt +++ b/gross-plugin/src/test/kotlin/se/premex/gross/ArtifactGeneratorTest.kt @@ -17,9 +17,9 @@ class ArtifactGeneratorTest { private val artifactCodeGenerator = ArtifactCodeGenerator( packageName = packageName, - licenseeTypesGenerator.unknownLicensesTypeSpec, licenseeTypesGenerator.spdxLicensesTypeSpec, licenseeTypesGenerator.scmTypeSpec, + licenseeTypesGenerator.unknownLicensesTypeSpec, ) @Test @@ -74,7 +74,7 @@ class ArtifactGeneratorTest { name = "testName", spdxLicenses = kotlin.collections.listOf( ), - scm = se.premex.gross.SpdxLicenses("testUrl"), + scm = se.premex.gross.Scm("testUrl"), unknownLicenses = kotlin.collections.listOf( ), ) @@ -110,13 +110,13 @@ class ArtifactGeneratorTest { version = "testVersion", name = "testName", spdxLicenses = kotlin.collections.listOf( - se.premex.gross.UnknownLicenses(identifier = "spdxId1", name = "spdxName1", url = "spdxUrl1"), - se.premex.gross.UnknownLicenses(identifier = "spdxId2", name = "spdxName2", url = "spdxUrl2"), + se.premex.gross.SpdxLicenses(identifier = "spdxId1", name = "spdxName1", url = "spdxUrl1"), + se.premex.gross.SpdxLicenses(identifier = "spdxId2", name = "spdxName2", url = "spdxUrl2"), ), - scm = se.premex.gross.SpdxLicenses("testUrl"), + scm = se.premex.gross.Scm("testUrl"), unknownLicenses = kotlin.collections.listOf( - se.premex.gross.Scm(name = "unknown1", url = "unknown1"), - se.premex.gross.Scm(name = "unknown2", url = "unknown2"), + se.premex.gross.UnknownLicenses(name = "unknown1", url = "unknown1"), + se.premex.gross.UnknownLicenses(name = "unknown2", url = "unknown2"), ), ) From 7dc4009e6f6ebac9f442cec50bc31059a35df997 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 06:40:17 +0000 Subject: [PATCH 4/6] Updated README with information about the core library Co-authored-by: warting <657973+warting@users.noreply.github.com> --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 7d6ed4e..2c02eca 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Gross is a Gradle plugin that helps you manage and document open source licenses - **Kotlin Code Generation**: Generates a static list of open source artifacts with their licenses as Kotlin code - **Android Asset Generation**: Saves the licensee report as an Android asset for runtime access - **License Compliance**: Makes it easier to comply with open source license requirements in your projects +- **Core Library**: Provides data classes for artifacts and licenses in a separate library that can be used by other modules ## Installation @@ -92,6 +93,16 @@ You can use `AssetLicenseParser` to read and parse this file at runtime: val licenses = AssetLicenseParser(context).parse() ``` +### Core Library + +The core module provides the data classes (`Artifact`, `SpdxLicenses`, `Scm`, `UnknownLicenses`) that can be used by other modules in your project. To use them, you just need to add a dependency to the core module: + +```kotlin +dependencies { + implementation("se.premex.gross:core:1.0") +} +``` + ## Usage Examples ### Creating a licenses screen in an Android app with Jetpack Compose From 873fbe0ad54bd062479f96d64d9c1de4dad1e66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20W=C3=A4rting?= Date: Mon, 23 Mar 2026 19:33:19 +0100 Subject: [PATCH 5/6] fix: resolve core module dependency for composite build architecture The gross-plugin is a composite build (includeBuild) that cannot directly access root subprojects. This fixes the build by: - Adding core/settings.gradle.kts for standalone builds (publishToMavenLocal) - Adding mavenLocal() to gross-plugin and test fixture repositories - Publishing core to mavenLocal in CI before builds that need it - Removing duplicate LicenseParser.kt from gross-plugin - Fixing smart cast errors in ArtifactCodeGenerator (cross-module nullable access) Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/post-merge.yml | 3 +++ .github/workflows/pull-request.yml | 6 +++++ .github/workflows/release-gross-plugin.yml | 3 +++ core/settings.gradle.kts | 22 +++++++++++++++++++ gross-plugin/settings.gradle.kts | 2 ++ .../se/premex/gross/ArtifactCodeGenerator.kt | 10 +++++---- .../se/premex/gross/core/LicenseParser.kt | 10 --------- .../android_licensee_1_11/settings.gradle.kts | 1 + .../android_licensee_1_12/settings.gradle.kts | 1 + .../android_licensee_1_14/settings.gradle.kts | 1 + .../android_licensee_1_7/settings.gradle.kts | 1 + .../android_licensee_1_8/settings.gradle.kts | 1 + .../java_licensee_1_7/settings.gradle.kts | 1 + .../java_licensee_1_8/settings.gradle.kts | 1 + settings.gradle.kts | 1 + 15 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 core/settings.gradle.kts delete mode 100644 gross-plugin/src/main/kotlin/se/premex/gross/core/LicenseParser.kt diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index 5db5a7f..915baa4 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -27,6 +27,9 @@ jobs: id: find_version run: ./scripts/generate_versions.sh + - name: Publish core to mavenLocal + run: cd core && ../gradlew publishToMavenLocal + - name: Run verifications run: ./gradlew check --scan diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 40a6956..8166720 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -31,6 +31,9 @@ jobs: id: find_version run: ./scripts/generate_versions.sh + - name: Publish core to mavenLocal + run: cd core && ../gradlew publishToMavenLocal + - name: Run verifications run: ./gradlew check --scan @@ -124,6 +127,9 @@ jobs: id: find_version run: ./scripts/generate_versions.sh + - name: Publish core to mavenLocal + run: cd core && ../gradlew publishToMavenLocal + - name: Run validate on plugin working-directory: gross-plugin run: ./gradlew check validatePlugins --scan diff --git a/.github/workflows/release-gross-plugin.yml b/.github/workflows/release-gross-plugin.yml index a34e136..464e167 100644 --- a/.github/workflows/release-gross-plugin.yml +++ b/.github/workflows/release-gross-plugin.yml @@ -29,6 +29,9 @@ jobs: id: find_version run: ./scripts/generate_versions.sh + - name: Publish core to mavenLocal + run: cd core && ../gradlew publishToMavenLocal + - name: Run verifications run: ./gradlew check --scan diff --git a/core/settings.gradle.kts b/core/settings.gradle.kts new file mode 100644 index 0000000..5109d8d --- /dev/null +++ b/core/settings.gradle.kts @@ -0,0 +1,22 @@ +rootProject.name = "core" + +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } + @Suppress("UnstableApiUsage") + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + @Suppress("UnstableApiUsage") + repositories { + mavenCentral() + } +} diff --git a/gross-plugin/settings.gradle.kts b/gross-plugin/settings.gradle.kts index a111c31..f6d12b7 100644 --- a/gross-plugin/settings.gradle.kts +++ b/gross-plugin/settings.gradle.kts @@ -18,6 +18,7 @@ dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) @Suppress("UnstableApiUsage") repositories { + mavenLocal() google() mavenCentral() gradlePluginPortal() @@ -35,3 +36,4 @@ develocity { termsOfUseAgree = "yes" } } + diff --git a/gross-plugin/src/main/kotlin/se/premex/gross/ArtifactCodeGenerator.kt b/gross-plugin/src/main/kotlin/se/premex/gross/ArtifactCodeGenerator.kt index 3da0d10..ec5cdd4 100644 --- a/gross-plugin/src/main/kotlin/se/premex/gross/ArtifactCodeGenerator.kt +++ b/gross-plugin/src/main/kotlin/se/premex/gross/ArtifactCodeGenerator.kt @@ -30,9 +30,10 @@ class ArtifactCodeGenerator( arguments.add(artifact.groupId) arguments.add(artifact.artifactId) arguments.add(artifact.version) - if (artifact.name != null) { + val artifactName = artifact.name + if (artifactName != null) { appendLine("""name = %S,""") - arguments.add(artifact.name) + arguments.add(artifactName) } else { appendLine("""name = null,""") } @@ -48,10 +49,11 @@ class ArtifactCodeGenerator( } appendLine("""),""") - if (artifact.scm != null) { + val artifactScm = artifact.scm + if (artifactScm != null) { appendLine("""scm = %T(%S), """.trimMargin()) arguments.add(ClassName(packageName, scmTypeSpec.name!!)) - arguments.add(artifact.scm.url) + arguments.add(artifactScm.url) } else { appendLine("""scm = null, """.trimMargin()) } diff --git a/gross-plugin/src/main/kotlin/se/premex/gross/core/LicenseParser.kt b/gross-plugin/src/main/kotlin/se/premex/gross/core/LicenseParser.kt deleted file mode 100644 index 42096e0..0000000 --- a/gross-plugin/src/main/kotlin/se/premex/gross/core/LicenseParser.kt +++ /dev/null @@ -1,10 +0,0 @@ -package se.premex.gross.core - -import kotlinx.serialization.json.Json -import okio.BufferedSource - -object LicenseParser { - fun decode(source: BufferedSource): List { - return Json.decodeFromString(source.readString(Charsets.UTF_8)) - } -} diff --git a/gross-plugin/src/test/fixtures/android_licensee_1_11/settings.gradle.kts b/gross-plugin/src/test/fixtures/android_licensee_1_11/settings.gradle.kts index 1c7d343..edc9838 100644 --- a/gross-plugin/src/test/fixtures/android_licensee_1_11/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/android_licensee_1_11/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven") + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/gross-plugin/src/test/fixtures/android_licensee_1_12/settings.gradle.kts b/gross-plugin/src/test/fixtures/android_licensee_1_12/settings.gradle.kts index 1c7d343..edc9838 100644 --- a/gross-plugin/src/test/fixtures/android_licensee_1_12/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/android_licensee_1_12/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven") + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/gross-plugin/src/test/fixtures/android_licensee_1_14/settings.gradle.kts b/gross-plugin/src/test/fixtures/android_licensee_1_14/settings.gradle.kts index 1c7d343..edc9838 100644 --- a/gross-plugin/src/test/fixtures/android_licensee_1_14/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/android_licensee_1_14/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven") + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/gross-plugin/src/test/fixtures/android_licensee_1_7/settings.gradle.kts b/gross-plugin/src/test/fixtures/android_licensee_1_7/settings.gradle.kts index 1c7d343..edc9838 100644 --- a/gross-plugin/src/test/fixtures/android_licensee_1_7/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/android_licensee_1_7/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven") + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/gross-plugin/src/test/fixtures/android_licensee_1_8/settings.gradle.kts b/gross-plugin/src/test/fixtures/android_licensee_1_8/settings.gradle.kts index 1c7d343..edc9838 100644 --- a/gross-plugin/src/test/fixtures/android_licensee_1_8/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/android_licensee_1_8/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven") + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/gross-plugin/src/test/fixtures/java_licensee_1_7/settings.gradle.kts b/gross-plugin/src/test/fixtures/java_licensee_1_7/settings.gradle.kts index b157ec1..d358aed 100644 --- a/gross-plugin/src/test/fixtures/java_licensee_1_7/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/java_licensee_1_7/settings.gradle.kts @@ -1,5 +1,6 @@ pluginManagement { repositories { + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/gross-plugin/src/test/fixtures/java_licensee_1_8/settings.gradle.kts b/gross-plugin/src/test/fixtures/java_licensee_1_8/settings.gradle.kts index 696a160..8b047e3 100644 --- a/gross-plugin/src/test/fixtures/java_licensee_1_8/settings.gradle.kts +++ b/gross-plugin/src/test/fixtures/java_licensee_1_8/settings.gradle.kts @@ -1,6 +1,7 @@ pluginManagement { repositories { maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven") + mavenLocal() google() gradlePluginPortal() mavenCentral() diff --git a/settings.gradle.kts b/settings.gradle.kts index 1a96405..f51c69c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,7 @@ enableFeaturePreview("STABLE_CONFIGURATION_CACHE") pluginManagement { repositories { + mavenLocal() google() mavenCentral() gradlePluginPortal() From baa8fd484ca1c30f7c6b87923bd6fd09d9e63d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20W=C3=A4rting?= Date: Mon, 23 Mar 2026 19:59:06 +0100 Subject: [PATCH 6/6] fix: add publishToMavenLocal step to ui-check and core-check CI jobs Even targeted tasks like :core:check and :ui:check trigger full root build configuration, which includes gross-plugin classpath resolution requiring se.premex.gross:core:1.0 from mavenLocal. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/pull-request.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 8166720..b52be6b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -65,6 +65,9 @@ jobs: id: find_version run: ./scripts/generate_versions.sh + - name: Publish core to mavenLocal + run: cd core && ../gradlew publishToMavenLocal + - name: Run validate on ui run: ./gradlew :ui:check --scan @@ -96,6 +99,9 @@ jobs: id: find_version run: ./scripts/generate_versions.sh + - name: Publish core to mavenLocal + run: cd core && ../gradlew publishToMavenLocal + - name: Run validate on core run: ./gradlew :core:check --scan