cashapp / licensee

Gradle plugin which validates the licenses of your dependency graph match what you expect
https://cashapp.github.io/licensee/docs/1.x/
Apache License 2.0
637 stars 30 forks source link

FeatureRequest: Add Configuration For File Directory #127

Closed sdoward closed 7 months ago

sdoward commented 2 years ago

As an android developer I want to be able to configure the location of the artefacts.json file So that I can bundle it in my app as part of the ./assets directory


We use the .json file to create a screen that shows the licences to our users. It would be nice if we can easily add that file as part of the build/ci pipeline.

JakeWharton commented 2 years ago

This is one of the intended use of the library. I don't think the right path is configuring our tasks, but either doing one of two things:

The functionality for registering an asset-generating task is relatively new and I have not experimented with it yet: https://issuetracker.google.com/issues/37085092#comment4

hfhbd commented 7 months ago

You can easily just consume the json file using standard Gradle api:

val myCustomTask = tasks.register("myCustomTask", MyCustomTask::class) {
  val licenseeJsonFile: Provider<RegularFile> = tasks.licensee.flatMap { it.outputDir.file("artifacts.json") }
  myInputFile.set(licenseeJsonFile)
}

But we could also expose the file as a task property:

val myCustomTask = tasks.register("myCustomTask", MyCustomTask::class) {
  val licenseeJsonFile: Provider<RegularFile> = tasks.licensee.flatMap { it.artifactsJsonFile }
  myInputFile.set(licenseeJsonFile)
}
JakeWharton commented 7 months ago

181 also shows how to bundle the output into assets using the correct mechanisms. That change will make it even easier.