New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Licenses are missing in multi-module/multi-flavor project #474
Comments
@ar-g which version of the library do you use? how did you set it up? Libraries are generally merged from all the different flavors, and should also cover all transitive dependencies. Do you have by coincidence the whole xml generated? okhttp is a known special case as there is some topic with their POM file. |
I can add my input on this matter. Yes, there are lots of libs that are missing since POM files are incomplete and does not follow the standards. I am not running a multi-flavor setup by these are the ones missing on my side.
No, maybe it is not the proper way to solve this but is how we solve this.
And then have the new licence texts in a resources file:
|
For Note for only patching the licenses we maintain a list to allow patching these, so if you may provide the list of identifiers for those libraries we could enhance the list: Btw it is also possible to provide your own custom license mapping too. See here: https://github.com/mikepenz/AboutLibraries#gradle-plugin-configuration Beside the described approach by @adrianlandborn which works great there is also a way to modify informations on a per field basis:
This would allows to provide license name, description, url for the website: |
The plugin is applied to the app module. This one included into root Gradle file:
|
@ar-g please see @adrianlandborn and my answer. so it looks like parts of your libraries simply do not have their POM file incomplete in the providing repositories. meaning that for these the only approach is a manual one. you can add missing information as noted above. but you may also provide a list with all libraries and their licenses so we can look into it:
will output the info in the log :) if you have something sensitive in here which you may do not want to share publicly you may also be able to send me an e-mail with the output |
I was only able to add license through .withLibraryEnchantment("com_squareup_okhttp__okhttp", "xcom_squareup_okhttp__okhttp") <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="define_xcom_squareup_okhttp__okhttp" tools:ignore="UnusedResources">owner</string>
<string name="library_xcom_squareup_okhttp__okhttp_licenseId">Apache_2_0</string>
<string name="library_xcom_squareup_okhttp__okhttp_libraryName">OkHttp</string>
<string name="library_xcom_squareup_okhttp__okhttp_libraryDescription"><![CDATA[]]></string>
<string name="library_xcom_squareup_okhttp__okhttp_libraryArtifactId">com.squareup.okhttp:okhttp:</string>
</resources>
Gradle Plugin config didn't work for me. I'm going to add all those 42 licenses manually to the xml file and config. |
What did you try via the gradle plugin config? @ar-g I'd be curious to perhaps see if we can improve something here |
@mikepenz I just copied library definitions, modified okhttp to point apache_2_0 license and turned on configuration for the AboutLibraries gradle plugin. |
Now, we have another issue. This is how the generated folder looks like The problem is that there is no license description, and XML file with license looks like this: <resources>
<string name="define_license_Apache_2_0"></string>
<string name="license_Apache_2_0_licenseName">Apache License 2.0</string>
<string name="license_Apache_2_0_licenseWebsite">https://spdx.org/licenses/Apache-2.0.html</string>
</resources> |
@ar-g not sure if it is too much to ask. but perhaps it would be possible if you could remove all the application code and just keep the dependencies and the adjustments you made so that I can try and see why the apache license may no longer be used from the plugin but instead from the auto generated spec according to the spdx list |
I'm using a standard configuration of Gradle plugin:
I'm wondering how to debug this plugin 🤔 |
@ar-g so usually I use (upload archives is available within the plugin sub project) Debugging itself.. I tent to put log outputs and check the good old fashioned way. if there is a muc better way to get debugging and stuff working in AS I would be happy as it could speed up additionally |
I was able to do a bit of progress with debugging plugin. Basically, I was running When I was running latest published rc-02 version, the output was
Then I've made some changes to the gradle plugin, mainly commented part of it: class AboutLibrariesPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
// create the config possible
project.extensions.create('aboutLibraries', AboutLibrariesExtension)
File outputFile = project.file("$project.buildDir/generated/aboutlibraries/res/")
// task for cleaning
def cleanupTask = project.tasks.create("aboutLibrariesClean", AboutLibrariesCleanTask)
cleanupTask.description = "Cleans the generated data from the AboutLibraries plugin"
cleanupTask.dependencies = outputFile
project.tasks.findByName("clean").dependsOn(cleanupTask)
// task to write the general definitions information
AboutLibrariesTask task = project.tasks.create("prepareLibraryDefinitions", AboutLibrariesTask)
task.description = "Writes the relevant meta data for the AboutLibraries plugin to display dependencies"
task.setDependencies(outputFile)
/*project.android.applicationVariants.all { variant ->
// This is necessary for backwards compatibility with versions of gradle that do not support
// this new API.
if (variant.hasProperty("preBuildProvider")) {
variant.preBuildProvider.configure { dependsOn(task) }
} else {
//noinspection GrDeprecatedAPIUsage
variant.preBuild.dependsOn(task)
}
// This is necessary for backwards compatibility with versions of gradle that do not support
// this new API.
if (variant.respondsTo("registerGeneratedResFolders")) {
task.ext.generatedResFolders = project.files(task.getDependencies()).builtBy(task)
variant.registerGeneratedResFolders(task.generatedResFolders)
if (variant.hasProperty("mergeResourcesProvider")) {
variant.mergeResourcesProvider.configure { dependsOn(task) }
} else {
//noinspection GrDeprecatedAPIUsage
variant.mergeResources.dependsOn(task)
}
} else {
//noinspection GrDeprecatedAPIUsage
variant.registerResGeneratingTask(task, task.getDependencies())
}
}*/
// task to output library names with ids for further actions
AboutLibrariesIdTask taskId = project.tasks.create("findLibraries", AboutLibrariesIdTask)
taskId.description = "Writes the relevant meta data for the AboutLibraries plugin to display dependencies"
// task to output libraries and their license in CSV format to the CLI
AboutLibrariesExportTask exportTaskId = project.tasks.create("exportLibraries", AboutLibrariesExportTask)
exportTaskId.description = "Writes all libraries and their license in CSV format to the CLI"
}
} Now the license file is generated propperly when run
|
I believe with v8.0.0-rc03 I may have been able to fix various problems. Not sure about the task problem you were seeing, as this seems to not occur in the projects I have. I have though added a new task for your usecase to directly execute the generation to circumstance the code you commented out
I think with v8.0.0-rc03 the main issue should be resolved and we can close this. |
About this issue
Some of the licenses are missing in our multi-module/multi-flavor project.
I've run this code:
and got:
I've also checked generated xml, for example for okhttp:
The text was updated successfully, but these errors were encountered: