Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -62,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

Expand Down Expand Up @@ -93,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

Expand Down Expand Up @@ -124,6 +133,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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-gross-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -32,3 +32,15 @@ dependencies {

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8")
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])

groupId = "se.premex.gross"
artifactId = "core"
version = "1.0"
}
}
}
22 changes: 22 additions & 0 deletions core/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
}
}
1 change: 1 addition & 0 deletions gross-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions gross-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
@Suppress("UnstableApiUsage")
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
Expand All @@ -35,3 +36,4 @@ develocity {
termsOfUseAgree = "yes"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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,""")
}
Expand All @@ -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())
}
Expand Down
23 changes: 0 additions & 23 deletions gross-plugin/src/main/kotlin/se/premex/gross/core/Artifact.kt

This file was deleted.

10 changes: 0 additions & 10 deletions gross-plugin/src/main/kotlin/se/premex/gross/core/LicenseParser.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven")
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven")
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven")
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven")
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven")
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pluginManagement {
repositories {
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven(url = "file://${settingsDir.absolutePath}/../../../../build/localMaven")
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ArtifactGeneratorTest {
private val artifactCodeGenerator =
ArtifactCodeGenerator(
packageName = packageName,
licenseeTypesGenerator.unknownLicensesTypeSpec,
licenseeTypesGenerator.spdxLicensesTypeSpec,
licenseeTypesGenerator.scmTypeSpec,
licenseeTypesGenerator.unknownLicensesTypeSpec,
)

@Test
Expand Down Expand Up @@ -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(
),
)
Expand Down Expand Up @@ -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"),
),
)

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ enableFeaturePreview("STABLE_CONFIGURATION_CACHE")

pluginManagement {
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
Expand Down
Loading