diff --git a/README.md b/README.md index 2750e94..69a5745 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,16 @@ Options can be configured in the `licenseeForAndroid` extension: ```groovy licenseeForAndroid { - enableKotlinCodeGeneration = false - enableAndroidAssetGeneration = true - androidAssetFileName = "licensee_artifacts.json" - singularVariantName = null + enableKotlinCodeGeneration = false + generatedPackageName = "io.github.usefulness.licensee" + enableAndroidAssetGeneration = true + androidAssetFileName = "licensee_artifacts.json" + singularVariantName = null } ``` - `enableKotlinCodeGeneration` - Generates a static list of open source assets +- `generatedPackageName` - Generate Kotlin code under given package - `enableAndroidAssetGeneration` - Enable asset generation. Will copy licensee report to android asset directory making it available as `androidAssetFileName` - `androidAssetFileName` - The name of the asset file the licensee report gets copied to. - `singularVariantName` - The name of the build variant that all variants will use to have always the same licensed, regardless of app variant. (i.e. "productionRelease") diff --git a/licensee-for-android/api/licensee-for-android.api b/licensee-for-android/api/licensee-for-android.api index 22d282b..4371d4d 100644 --- a/licensee-for-android/api/licensee-for-android.api +++ b/licensee-for-android/api/licensee-for-android.api @@ -11,6 +11,7 @@ public abstract class io/github/usefulness/licensee/CodeGenerationTask : org/gra public final fun action ()V public abstract fun getInputFile ()Lorg/gradle/api/file/RegularFileProperty; public abstract fun getOutputDirectory ()Lorg/gradle/api/file/DirectoryProperty; + public abstract fun getPackageName ()Lorg/gradle/api/provider/Property; } public class io/github/usefulness/licensee/LicenseeForAndroidExtension { @@ -18,6 +19,7 @@ public class io/github/usefulness/licensee/LicenseeForAndroidExtension { public final fun getAndroidAssetFileName ()Lorg/gradle/api/provider/Property; public final fun getEnableAndroidAssetGeneration ()Lorg/gradle/api/provider/Property; public final fun getEnableKotlinCodeGeneration ()Lorg/gradle/api/provider/Property; + public final fun getGeneratedPackageName ()Lorg/gradle/api/provider/Property; public final fun getSingularVariantName ()Lorg/gradle/api/provider/Property; } diff --git a/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/CodeGenerationTask.kt b/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/CodeGenerationTask.kt index eb02c99..1d5eb86 100644 --- a/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/CodeGenerationTask.kt +++ b/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/CodeGenerationTask.kt @@ -34,7 +34,7 @@ public abstract class CodeGenerationTask : DefaultTask() { public abstract val inputFile: RegularFileProperty @get:Input - public abstract val packageName : Property + public abstract val packageName: Property @TaskAction @ExperimentalSerializationApi diff --git a/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/LicenseeForAndroidExtension.kt b/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/LicenseeForAndroidExtension.kt index 87d0b4f..b38c10c 100644 --- a/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/LicenseeForAndroidExtension.kt +++ b/licensee-for-android/src/main/kotlin/io/github/usefulness/licensee/LicenseeForAndroidExtension.kt @@ -11,6 +11,10 @@ public open class LicenseeForAndroidExtension(objectFactory: ObjectFactory) { */ public val enableKotlinCodeGeneration: Property = objectFactory.property(default = false) + /** + * Generate kotlin code under given package + * Default: `io.github.usefulness.licensee` + */ public val generatedPackageName: Property = objectFactory.property(default = "io.github.usefulness.licensee") /** diff --git a/sample/ui/build.gradle b/sample/ui/build.gradle index da80100..cbd3e9e 100644 --- a/sample/ui/build.gradle +++ b/sample/ui/build.gradle @@ -1,5 +1,21 @@ +import app.cash.licensee.LicenseeTask +import io.github.usefulness.licensee.CodeGenerationTask + plugins { alias(libs.plugins.starter.library.android) + alias(libs.plugins.app.cash.licensee) + id("io.github.usefulness.licensee-for-android") +} + +licensee { + allow("Apache-2.0") +} + +licenseeForAndroid { + enableKotlinCodeGeneration = true + enableAndroidAssetGeneration = false + generatedPackageName = "example.generated.from.library" + androidAssetFileName = "library_asset.json" } android { diff --git a/sample/ui/src/test/kotlin/io/github/usefulness/licensee/PluginLibaryIntegrationTest.kt b/sample/ui/src/test/kotlin/io/github/usefulness/licensee/PluginLibaryIntegrationTest.kt new file mode 100644 index 0000000..fda7bb3 --- /dev/null +++ b/sample/ui/src/test/kotlin/io/github/usefulness/licensee/PluginLibaryIntegrationTest.kt @@ -0,0 +1,13 @@ +package io.github.usefulness.licensee + +import example.generated.from.library.Licensee +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PluginLibaryIntegrationTest { + + @Test + fun checkGeneratedCode() { + assertThat(Licensee.artifacts).isNotEmpty() + } +}