Skip to content

Commit 94630cf

Browse files
authored
Merge pull request #40 from LikeTheSalad/release/2.4.0
Release/2.4.0
2 parents c3e3a8e + 6ff6b79 commit 94630cf

File tree

11 files changed

+45
-23
lines changed

11 files changed

+45
-23
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.4.0 *(26-04-2023)*
5+
---
6+
7+
* Made Stem aware of mapSourceSetPaths task (Fix #39)
8+
49
Version 2.3.0 *(07-01-2023)*
510
---
611

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ First, in your `Root's build.gradle` file, you'll need to add this
347347
line into your `buildscript` dependencies block:
348348

349349
```groovy
350-
classpath "com.likethesalad.android:stem-plugin:2.3.0"
350+
classpath "com.likethesalad.android:stem-plugin:2.4.0"
351351
```
352352

353353
Example:
@@ -360,7 +360,7 @@ buildscript {
360360
}
361361
dependencies {
362362
//...
363-
classpath "com.likethesalad.android:stem-plugin:2.3.0"
363+
classpath "com.likethesalad.android:stem-plugin:2.4.0"
364364
365365
// NOTE: Do not place your application dependencies here; they belong
366366
// in the individual module build.gradle files

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ 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.3.0'
33+
version = "2.4.0"
3434

3535
ext {
3636
dagger_version = '2.39.1'

stem-plugin/src/main/java/com/likethesalad/stem/modules/common/helpers/android/AndroidVariantContext.kt

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ class AndroidVariantContext @AssistedInject constructor(
3535
val mergeResourcesTask: Task by lazy {
3636
taskProvider.findTaskByName(tasksNames.mergeResourcesName)!!
3737
}
38-
val packageResourcesTask: Task? by lazy {
39-
taskProvider.findTaskByName(tasksNames.packageResourcesName)
40-
}
41-
val extractDeeplinksTask: Task? by lazy {
42-
taskProvider.findTaskByName(tasksNames.extractDeeplinksName)
43-
}
4438
val incrementalDir: String by lazy {
4539
projectDirsProvider.getBuildDir().absolutePath + "/intermediates/incremental/" + tasksNames.resolvePlaceholdersName
4640
}
@@ -51,4 +45,8 @@ class AndroidVariantContext @AssistedInject constructor(
5145
outputStringFileResolver,
5246
resourceSerializer
5347
)
48+
49+
fun findVariantTask(template: String): Task? {
50+
return taskProvider.findTaskByName(tasksNames.resolveTaskName(template))
51+
}
5452
}

stem-plugin/src/main/java/com/likethesalad/stem/modules/common/models/TasksNamesModel.kt

+2-8
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class TasksNamesModel @AssistedInject constructor(@Assisted androidVariantData:
1818
private const val GATHER_STRING_TEMPLATES_NAME_FORMAT = "gather%sStringTemplates"
1919
private const val RESOLVE_PLACEHOLDERS_NAME_FORMAT = "resolve%sPlaceholders"
2020
private const val ANDROID_MERGE_RESOURCES_TASK_NAME_FORMAT = "merge%sResources"
21-
private const val ANDROID_PACKAGE_RESOURCES_TASK_NAME_FORMAT = "package%sResources"
22-
private const val ANDROID_EXTRACT_DEEPLINKS_TASK_NAME_FORMAT = "extractDeepLinks%s"
2321
}
2422

2523
private val capitalizedBuildVariant = androidVariantData.getVariantName().upperFirst()
@@ -40,11 +38,7 @@ class TasksNamesModel @AssistedInject constructor(@Assisted androidVariantData:
4038
ANDROID_MERGE_RESOURCES_TASK_NAME_FORMAT.format(capitalizedBuildVariant)
4139
}
4240

43-
val packageResourcesName: String by lazy {
44-
ANDROID_PACKAGE_RESOURCES_TASK_NAME_FORMAT.format(capitalizedBuildVariant)
45-
}
46-
47-
val extractDeeplinksName: String by lazy {
48-
ANDROID_EXTRACT_DEEPLINKS_TASK_NAME_FORMAT.format(capitalizedBuildVariant)
41+
fun resolveTaskName(template: String): String {
42+
return template.format(capitalizedBuildVariant)
4943
}
5044
}

stem-plugin/src/main/java/com/likethesalad/stem/utils/PlaceholderTasksCreator.kt

+19-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,25 @@ class PlaceholderTasksCreator @Inject constructor(
8181

8282
postConfigurationProvider.executeAfterEvaluate {
8383
androidVariantContext.mergeResourcesTask.dependsOn(resolvePlaceholdersTask)
84-
androidVariantContext.packageResourcesTask?.dependsOn(resolvePlaceholdersTask)
85-
androidVariantContext.extractDeeplinksTask?.dependsOn(resolvePlaceholdersTask)
84+
addExplicitDependencies(
85+
androidVariantContext,
86+
resolvePlaceholdersTask,
87+
listOf(
88+
"map%sSourceSetPaths",
89+
"package%sResources",
90+
"extractDeepLinks%s"
91+
)
92+
)
93+
}
94+
}
95+
96+
private fun addExplicitDependencies(
97+
androidVariantContext: AndroidVariantContext,
98+
resolvePlaceholdersTask: TaskProvider<ResolvePlaceholdersTask>,
99+
dependantTaskNames: List<String>
100+
) {
101+
dependantTaskNames.forEach { nameTemplate ->
102+
androidVariantContext.findVariantTask(nameTemplate)?.mustRunAfter(resolvePlaceholdersTask)
86103
}
87104
}
88105

stem-plugin/src/test/java/com/likethesalad/stem/models/TasksNamesModelTest.kt

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ class TasksNamesModelTest {
3939
Truth.assertThat(tasksNamesModel.mergeResourcesName).isEqualTo("mergeResources")
4040
}
4141

42+
@Test
43+
fun check_genericTaskName() {
44+
val tasksNamesModel = getTasksNamesFor("debug")
45+
46+
Truth.assertThat(tasksNamesModel.resolveTaskName("package%sResources")).isEqualTo("packageDebugResources")
47+
Truth.assertThat(tasksNamesModel.resolveTaskName("extractDeepLinks%s")).isEqualTo("extractDeepLinksDebug")
48+
}
49+
4250
private fun getTasksNamesFor(variantName: String): TasksNamesModel {
4351
val androidVariantData = mockk<AndroidVariantData>()
4452
every { androidVariantData.getVariantName() }.returns(variantName)

stem-test/app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55

66
android {
77
compileSdk 32
8+
namespace "com.likethesalad.stem.test"
89

910
defaultConfig {
1011
applicationId "com.likethesalad.stem.test"

stem-test/app/src/main/AndroidManifest.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.likethesalad.stem.test">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<application
65
android:allowBackup="true"

stem-test/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
android.useAndroidX=true
2-
agpTest_version=7.2.0
2+
agpTest_version=7.4.0

stem-test/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.4-bin.zip
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)