Skip to content

Commit 293e19b

Browse files
authored
Merge pull request #34 from LikeTheSalad/release/2.2.3
Release/2.2.3
2 parents 19682ee + 9d03493 commit 293e19b

File tree

9 files changed

+58
-11
lines changed

9 files changed

+58
-11
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change Log
22
==========
33

4+
Version 2.2.3 *(09-10-2022)*
5+
---
6+
7+
* Fix #33
8+
49
Version 2.2.2 *(31-08-2022)*
510
---
611

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ So we see that the `app_name` value has been overridden by the demo's app_name,
312312
also for templates, we can also override templates within our demo's resources.
313313

314314
> Those were some of the use cases that you can achieve using Android Stem, there's more of them such as overriding
315-
> flavors' multi languages from the base values folder and also working with multi-dimension flavors. You can play around
315+
> flavors' multi languages from the base values folder and also working with multi-dimension flavors. You can play
316+
> around
316317
> with it, it all should work the way you'd expect it to work.
317318
318319
Adding it to your project
@@ -346,7 +347,7 @@ First, in your `Root's build.gradle` file, you'll need to add this
346347
line into your `buildscript` dependencies block:
347348

348349
```groovy
349-
classpath "com.likethesalad.android:stem-plugin:2.2.2"
350+
classpath "com.likethesalad.android:stem-plugin:2.2.3"
350351
```
351352

