-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Duplicate assets issue #226
Comments
On a related note - generated assets should be separated by build variant under Android, so that
are all separated from each other and each target file can keep its original file name. That way it is easier in multi-variant environments, because consumers don't have to rename files by hand or via a separate Gradle All you need to do is to add the appropriate variant-named build dir to the assets source set of the same variant and you're done. |
The common output directory is even more problematic in Gradle 8, which introduced more strict task validation rules. Since all of the
errors out with
when the tasks for more than one build variant are executed at the same time. |
Are there any news on this? Because I am struggling with it in our gradle upgrade from 7 to 8, in which the plugin produces a lot of error output and does not work properly. |
@realdadfish Are you still having this issue? I am trying to repro with
|
I switched projects in the meantime, in the current one I'm not using the plugin anymore, so I can't say. Maybe @AndreyBulgakow can say? |
At least #339 seems to be fixed in |
Actually the build failed to me on CI:
|
Where is |
It's a custom task that triggers a private fun Project.createLicenseTask(
variantName: String,
assetDirs: Set<File>,
ignoredPatterns: Set<String>
) = task("generate${variantName}LicenseReport") {
// Trigger the license plugin task first to generate the JSON report.
dependsOn("license${variantName}Report")
// Prepare output directions and mark them as outputs.
val outputDirName = "licenses"
val outputDirs = assetDirs.map {
it.toPath().resolve(outputDirName).toFile()
}
outputDirs.forEach {
outputs.dir(it)
}
// Prepare inputs.
val jsonReport = licenseReportFile(variantName)
inputs.file(jsonReport)
val knownLicensesDir = knownLicencesDir()
inputs.dir(knownLicensesDir)
val extraDeps = extraDepsFile()
inputs.file(extraDeps)
// Mapping between a license URL and its text.
val knownLicensesByUrl = knownLicencesByUrl()
doLast {
val deps = loadDeps(
from = jsonReport,
ignoredPatterns = ignoredPatterns
).toMutableMap()
// Load extra dependencies. These are dependencies coming from other
// sources then the license report plugin. E.g. if we use a native
// library or a jar-file requiring attribution.
deps.putAll(loadDeps(from = extraDeps))
// Make sure each dependency has a license defined.
checkLicenseExistence(deps)
// Add the license file name to the report or fail if missing.
deps.values.forEach { dep ->
dep.licenses?.forEach {
val licenseFile = knownLicensesByUrl[it.licenseUrl]
if (licenseFile != null) {
it.licenseFile = "$outputDirName/$licenseFile"
} else {
throw GradleException("Missing license file for license url: ${it.licenseUrl} coming from ${dep.dependency}")
}
}
}
// Copy result json report and licenses to assets
outputDirs.forEach { outputDir ->
writeOutput(outputDir, deps, knownLicensesDir)
}
}
} While |
In
gradle-license-plugin/gradle-license-plugin/src/main/kotlin/com/jaredsburrows/license/projectAndroid.kt
Line 97 in a441c46
IMHO this is the wrong approach, because this leads to a "duplicate assets" issue as shown below:
It doesn't make much sense to just take "the first" or only the first not in
/build
either, because you cannot foresee what the module owner had in mind when (s)he configured his module with multiple asset directories. A better approach would beObviously, these two options should be mutual exclusive, otherwise people will stumble upon the same error above.
The text was updated successfully, but these errors were encountered: