@callstack/react-native-brownfield 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gradle-plugin/brownfield/config/detekt/detekt.yml +1 -1
- package/gradle-plugin/brownfield/gradle.properties +1 -1
- package/gradle-plugin/brownfield/gradlew +0 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/expo/utils/LocalMavenUtils.kt +2 -5
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/ProjectConfigurations.kt +3 -5
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNBrownfieldPlugin.kt +20 -26
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt +23 -35
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/AssetTaskProcessor.kt +51 -16
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ExplodeTaskProvider.kt +6 -7
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt +133 -108
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ManifestTaskProcessor.kt +26 -62
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/MergeProcessor.kt +7 -29
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ProguardProcessor.kt +9 -46
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ResourceTaskProcessor.kt +49 -11
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt +52 -47
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantTaskProvider.kt +31 -63
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/BundleTaskProvider.kt +72 -27
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/Constants.kt +0 -1
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/ExplodeAarTask.kt +2 -20
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/Logging.kt +1 -1
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/MergeClassesTask.kt +70 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/MergeLibraryManifestTask.kt +178 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/AndroidArchiveLibrary.kt +0 -4
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/DirectoryManager.kt +0 -5
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt +8 -9
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Utils.kt +2 -34
- package/lib/commonjs/expo-config-plugin/android/utils/constants.js +1 -1
- package/lib/commonjs/expo-config-plugin/android/utils/formatHelpers.js +2 -0
- package/lib/commonjs/expo-config-plugin/android/utils/formatHelpers.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/android/utils/gradleHelpers.js +1 -1
- package/lib/commonjs/expo-config-plugin/android/utils/gradleHelpers.js.map +1 -1
- package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
- package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
- package/lib/commonjs/expo-config-plugin/android/withBrownfieldAndroid.js +1 -1
- package/lib/commonjs/expo-config-plugin/android/withBrownfieldAndroid.js.map +1 -1
- package/lib/commonjs/expo-config-plugin/template/android/build.gradle.kts +6 -0
- package/lib/commonjs/scripts/brownfield.js +0 -0
- package/lib/module/expo-config-plugin/android/utils/constants.js +1 -1
- package/lib/module/expo-config-plugin/android/utils/formatHelpers.js +2 -0
- package/lib/module/expo-config-plugin/android/utils/formatHelpers.js.map +1 -0
- package/lib/module/expo-config-plugin/android/utils/gradleHelpers.js +1 -1
- package/lib/module/expo-config-plugin/android/utils/gradleHelpers.js.map +1 -1
- package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
- package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
- package/lib/module/expo-config-plugin/android/withBrownfieldAndroid.js +1 -1
- package/lib/module/expo-config-plugin/android/withBrownfieldAndroid.js.map +1 -1
- package/lib/module/expo-config-plugin/template/android/build.gradle.kts +6 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
- package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/formatHelpers.d.ts +2 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/formatHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/gradleHelpers.d.ts +9 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/gradleHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +10 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
- package/lib/typescript/module/src/expo-config-plugin/android/utils/formatHelpers.d.ts +2 -0
- package/lib/typescript/module/src/expo-config-plugin/android/utils/formatHelpers.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/android/utils/gradleHelpers.d.ts +9 -1
- package/lib/typescript/module/src/expo-config-plugin/android/utils/gradleHelpers.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +10 -0
- package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/expo-config-plugin/android/utils/constants.ts +1 -1
- package/src/expo-config-plugin/android/utils/formatHelpers.ts +7 -0
- package/src/expo-config-plugin/android/utils/gradleHelpers.ts +114 -8
- package/src/expo-config-plugin/android/withAndroidModuleFiles.ts +20 -0
- package/src/expo-config-plugin/android/withBrownfieldAndroid.ts +20 -4
- package/src/expo-config-plugin/template/android/build.gradle.kts +6 -0
- package/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.ts +12 -0
- package/CHANGELOG.md +0 -300
|
@@ -1,61 +1,66 @@
|
|
|
1
1
|
package com.callstack.react.brownfield.processors
|
|
2
2
|
|
|
3
|
-
import com.callstack.react.brownfield.shared.BaseProject
|
|
4
|
-
import com.callstack.react.brownfield.utils.AndroidArchiveLibrary
|
|
5
|
-
import com.callstack.react.brownfield.utils.DirectoryManager
|
|
6
3
|
import com.callstack.react.brownfield.utils.capitalized
|
|
7
|
-
import org.gradle.api.
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private fun getClassPathDirFiles(variantName: String): ConfigurableFileCollection {
|
|
15
|
-
return project.files(
|
|
16
|
-
"$buildDir/intermediates/javac/$variantName/compile${variantName.capitalized()}JavaWithJavac/classes",
|
|
17
|
-
)
|
|
4
|
+
import org.gradle.api.Project
|
|
5
|
+
import org.gradle.api.Task
|
|
6
|
+
import org.gradle.api.tasks.TaskCollection
|
|
7
|
+
|
|
8
|
+
object VariantHelper {
|
|
9
|
+
fun getAsmTransformTaskName(capitalizedVariantName: String): String {
|
|
10
|
+
return "transform${capitalizedVariantName}ClassesWithAsm"
|
|
18
11
|
}
|
|
19
12
|
|
|
20
|
-
fun
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
pathsToDelete.add(
|
|
28
|
-
Paths.get(outputDir.absolutePath).relativize(Paths.get(path.absolutePath)),
|
|
29
|
-
)
|
|
13
|
+
fun getBundledAssetsVariantName(
|
|
14
|
+
variantName: String?,
|
|
15
|
+
buildTypeName: String?,
|
|
16
|
+
isDebuggable: Boolean,
|
|
17
|
+
): String {
|
|
18
|
+
require(!variantName.isNullOrEmpty()) {
|
|
19
|
+
"getBundledAssetsVariantName: Variant name cannot be empty"
|
|
30
20
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
|
|
22
|
+
require(!buildTypeName.isNullOrEmpty()) {
|
|
23
|
+
"getBundledAssetsVariantName: Build Type cannot be empty"
|
|
34
24
|
}
|
|
35
|
-
}
|
|
36
25
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
aarLibraries: Collection<AndroidArchiveLibrary>,
|
|
40
|
-
jarFiles: MutableList<File>,
|
|
41
|
-
variantName: String,
|
|
42
|
-
isMinifyEnabled: Boolean,
|
|
43
|
-
) {
|
|
44
|
-
MergeProcessor.mergeClassesJarIntoClasses(project, aarLibraries, outputDir)
|
|
45
|
-
if (isMinifyEnabled) {
|
|
46
|
-
MergeProcessor.mergeLibsIntoClasses(project, aarLibraries, jarFiles, outputDir)
|
|
26
|
+
if (!isDebuggable) {
|
|
27
|
+
return variantName
|
|
47
28
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
copyTask.into(javacDir)
|
|
52
|
-
copyTask.exclude("META-INF/")
|
|
29
|
+
|
|
30
|
+
if (variantName == buildTypeName) {
|
|
31
|
+
return "release"
|
|
53
32
|
}
|
|
54
33
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
34
|
+
val capitalizedBuildTypeName = buildTypeName.capitalized()
|
|
35
|
+
return if (variantName.endsWith(capitalizedBuildTypeName)) {
|
|
36
|
+
"${variantName.removeSuffix(capitalizedBuildTypeName)}Release"
|
|
37
|
+
} else {
|
|
38
|
+
"release"
|
|
59
39
|
}
|
|
60
40
|
}
|
|
41
|
+
|
|
42
|
+
fun getExpoUpdatesResourcesTaskName(variantName: String): String {
|
|
43
|
+
return "create${variantName.capitalized()}UpdatesResources"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fun getKotlinCompileTask(
|
|
47
|
+
project: Project,
|
|
48
|
+
capitalizedVariantName: String,
|
|
49
|
+
): TaskCollection<Task> {
|
|
50
|
+
return project.tasks.matching { it.name == "compile${capitalizedVariantName}Kotlin" }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fun getJavaCompileTask(
|
|
54
|
+
project: Project,
|
|
55
|
+
capitalizedVariantName: String,
|
|
56
|
+
): TaskCollection<Task> {
|
|
57
|
+
return project.tasks.matching { it.name == "compile${capitalizedVariantName}JavaWithJavac" }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fun getAsmTransformTask(
|
|
61
|
+
project: Project,
|
|
62
|
+
capitalizedVariantName: String,
|
|
63
|
+
): TaskCollection<Task> {
|
|
64
|
+
return project.tasks.matching { it.name == getAsmTransformTaskName(capitalizedVariantName) }
|
|
65
|
+
}
|
|
61
66
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
package com.callstack.react.brownfield.processors
|
|
2
2
|
|
|
3
|
-
import com.android.build.
|
|
4
|
-
import com.callstack.react.brownfield.exceptions.TaskNotFound
|
|
3
|
+
import com.android.build.api.variant.LibraryVariant
|
|
5
4
|
import com.callstack.react.brownfield.shared.ExplodeAarTask
|
|
5
|
+
import com.callstack.react.brownfield.shared.MergeClassesTask
|
|
6
6
|
import com.callstack.react.brownfield.utils.AndroidArchiveLibrary
|
|
7
7
|
import com.callstack.react.brownfield.utils.DirectoryManager
|
|
8
8
|
import com.callstack.react.brownfield.utils.Extension
|
|
@@ -12,7 +12,6 @@ import org.gradle.api.Project
|
|
|
12
12
|
import org.gradle.api.Task
|
|
13
13
|
import org.gradle.api.UnknownTaskException
|
|
14
14
|
import org.gradle.api.tasks.TaskProvider
|
|
15
|
-
import java.io.File
|
|
16
15
|
|
|
17
16
|
class VariantTaskProvider(val project: Project) {
|
|
18
17
|
fun bundleTaskProvider(
|
|
@@ -28,77 +27,46 @@ class VariantTaskProvider(val project: Project) {
|
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
fun processDataBinding(
|
|
32
|
-
bundleTask: TaskProvider<Task>,
|
|
33
|
-
aarLibraries: Collection<AndroidArchiveLibrary>,
|
|
34
|
-
variantName: String,
|
|
35
|
-
) {
|
|
36
|
-
bundleTask.configure { task ->
|
|
37
|
-
task.doLast {
|
|
38
|
-
aarLibraries.forEach {
|
|
39
|
-
val dataBindingFolder = it.getDataBindingFolder()
|
|
40
|
-
if (dataBindingFolder.exists()) {
|
|
41
|
-
val filePath = getReBundleFilePath(dataBindingFolder.name, variantName)
|
|
42
|
-
File(filePath).mkdirs()
|
|
43
|
-
project.copy { copyTask ->
|
|
44
|
-
copyTask.from(dataBindingFolder)
|
|
45
|
-
copyTask.into(filePath)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
val dataBindingLogFolder = it.getDataBindingLogFolder()
|
|
50
|
-
if (dataBindingLogFolder.exists()) {
|
|
51
|
-
val filePath = getReBundleFilePath(dataBindingLogFolder.name, variantName)
|
|
52
|
-
File(filePath).mkdirs()
|
|
53
|
-
project.copy { copyTask ->
|
|
54
|
-
copyTask.from(dataBindingLogFolder)
|
|
55
|
-
copyTask.into(filePath)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private fun getReBundleFilePath(
|
|
64
|
-
folderName: String,
|
|
65
|
-
variantName: String,
|
|
66
|
-
) = "${DirectoryManager.getReBundleDirectory(
|
|
67
|
-
variantName,
|
|
68
|
-
).path}/$folderName"
|
|
69
|
-
|
|
70
30
|
fun preBuildTaskByVariant(
|
|
71
|
-
|
|
72
|
-
buildTypeName: String,
|
|
73
|
-
isVariantDebuggable: Boolean,
|
|
31
|
+
variant: LibraryVariant,
|
|
74
32
|
explodeAarTask: TaskProvider<ExplodeAarTask>,
|
|
75
33
|
) {
|
|
76
|
-
val
|
|
77
|
-
val preBuildTask = project.tasks.named(preBuildTaskPath)
|
|
78
|
-
|
|
79
|
-
if (!preBuildTask.isPresent) {
|
|
80
|
-
throw TaskNotFound("Can not find $preBuildTaskPath task")
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
preBuildTask.dependsOn(explodeAarTask)
|
|
84
|
-
|
|
34
|
+
val variantName = variant.name
|
|
85
35
|
val bundledAssetsVariantName =
|
|
86
|
-
|
|
36
|
+
VariantHelper.getBundledAssetsVariantName(
|
|
87
37
|
variantName = variantName,
|
|
88
|
-
buildTypeName =
|
|
89
|
-
isDebuggable =
|
|
38
|
+
buildTypeName = variant.buildType,
|
|
39
|
+
isDebuggable = variant.debuggable,
|
|
90
40
|
)
|
|
91
41
|
val capitalizedBundledAssetsVariantName = bundledAssetsVariantName.capitalized()
|
|
92
42
|
|
|
93
43
|
val projectExt = project.extensions.getByType(Extension::class.java)
|
|
94
44
|
val appProject = project.rootProject.project(projectExt.appProjectName)
|
|
95
|
-
preBuildTask.dependsOn("${appProject.path}:createBundle${capitalizedBundledAssetsVariantName}JsAndAssets")
|
|
96
45
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
46
|
+
val jsBundleTaskName = "${appProject.path}:createBundle${capitalizedBundledAssetsVariantName}JsAndAssets"
|
|
47
|
+
|
|
48
|
+
variant.lifecycleTasks.registerPreBuild(explodeAarTask, jsBundleTaskName)
|
|
49
|
+
if (Utils.isExpoProject(project) && Utils.hasExpoUpdates(appProject, variantName)) {
|
|
50
|
+
val updatesResourcesTaskName = VariantHelper.getExpoUpdatesResourcesTaskName(variantName)
|
|
51
|
+
variant.lifecycleTasks.registerPreBuild("${appProject.path}:$updatesResourcesTaskName")
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fun mergeClasses(
|
|
56
|
+
aarLibraries: Collection<AndroidArchiveLibrary>,
|
|
57
|
+
explodeTasks: TaskProvider<ExplodeAarTask>,
|
|
58
|
+
variantName: String,
|
|
59
|
+
): TaskProvider<MergeClassesTask> {
|
|
60
|
+
val capitalizedVariantName = variantName.capitalized()
|
|
61
|
+
val mergeClassesTaskName = "mergeClasses$capitalizedVariantName"
|
|
62
|
+
|
|
63
|
+
return project.tasks.register(mergeClassesTaskName, MergeClassesTask::class.java) {
|
|
64
|
+
it.dependsOn(explodeTasks)
|
|
65
|
+
it.dependsOn(VariantHelper.getKotlinCompileTask(project, capitalizedVariantName))
|
|
66
|
+
it.dependsOn(VariantHelper.getJavaCompileTask(project, capitalizedVariantName))
|
|
67
|
+
it.variantName.set(variantName)
|
|
68
|
+
it.inputClassesJars.from(aarLibraries.map { aarLibrary -> aarLibrary.getClassesJarFile() })
|
|
69
|
+
it.outputDir.set(DirectoryManager.getMergeClassDirectory(variantName))
|
|
102
70
|
}
|
|
103
71
|
}
|
|
104
72
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
@file:Suppress("DEPRECATION")
|
|
2
|
-
|
|
3
1
|
package com.callstack.react.brownfield.shared
|
|
4
2
|
|
|
5
|
-
import com.android.build.
|
|
6
|
-
import com.android.build.
|
|
3
|
+
import com.android.build.api.dsl.LibraryExtension
|
|
4
|
+
import com.android.build.api.dsl.LibraryProductFlavor
|
|
5
|
+
import com.android.build.api.variant.LibraryVariant
|
|
7
6
|
import com.callstack.react.brownfield.processors.VariantTaskProvider
|
|
7
|
+
import com.callstack.react.brownfield.utils.capitalized
|
|
8
8
|
import org.gradle.api.Project
|
|
9
9
|
import org.gradle.api.Task
|
|
10
10
|
import org.gradle.api.tasks.TaskProvider
|
|
@@ -13,34 +13,79 @@ class BundleTaskProvider(private val variantTaskProvider: VariantTaskProvider) {
|
|
|
13
13
|
fun getBundleTask(
|
|
14
14
|
project: Project,
|
|
15
15
|
variant: LibraryVariant,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
missingDimensionStrategies: List<String>,
|
|
17
|
+
): TaskProvider<Task> {
|
|
18
|
+
val taskName = resolveTaskName(project, variant, missingDimensionStrategies)
|
|
19
|
+
return variantTaskProvider.bundleTaskProvider(project, taskName)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private fun resolveTaskName(
|
|
23
|
+
project: Project,
|
|
24
|
+
variant: LibraryVariant,
|
|
25
|
+
missingDimensionStrategies: List<String>,
|
|
26
|
+
): String {
|
|
27
|
+
val androidComponent = project.extensions.findByType(LibraryExtension::class.java) ?: return variant.name
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
androidExtension.productFlavors.getByName(flavor.name).missingDimensionStrategies
|
|
32
|
-
}.getOrNull() ?: return@find false
|
|
29
|
+
for (buildType in androidComponent.buildTypes) {
|
|
30
|
+
if (buildType.name != variant.name && buildType.name != variant.buildType) {
|
|
31
|
+
continue
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (androidComponent.productFlavors.isEmpty()) {
|
|
35
|
+
return buildType.name.capitalized()
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
val flavorNames = androidComponent.productFlavors.map { fl -> fl.name }
|
|
39
|
+
for (productFlavor in androidComponent.productFlavors) {
|
|
40
|
+
handleMissingDimensionStrategies(missingDimensionStrategies, project, flavorNames, productFlavor)
|
|
41
|
+
val flavorName = missingDimensionStrategies[1]
|
|
42
|
+
if (productFlavor.name != flavorName) {
|
|
43
|
+
continue
|
|
41
44
|
}
|
|
45
|
+
|
|
46
|
+
return "${productFlavor.name.capitalized()}${buildType.name.capitalized()}"
|
|
42
47
|
}
|
|
48
|
+
}
|
|
43
49
|
|
|
44
|
-
return
|
|
50
|
+
return variant.name
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private fun handleMissingDimensionStrategies(
|
|
54
|
+
missingDimensionStrategies: List<String>,
|
|
55
|
+
project: Project,
|
|
56
|
+
flavorNames: List<String>,
|
|
57
|
+
productFlavor: LibraryProductFlavor,
|
|
58
|
+
) {
|
|
59
|
+
if (missingDimensionStrategies.isEmpty()) {
|
|
60
|
+
throw MissingDimensionStrategiesException(getErrorMessage(project.name))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
val dimension = missingDimensionStrategies[0]
|
|
64
|
+
if (productFlavor.dimension != dimension) {
|
|
65
|
+
throw DimensionMismatchException(
|
|
66
|
+
"Ensure the provided dimension matches the ${project.name}'s dimension. Required dimension: $dimension",
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
val flavorName = missingDimensionStrategies[1]
|
|
71
|
+
if (!flavorNames.contains(flavorName)) {
|
|
72
|
+
throw FlavorMismatchException(
|
|
73
|
+
"Ensure the provided flavor matches the ${project.name}'s flavor. Required flavor(s): $flavorNames",
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private fun getErrorMessage(projectName: String): String {
|
|
79
|
+
return """
|
|
80
|
+
Provide `missingDimensionStrategies` for $projectName:
|
|
81
|
+
If using Expo, provide the `android.expo.missingDimensionStrategies` property from Brownfield Config.
|
|
82
|
+
If using Bare React Native, provide the `reactBrownfield.missingDimensionStrategies` property.
|
|
83
|
+
""".trimIndent()
|
|
45
84
|
}
|
|
46
85
|
}
|
|
86
|
+
|
|
87
|
+
class MissingDimensionStrategiesException(message: String) : IllegalStateException(message)
|
|
88
|
+
|
|
89
|
+
class DimensionMismatchException(message: String) : IllegalArgumentException(message)
|
|
90
|
+
|
|
91
|
+
class FlavorMismatchException(message: String) : IllegalArgumentException(message)
|
package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/Constants.kt
CHANGED
|
@@ -38,7 +38,6 @@ object Constants {
|
|
|
38
38
|
const val PROJECT_ID = "com.callstack.react.brownfield"
|
|
39
39
|
const val PLUGIN_NAME = "react-brownfield"
|
|
40
40
|
|
|
41
|
-
const val RE_BUNDLE_FOLDER = "aar_rebundle"
|
|
42
41
|
const val INTERMEDIATES_TEMP_DIR = PLUGIN_NAME
|
|
43
42
|
|
|
44
43
|
val BROWNFIELD_EXPO_TRANSITIVE_DEPS_WHITELISTED_MODULES_FOR_DISCOVERY =
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
package com.callstack.react.brownfield.shared
|
|
2
2
|
|
|
3
|
-
import com.callstack.react.brownfield.processors.VariantHelper
|
|
4
3
|
import com.callstack.react.brownfield.utils.AndroidArchiveLibrary
|
|
5
|
-
import com.callstack.react.brownfield.utils.DirectoryManager
|
|
6
4
|
import org.gradle.api.DefaultTask
|
|
7
5
|
import org.gradle.api.provider.ListProperty
|
|
8
6
|
import org.gradle.api.provider.Property
|
|
7
|
+
import org.gradle.api.tasks.CacheableTask
|
|
9
8
|
import org.gradle.api.tasks.Input
|
|
10
9
|
import org.gradle.api.tasks.Internal
|
|
11
10
|
import org.gradle.api.tasks.TaskAction
|
|
12
11
|
|
|
12
|
+
@CacheableTask
|
|
13
13
|
abstract class ExplodeAarTask : DefaultTask() {
|
|
14
14
|
@get:Internal
|
|
15
15
|
abstract val inputArtifacts: ListProperty<UnresolvedArtifactInfo>
|
|
@@ -17,25 +17,11 @@ abstract class ExplodeAarTask : DefaultTask() {
|
|
|
17
17
|
@get:Input
|
|
18
18
|
abstract val variantName: Property<String>
|
|
19
19
|
|
|
20
|
-
@get:Input
|
|
21
|
-
abstract val minifyEnabled: Property<Boolean>
|
|
22
|
-
|
|
23
20
|
@TaskAction
|
|
24
21
|
fun run() {
|
|
25
22
|
val artifacts = inputArtifacts.get()
|
|
26
23
|
val resolvedVariantName = variantName.get()
|
|
27
24
|
|
|
28
|
-
val variantHelper = VariantHelper()
|
|
29
|
-
variantHelper.project = project
|
|
30
|
-
|
|
31
|
-
// classes-merge
|
|
32
|
-
variantHelper.classesMergeTaskDoFirst(
|
|
33
|
-
DirectoryManager.getMergeClassDirectory(
|
|
34
|
-
resolvedVariantName,
|
|
35
|
-
),
|
|
36
|
-
resolvedVariantName,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
25
|
val aarLibraries = mutableListOf<AndroidArchiveLibrary>()
|
|
40
26
|
artifacts.forEach { art ->
|
|
41
27
|
val artifactFile =
|
|
@@ -64,9 +50,5 @@ abstract class ExplodeAarTask : DefaultTask() {
|
|
|
64
50
|
it.into(zipFolder)
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
|
-
|
|
68
|
-
// classes-merge
|
|
69
|
-
val mergeClassesOutputDir = DirectoryManager.getMergeClassDirectory(resolvedVariantName)
|
|
70
|
-
variantHelper.classesMergeTaskDoLast(mergeClassesOutputDir, aarLibraries, mutableListOf(), resolvedVariantName, minifyEnabled.get())
|
|
71
53
|
}
|
|
72
54
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
package com.callstack.react.brownfield.shared
|
|
2
|
+
|
|
3
|
+
import com.callstack.react.brownfield.processors.MergeProcessor
|
|
4
|
+
import com.callstack.react.brownfield.utils.DirectoryManager
|
|
5
|
+
import com.callstack.react.brownfield.utils.capitalized
|
|
6
|
+
import org.gradle.api.DefaultTask
|
|
7
|
+
import org.gradle.api.file.ConfigurableFileCollection
|
|
8
|
+
import org.gradle.api.file.DirectoryProperty
|
|
9
|
+
import org.gradle.api.provider.Property
|
|
10
|
+
import org.gradle.api.tasks.Classpath
|
|
11
|
+
import org.gradle.api.tasks.Input
|
|
12
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
13
|
+
import org.gradle.api.tasks.TaskAction
|
|
14
|
+
import java.io.File
|
|
15
|
+
import java.nio.file.Files
|
|
16
|
+
import java.nio.file.Path
|
|
17
|
+
import java.nio.file.Paths
|
|
18
|
+
|
|
19
|
+
abstract class MergeClassesTask : DefaultTask() {
|
|
20
|
+
@get:Classpath
|
|
21
|
+
abstract val inputClassesJars: ConfigurableFileCollection
|
|
22
|
+
|
|
23
|
+
@get:Input
|
|
24
|
+
abstract val variantName: Property<String>
|
|
25
|
+
|
|
26
|
+
@get:OutputDirectory
|
|
27
|
+
abstract val outputDir: DirectoryProperty
|
|
28
|
+
|
|
29
|
+
@TaskAction
|
|
30
|
+
fun run() {
|
|
31
|
+
val resolvedVariantName = variantName.get()
|
|
32
|
+
val mergedOutputDir = outputDir.get().asFile
|
|
33
|
+
val javacDir = getClassPathDir(resolvedVariantName)
|
|
34
|
+
val pathsToDelete = mutableListOf<Path>()
|
|
35
|
+
|
|
36
|
+
if (mergedOutputDir.exists()) {
|
|
37
|
+
project.fileTree(mergedOutputDir).forEach { path ->
|
|
38
|
+
pathsToDelete.add(
|
|
39
|
+
Paths.get(mergedOutputDir.absolutePath).relativize(Paths.get(path.absolutePath)),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
mergedOutputDir.deleteRecursively()
|
|
45
|
+
pathsToDelete.forEach { path ->
|
|
46
|
+
Files.deleteIfExists(javacDir.toPath().resolve(path))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
MergeProcessor.mergeClassesJarFilesIntoClasses(project, inputClassesJars.files, mergedOutputDir)
|
|
50
|
+
|
|
51
|
+
project.copy { copyTask ->
|
|
52
|
+
copyTask.from(mergedOutputDir)
|
|
53
|
+
copyTask.into(javacDir)
|
|
54
|
+
copyTask.exclude("META-INF/")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
project.copy { copyTask ->
|
|
58
|
+
copyTask.from(File(mergedOutputDir, "META-INF"))
|
|
59
|
+
copyTask.into(DirectoryManager.getKotlinMetaDirectory(resolvedVariantName))
|
|
60
|
+
copyTask.include("*.kotlin_module")
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private fun getClassPathDir(variantName: String): File {
|
|
65
|
+
val buildDirectory = project.layout.buildDirectory.get().asFile
|
|
66
|
+
return project.file(
|
|
67
|
+
"$buildDirectory/intermediates/javac/$variantName/compile${variantName.capitalized()}JavaWithJavac/classes",
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
}
|