352353
Example:
@@ -359,7 +360,7 @@ buildscript {
359360
}
360361
dependencies {
361362
//...
362-
classpath "com.likethesalad.android:stem-plugin:2.2.2"
363+
classpath "com.likethesalad.android:stem-plugin:2.2.3"
363364
364365
// NOTE: Do not place your application dependencies here; they belong
365366
// in the individual module build.gradle files

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ artifactPublisher {
3030

3131
description = "This is a Gradle plugin for Android applications which resolves XML string references in other XML strings."
3232
group = 'com.likethesalad.android'
33-
version = '2.2.2'
33+
version = '2.2.3'
3434

3535
ext {
3636
dagger_version = '2.39.1'
3737
androidBuild_version = '7.1.0'
3838
testingUtilities_version = '1.0.8'
3939
resourceLocator_version = '2.0.0'
4040
androidTools_version = "1.2.0"
41+
androidBuild_test_version = '7.1.0'
4142
}
4243

4344
allprojects {

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Wed Aug 28 16:11:02 IST 2019
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

stem-plugin/build.gradle

+18-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ plugins {
44
id 'kotlin-kapt'
55
}
66

7+
configurations {
8+
testPluginDependency {
9+
canBeResolved(false)
10+
canBeConsumed(false)
11+
}
12+
testPluginClasspath {
13+
canBeConsumed(false)
14+
canBeResolved(true)
15+
extendsFrom(testPluginDependency)
16+
}
17+
}
18+
719
dependencies {
820
embedded "com.google.dagger:dagger:$dagger_version"
921
embedded project(':templates-provider-plugin')
@@ -14,12 +26,16 @@ dependencies {
1426
kapt "com.google.dagger:dagger-compiler:$dagger_version"
1527
testImplementation "com.likethesalad.tools.testing:android-gradle:$testingUtilities_version"
1628
testImplementation "com.likethesalad.tools.testing:unit-testing:$testingUtilities_version"
17-
testImplementation "com.android.tools.build:gradle:$androidBuild_version"
1829
testImplementation "net.lingala.zip4j:zip4j:2.9.1"
30+
testPluginDependency "com.android.tools.build:gradle:$androidBuild_test_version"
1931
}
2032

2133
tasks.withType(PluginUnderTestMetadata).configureEach {
22-
pluginClasspath.from(configurations.compileOnly)
34+
pluginClasspath.from(configurations.testPluginClasspath)
35+
}
36+
37+
tasks.withType(Test) {
38+
systemProperty "agpVersion", androidBuild_test_version
2339
}
2440

2541
kapt {

stem-plugin/src/functionalTest/kotlin/com/likethesalad/stem/CheckOutputsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class CheckOutputsTest : AndroidProjectTest() {
2121
companion object {
2222
private const val RESOLVER_PLUGIN_ID = "com.likethesalad.stem"
2323
private const val PROVIDER_PLUGIN_ID = "com.likethesalad.stem-library"
24-
private const val ANDROID_PLUGIN_VERSION = "7.1.0"
2524
private const val GRADLE_VERSION = "7.2"
25+
private val ANDROID_PLUGIN_VERSION = System.getProperty("agpVersion")
2626
}
2727

2828
private val inputAssetsProvider = TestAssetsProvider("functionalTest", "inputs")

stem-plugin/src/main/java/com/likethesalad/stem/ResolvePlaceholdersPlugin.kt

+21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.likethesalad.stem
22

3+
import com.android.build.api.AndroidPluginVersion
4+
import com.android.build.api.variant.AndroidComponentsExtension
35
import com.likethesalad.android.templates.common.plugins.BaseTemplatesProcessorPlugin
46
import com.likethesalad.stem.di.AppInjector
57
import com.likethesalad.stem.locator.listener.TypeLocatorCreationListener
8+
import com.likethesalad.stem.modules.common.helpers.dirs.VariantBuildResolvedDir.Companion.getBuildRelativeResolvedDir
69
import com.likethesalad.stem.providers.AndroidExtensionProvider
710
import com.likethesalad.stem.providers.LocatorExtensionProvider
811
import com.likethesalad.stem.providers.ProjectDirsProvider
@@ -49,6 +52,24 @@ class ResolvePlaceholdersPlugin : BaseTemplatesProcessorPlugin(), AndroidExtensi
4952
templateResourcesEntryPointFactory.create(commonSourceConfigurationCreator),
5053
creationListener
5154
)
55+
validateAgp73AddingSrcDirs(project)
56+
}
57+
58+
private fun validateAgp73AddingSrcDirs(project: Project) {
59+
try {
60+
val androidComponentsExtension = project.extensions.getByType(AndroidComponentsExtension::class.java)
61+
if (androidComponentsExtension.pluginVersion >= AndroidPluginVersion(7, 3)) {
62+
androidComponentsExtension.onVariants {
63+
val variantName = it.name
64+
androidExtension.addVariantSrcDir(
65+
variantName,
66+
project.layout.buildDirectory.dir(getBuildRelativeResolvedDir(variantName))
67+
)
68+
}
69+
}
70+
} catch (ignored: NoClassDefFoundError) {
71+
// When AGP < 7
72+
}
5273
}
5374

5475
fun getGradleLogger(): Logger {

stem-plugin/src/main/java/com/likethesalad/stem/modules/common/helpers/dirs/VariantBuildResolvedDir.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ class VariantBuildResolvedDir @AssistedInject constructor(
1919

2020
companion object {
2121
val RESOLVED_DIR_BUILD_RELATIVE_PATH = "generated${File.separator}resolved"
22+
23+
fun getBuildRelativeResolvedDir(variantName: String): String {
24+
return "$RESOLVED_DIR_BUILD_RELATIVE_PATH${File.separator}$variantName"
25+
}
2226
}
2327

2428
private val variantName by lazy { androidVariantData.getVariantName() }
2529

2630
val resolvedDir: File by lazy {
27-
val dir =
28-
File(projectDirsProvider.getBuildDir(), "$RESOLVED_DIR_BUILD_RELATIVE_PATH${File.separator}$variantName")
31+
val dir = File(projectDirsProvider.getBuildDir(), getBuildRelativeResolvedDir(variantName))
2932
sourceSetsHandler.addToSourceSets(dir, variantName)
3033
dir
3134
}

stem-plugin/src/main/java/com/likethesalad/stem/modules/resolveStrings/resolver/RecursiveLevelDetector.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class RecursiveLevelDetector @Inject constructor() {
6868
}
6969

7070
// Grab the highest level, that will be this current template level
71-
levels.max()!!
71+
levels.maxOrNull()!!
7272
} else {
7373
0
7474
}

0 commit comments

Comments
 (0)