Skip to content

Commit

Permalink
Check library integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Nov 11, 2023
1 parent 4001044 commit 566d272
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions licensee-for-android/api/licensee-for-android.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ 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 {
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class CodeGenerationTask : DefaultTask() {
public abstract val inputFile: RegularFileProperty

@get:Input
public abstract val packageName : Property<String>
public abstract val packageName: Property<String>

@TaskAction
@ExperimentalSerializationApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public open class LicenseeForAndroidExtension(objectFactory: ObjectFactory) {
*/
public val enableKotlinCodeGeneration: Property<Boolean> = objectFactory.property(default = false)

/**
* Generate kotlin code under given package
* Default: `io.github.usefulness.licensee`
*/
public val generatedPackageName: Property<String> = objectFactory.property(default = "io.github.usefulness.licensee")

/**
Expand Down
16 changes: 16 additions & 0 deletions sample/ui/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit 566d272

Please sign in to comment.