|
1 |
| -//Version 2.1.1 |
| 1 | +//Version 2.2.2 |
2 | 2 | buildscript {
|
3 | 3 | repositories {
|
4 | 4 | mavenCentral()
|
@@ -57,17 +57,24 @@ project.afterEvaluate {
|
57 | 57 |
|
58 | 58 | def allTaskNames
|
59 | 59 |
|
| 60 | + def includeDebug = project.hasProperty('publishReleaseOnly') ? |
| 61 | + !Boolean.valueOf(publishReleaseOnly) : true |
| 62 | + |
60 | 63 | if (project.hasProperty('productFlavors')) {
|
61 | 64 | def parts = productFlavors.split(",")
|
62 | 65 | allTaskNames = new ArrayList<?>(parts.length * 2)
|
63 | 66 | for (part in parts) {
|
64 |
| - allTaskNames.add(tasksContainer.getByName("bundle${part.capitalize()}DebugAar")) |
| 67 | + if (includeDebug) { |
| 68 | + allTaskNames.add(tasksContainer.getByName("bundle${part.capitalize()}DebugAar")) |
| 69 | + } |
65 | 70 | allTaskNames.add(tasksContainer.getByName("bundle${part.capitalize()}ReleaseAar"))
|
66 | 71 | }
|
67 | 72 | } else {
|
68 | 73 | allTaskNames = new ArrayList<?>(2)
|
69 | 74 | allTaskNames.add(tasksContainer.getByName("bundleReleaseAar"))
|
70 |
| - allTaskNames.add(tasksContainer.getByName("bundleDebugAar")) |
| 75 | + if (includeDebug) { |
| 76 | + allTaskNames.add(tasksContainer.getByName("bundleDebugAar")) |
| 77 | + } |
71 | 78 | }
|
72 | 79 |
|
73 | 80 |
|
@@ -252,24 +259,21 @@ project.afterEvaluate {
|
252 | 259 |
|
253 | 260 | def scopes = ["compile", "api", "implementation"]
|
254 | 261 | for (scope in scopes) {
|
255 |
| - for (conf in configurations) { |
256 |
| - def confName = conf.name.toLowerCase() |
257 |
| - |
258 |
| - if (confName.endsWith(scope) && |
259 |
| - !confName.contains("test") && |
260 |
| - !confName.contains("metadata") && |
261 |
| - !confName.contains("android") && |
262 |
| - !confName.contains("dependencies") && ( |
263 |
| - |
264 |
| - // Only consider the debug dependencies for debug publication |
265 |
| - // equally release for release or normal (neither debug, |
266 |
| - // nor release) |
267 |
| - (buildTypeLower == "debug" && confName.contains('debug')) || |
268 |
| - (buildTypeLower == "release" && confName.contains('release')) || |
269 |
| - (!confName.contains('debug') && !confName.contains('release')) |
270 |
| - ) |
271 |
| - ) { |
272 |
| - conf.getDependencies().each { dep -> |
| 262 | + def scopeConfigurations = new ArrayList<String>(4) |
| 263 | + //api |
| 264 | + scopeConfigurations.add(scope) |
| 265 | + //debugApi |
| 266 | + scopeConfigurations.add(buildTypeLower + scope.capitalize()) |
| 267 | + if (!productFlavorLower.empty) { |
| 268 | + //stagingApi |
| 269 | + scopeConfigurations.add(productFlavorLower + scope.capitalize()) |
| 270 | + //stagingDebugApi |
| 271 | + scopeConfigurations.add(productFlavorLower + buildTypeLower.capitalize() + scope.capitalize()) |
| 272 | + } |
| 273 | + |
| 274 | + for (confName in scopeConfigurations) { |
| 275 | + configurations.getByName(confName) { |
| 276 | + getDependencies().each { dep -> |
273 | 277 | //Ignore kotlin transitive dependencies as they will be applied
|
274 | 278 | // by the kotlin plugin
|
275 | 279 | if (!(dep.group == "org.jetbrains.kotlin" &&
|
@@ -398,8 +402,11 @@ class ArtefactFlavorConf {
|
398 | 402 |
|
399 | 403 | // Allow the definition to be only artefact name-based
|
400 | 404 | boolean isArtefact(PropertyDependency dependency) {
|
401 |
| - return (artefact == dependency || (artefact.isNameOnly() && artefact.name == dependency.name)) || |
402 |
| - isForAllArtefacts() |
| 405 | + return (artefact == dependency || isNamedArtefact(dependency.name)) |
| 406 | + } |
| 407 | + |
| 408 | + boolean isNamedArtefact(String name) { |
| 409 | + return (artefact.isNameOnly() && artefact.name == name) || iusForAllArtefacts() |
403 | 410 | }
|
404 | 411 |
|
405 | 412 | boolean hasFlavor(String flavorName) {
|
@@ -435,6 +442,21 @@ class ArtefactFlavorProperties {
|
435 | 442 | configuration = []
|
436 | 443 | }
|
437 | 444 |
|
| 445 | + boolean ignoreFlavorFor(ProjectDependency dependency, String flavor) { |
| 446 | + if (flavor.empty) { |
| 447 | + //No flavours in project, treat this as ignored |
| 448 | + return true |
| 449 | + } |
| 450 | + |
| 451 | + for (ArtefactFlavorConf conf : configuration) { |
| 452 | + if (conf.isNamedArtefact(dependency.name) && conf.hasFlavor(flavor)){ |
| 453 | + return true |
| 454 | + } |
| 455 | + } |
| 456 | + |
| 457 | + return false |
| 458 | + } |
| 459 | + |
438 | 460 | boolean ignoreFlavorFor(PropertyDependency dependency, String flavor){
|
439 | 461 | if (flavor.empty) {
|
440 | 462 | //No flavours in project, treat this as ignored
|
|
0 commit comments