@callstack/react-native-brownfield 6.0.0 → 6.1.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/CHANGELOG.md +52 -0
- package/gradle-plugin/brownfield/build.gradle.kts +4 -0
- package/gradle-plugin/brownfield/gradle/libs.versions.toml +2 -0
- package/gradle-plugin/brownfield/gradle.properties +1 -1
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNBrownfieldPlugin.kt +24 -7
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt +4 -37
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt +206 -104
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ResourceTaskProcessor.kt +201 -4
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt +7 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantTaskProvider.kt +4 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/GradleExclude.kt +31 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/MergeClassesTask.kt +2 -0
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/PublishingMetadataInjector.kt +28 -3
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/AndroidArchiveLibrary.kt +41 -4
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt +14 -1
- package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/TaskOutputs.kt +40 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/plugin/AgpCompatibilityMatrixTest.kt +14 -6
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/plugin/HardExcludePredicateTest.kt +28 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/ConfigureProcessJniTaskTest.kt +60 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/CopyExplodedResTaskTest.kt +368 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/JniLibsPlanTest.kt +252 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/MergeClassesLocalJarsTest.kt +73 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/MetroResDirWiringTest.kt +39 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/ProcessAndCopyJniLibsTaskTest.kt +136 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/shared/GradleExcludesTest.kt +81 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/shared/PublishingMetadataInjectorTest.kt +56 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/utils/AndroidArchiveLibraryNamespaceFallbackTest.kt +137 -0
- package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/utils/ExtensionTest.kt +5 -0
- package/ios/Expo/ExpoHostRuntime.swift +3 -1
- package/ios/Expo/ExpoUpdatesStartup.swift +2 -1
- package/lib/commonjs/expo-config-plugin/android/utils/constants.js +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/ios/podfileHelpers.js +2 -2
- package/lib/commonjs/expo-config-plugin/ios/podfileHelpers.js.map +1 -1
- package/lib/commonjs/expo-config-plugin/ios/withIosFrameworkFiles.js +1 -1
- package/lib/commonjs/expo-config-plugin/ios/withIosFrameworkFiles.js.map +1 -1
- package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js +2 -2
- package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js.map +1 -1
- package/lib/commonjs/expo-config-plugin/template/android/ReactNativeHostManager.vanilla.kt +5 -7
- package/lib/commonjs/expo-config-plugin/template/android/build.gradle.kts +1 -1
- package/lib/commonjs/expo-config-plugin/template/ios/ExpoModulesProviderExtension.swift +7 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/scaffold/index.js +1 -1
- package/lib/commonjs/scaffold/index.js.map +1 -1
- package/lib/commonjs/scaffold/projectFiles.js +1 -1
- package/lib/commonjs/scaffold/projectFiles.js.map +1 -1
- package/lib/module/expo-config-plugin/android/utils/constants.js +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/ios/podfileHelpers.js +2 -2
- package/lib/module/expo-config-plugin/ios/podfileHelpers.js.map +1 -1
- package/lib/module/expo-config-plugin/ios/withIosFrameworkFiles.js +1 -1
- package/lib/module/expo-config-plugin/ios/withIosFrameworkFiles.js.map +1 -1
- package/lib/module/expo-config-plugin/ios/xcodeHelpers.js +2 -2
- package/lib/module/expo-config-plugin/ios/xcodeHelpers.js.map +1 -1
- package/lib/module/expo-config-plugin/template/android/ReactNativeHostManager.vanilla.kt +5 -7
- package/lib/module/expo-config-plugin/template/android/build.gradle.kts +1 -1
- package/lib/module/expo-config-plugin/template/ios/ExpoModulesProviderExtension.swift +7 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/scaffold/index.js +1 -1
- package/lib/module/scaffold/index.js.map +1 -1
- package/lib/module/scaffold/projectFiles.js +1 -1
- package/lib/module/scaffold/projectFiles.js.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/podfileHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts +5 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts +5 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +6 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/scaffold/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/scaffold/projectFiles.d.ts +2 -2
- package/lib/typescript/commonjs/src/scaffold/projectFiles.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/withAndroidModuleFiles.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/ios/podfileHelpers.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts +5 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts +5 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -1
- package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +6 -0
- package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/scaffold/index.d.ts.map +1 -1
- package/lib/typescript/module/src/scaffold/projectFiles.d.ts +2 -2
- package/lib/typescript/module/src/scaffold/projectFiles.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/expo-config-plugin/android/utils/constants.ts +1 -1
- package/src/expo-config-plugin/android/withAndroidModuleFiles.ts +42 -0
- package/src/expo-config-plugin/ios/podfileHelpers.ts +47 -13
- package/src/expo-config-plugin/ios/withIosFrameworkFiles.ts +11 -1
- package/src/expo-config-plugin/ios/xcodeHelpers.ts +67 -9
- package/src/expo-config-plugin/template/android/ReactNativeHostManager.vanilla.kt +5 -7
- package/src/expo-config-plugin/template/android/build.gradle.kts +1 -1
- package/src/expo-config-plugin/template/ios/ExpoModulesProviderExtension.swift +7 -0
- package/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.ts +7 -0
- package/src/index.ts +4 -2
- package/src/scaffold/index.ts +61 -4
- package/src/scaffold/projectFiles.ts +5 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
package com.callstack.react.brownfield.processors
|
|
2
|
+
|
|
3
|
+
import com.callstack.react.brownfield.shared.ExplodeAarTask
|
|
4
|
+
import com.callstack.react.brownfield.shared.UnresolvedArtifactInfo
|
|
5
|
+
import com.callstack.react.brownfield.utils.AndroidArchiveLibrary
|
|
6
|
+
import com.callstack.react.brownfield.utils.DirectoryManager
|
|
7
|
+
import org.gradle.testfixtures.ProjectBuilder
|
|
8
|
+
import org.junit.jupiter.api.Test
|
|
9
|
+
import org.junit.jupiter.api.io.TempDir
|
|
10
|
+
import java.io.File
|
|
11
|
+
import java.util.zip.ZipEntry
|
|
12
|
+
import java.util.zip.ZipOutputStream
|
|
13
|
+
import kotlin.test.assertTrue
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A library that ships `implementation files("libs/some.jar")` has that jar in its exploded AAR's
|
|
17
|
+
* `libs/`. Its classes must be merged with the library's own `classes.jar` (#489).
|
|
18
|
+
*/
|
|
19
|
+
class MergeClassesLocalJarsTest {
|
|
20
|
+
@TempDir
|
|
21
|
+
lateinit var tempDir: File
|
|
22
|
+
|
|
23
|
+
@Test
|
|
24
|
+
fun `merges classes from a library's local jars`() {
|
|
25
|
+
val project = ProjectBuilder.builder().withProjectDir(tempDir).build()
|
|
26
|
+
DirectoryManager.project = project
|
|
27
|
+
|
|
28
|
+
val variantName = "release"
|
|
29
|
+
val library =
|
|
30
|
+
AndroidArchiveLibrary(
|
|
31
|
+
project,
|
|
32
|
+
UnresolvedArtifactInfo("RNApp", "react-native-aar-repro", "unspecified", null, false),
|
|
33
|
+
variantName,
|
|
34
|
+
)
|
|
35
|
+
val explodeTask = project.tasks.register("explodeTest", ExplodeAarTask::class.java)
|
|
36
|
+
val mergeTask = VariantTaskProvider(project).mergeClasses(listOf(library), explodeTask, variantName).get()
|
|
37
|
+
|
|
38
|
+
// Exploded after the task is configured, as on a clean build.
|
|
39
|
+
library.getExplodedAarRootDir().mkdirs()
|
|
40
|
+
writeJar(library.getClassesJarFile(), "com/aarrepro/AarReproPackage.class")
|
|
41
|
+
writeJar(
|
|
42
|
+
File(library.getLibsDir(), "aar-repro.jar"),
|
|
43
|
+
"com/aarrepro/jar/AarReproJarClass.class",
|
|
44
|
+
"module-info.class",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
mergeTask.run()
|
|
48
|
+
|
|
49
|
+
val merged = mergeTask.outputDir.get().asFile
|
|
50
|
+
assertTrue(File(merged, "com/aarrepro/AarReproPackage.class").exists(), "classes.jar was not merged")
|
|
51
|
+
assertTrue(
|
|
52
|
+
File(merged, "com/aarrepro/jar/AarReproJarClass.class").exists(),
|
|
53
|
+
"classes from libs/aar-repro.jar were not merged",
|
|
54
|
+
)
|
|
55
|
+
val javacDir = File(tempDir, "build/intermediates/javac/release/compileReleaseJavaWithJavac/classes")
|
|
56
|
+
assertTrue(File(javacDir, "com/aarrepro/jar/AarReproJarClass.class").exists(), "jar classes are not compiled into the AAR")
|
|
57
|
+
assertTrue(!File(javacDir, "module-info.class").exists(), "a jar's module-info.class ended up in the AAR")
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private fun writeJar(
|
|
61
|
+
jar: File,
|
|
62
|
+
vararg entries: String,
|
|
63
|
+
) {
|
|
64
|
+
jar.parentFile.mkdirs()
|
|
65
|
+
ZipOutputStream(jar.outputStream()).use { zip ->
|
|
66
|
+
entries.forEach { entry ->
|
|
67
|
+
zip.putNextEntry(ZipEntry(entry))
|
|
68
|
+
zip.write(byteArrayOf(0xCA.toByte(), 0xFE.toByte(), 0xBA.toByte(), 0xBE.toByte()))
|
|
69
|
+
zip.closeEntry()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.callstack.react.brownfield.processors
|
|
2
|
+
|
|
3
|
+
import org.gradle.api.DefaultTask
|
|
4
|
+
import org.gradle.api.file.DirectoryProperty
|
|
5
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
6
|
+
import org.gradle.testfixtures.ProjectBuilder
|
|
7
|
+
import org.junit.jupiter.api.Test
|
|
8
|
+
import org.junit.jupiter.api.io.TempDir
|
|
9
|
+
import java.io.File
|
|
10
|
+
import kotlin.test.assertEquals
|
|
11
|
+
import kotlin.test.assertTrue
|
|
12
|
+
|
|
13
|
+
abstract class FakeBundleTask : DefaultTask() {
|
|
14
|
+
@get:OutputDirectory
|
|
15
|
+
abstract val resourcesDir: DirectoryProperty
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class MetroResDirWiringTest {
|
|
19
|
+
@TempDir
|
|
20
|
+
lateinit var tempDir: File
|
|
21
|
+
|
|
22
|
+
@Test
|
|
23
|
+
fun `treats Metro's res output as the module's own and runs after the bundle`() {
|
|
24
|
+
val root = ProjectBuilder.builder().withProjectDir(tempDir).build()
|
|
25
|
+
val app = ProjectBuilder.builder().withName("app").withParent(root).build()
|
|
26
|
+
val lib = ProjectBuilder.builder().withName("BrownfieldLib").withParent(root).build()
|
|
27
|
+
val metroDir = File(tempDir, "app/build/generated/res/react/release")
|
|
28
|
+
val bundle =
|
|
29
|
+
app.tasks.register("createBundleReleaseJsAndAssets", FakeBundleTask::class.java) {
|
|
30
|
+
it.resourcesDir.set(metroDir)
|
|
31
|
+
}
|
|
32
|
+
val copy = lib.tasks.register("copyExplodedResForRelease", CopyExplodedResTask::class.java).get()
|
|
33
|
+
|
|
34
|
+
wireMetroResDir(copy, app, "createBundleReleaseJsAndAssets")
|
|
35
|
+
|
|
36
|
+
assertEquals(setOf(metroDir), copy.moduleResDirs.files)
|
|
37
|
+
assertTrue(bundle.get() in copy.taskDependencies.getDependencies(copy))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
package com.callstack.react.brownfield.processors
|
|
2
|
+
|
|
3
|
+
import org.gradle.api.tasks.InputDirectory
|
|
4
|
+
import org.gradle.api.tasks.InputFiles
|
|
5
|
+
import org.gradle.api.tasks.Optional
|
|
6
|
+
import org.gradle.testfixtures.ProjectBuilder
|
|
7
|
+
import org.junit.jupiter.api.Test
|
|
8
|
+
import org.junit.jupiter.api.io.TempDir
|
|
9
|
+
import java.io.File
|
|
10
|
+
import kotlin.test.assertEquals
|
|
11
|
+
import kotlin.test.assertFalse
|
|
12
|
+
import kotlin.test.assertTrue
|
|
13
|
+
|
|
14
|
+
class ProcessAndCopyJniLibsTaskTest {
|
|
15
|
+
@TempDir
|
|
16
|
+
lateinit var tempDir: File
|
|
17
|
+
|
|
18
|
+
private val out by lazy { File(tempDir, "out") }
|
|
19
|
+
private val report by lazy { File(tempDir, "reports/skipped-so.txt") }
|
|
20
|
+
|
|
21
|
+
private fun so(
|
|
22
|
+
root: File,
|
|
23
|
+
abi: String,
|
|
24
|
+
name: String,
|
|
25
|
+
content: String = name,
|
|
26
|
+
): File =
|
|
27
|
+
File(root, "$abi/$name").apply {
|
|
28
|
+
parentFile.mkdirs()
|
|
29
|
+
writeText(content)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private fun runTask(
|
|
33
|
+
aars: List<File>,
|
|
34
|
+
appDir: File,
|
|
35
|
+
extraIgnored: List<String> = emptyList(),
|
|
36
|
+
dynamic: List<String> = emptyList(),
|
|
37
|
+
) {
|
|
38
|
+
val project = ProjectBuilder.builder().withProjectDir(File(tempDir, "project")).build()
|
|
39
|
+
val task = project.tasks.register("processJniForTest", ProcessAndCopyJniLibsTask::class.java).get()
|
|
40
|
+
task.aarJniDirs.setFrom(aars)
|
|
41
|
+
task.appNativeLibsDir.set(appDir)
|
|
42
|
+
task.extraIgnoredLibs.set(extraIgnored)
|
|
43
|
+
task.dynamicLibs.set(dynamic)
|
|
44
|
+
task.outputDirectory.set(out)
|
|
45
|
+
task.skippedReportFile.set(report)
|
|
46
|
+
task.execute()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private fun outFiles(): Set<String> = out.walkTopDown().filter { it.isFile }.map { it.relativeTo(out).invariantSeparatorsPath }.toSet()
|
|
50
|
+
|
|
51
|
+
@Test
|
|
52
|
+
fun `copies the plan and clears stale output`() {
|
|
53
|
+
so(out, "arm64-v8a", "libold.so")
|
|
54
|
+
val app = File(tempDir, "app")
|
|
55
|
+
val aar = File(tempDir, "aar")
|
|
56
|
+
so(app, "arm64-v8a", "libappmodules.so", "app-bytes")
|
|
57
|
+
val aarLib = so(aar, "arm64-v8a", "libfoo.so", "aar-bytes")
|
|
58
|
+
|
|
59
|
+
runTask(listOf(aar), app)
|
|
60
|
+
|
|
61
|
+
assertEquals(setOf("arm64-v8a/libappmodules.so", "arm64-v8a/libfoo.so"), outFiles())
|
|
62
|
+
assertEquals("app-bytes", File(out, "arm64-v8a/libappmodules.so").readText())
|
|
63
|
+
assertEquals("aar-bytes", File(out, "arm64-v8a/libfoo.so").readText())
|
|
64
|
+
assertTrue(aarLib.exists(), "inputs must not be modified")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Test
|
|
68
|
+
fun `works when the app dir does not exist`() {
|
|
69
|
+
val aar = File(tempDir, "aar")
|
|
70
|
+
so(aar, "arm64-v8a", "libfoo.so")
|
|
71
|
+
|
|
72
|
+
runTask(listOf(aar), File(tempDir, "missing"))
|
|
73
|
+
|
|
74
|
+
assertEquals(setOf("arm64-v8a/libfoo.so"), outFiles())
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Test
|
|
78
|
+
fun `writes the skipped report`() {
|
|
79
|
+
val app = File(tempDir, "app")
|
|
80
|
+
val aar = File(tempDir, "aar")
|
|
81
|
+
so(app, "arm64-v8a", "libQmBlur.so")
|
|
82
|
+
so(aar, "arm64-v8a", "libreactnative.so")
|
|
83
|
+
|
|
84
|
+
runTask(listOf(aar), app)
|
|
85
|
+
|
|
86
|
+
val lines = report.readLines()
|
|
87
|
+
val expectedFirst = skippedSummary(planJniLibs(listOf(aar), app, IGNORE_EMBEDDED_LIBS, emptyList()), null)
|
|
88
|
+
assertEquals(expectedFirst, lines.first())
|
|
89
|
+
assertTrue("libQmBlur.so: NOT_EMBEDDED" in lines, lines.toString())
|
|
90
|
+
assertTrue("libreactnative.so: IGNORED" in lines, lines.toString())
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Test
|
|
94
|
+
fun `writes the skipped report when nothing is skipped`() {
|
|
95
|
+
val app = File(tempDir, "app")
|
|
96
|
+
so(app, "arm64-v8a", "libappmodules.so")
|
|
97
|
+
|
|
98
|
+
runTask(emptyList(), app)
|
|
99
|
+
|
|
100
|
+
assertEquals(listOf("No .so files were left out."), report.readLines())
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Test
|
|
104
|
+
fun `applies ignoreEmbeddedLibs and dynamicLibs`() {
|
|
105
|
+
val app = File(tempDir, "app")
|
|
106
|
+
val aar = File(tempDir, "aar")
|
|
107
|
+
so(app, "arm64-v8a", "libmmkv.so")
|
|
108
|
+
so(aar, "arm64-v8a", "libdatadog-ndk.so")
|
|
109
|
+
so(aar, "arm64-v8a", "libfoo.so")
|
|
110
|
+
|
|
111
|
+
runTask(listOf(aar), app, extraIgnored = listOf("libdatadog"), dynamic = listOf("libmmkv.so"))
|
|
112
|
+
|
|
113
|
+
assertEquals(setOf("arm64-v8a/libmmkv.so", "arm64-v8a/libfoo.so"), outFiles())
|
|
114
|
+
assertTrue("libdatadog-ndk.so: IGNORED" in report.readLines())
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Test
|
|
118
|
+
fun `app dir is not declared as an InputDirectory`() {
|
|
119
|
+
val getter = ProcessAndCopyJniLibsTask::class.java.getMethod("getAppNativeLibsDir")
|
|
120
|
+
|
|
121
|
+
assertTrue(getter.isAnnotationPresent(InputFiles::class.java))
|
|
122
|
+
assertTrue(getter.isAnnotationPresent(Optional::class.java))
|
|
123
|
+
assertFalse(getter.isAnnotationPresent(InputDirectory::class.java))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Test
|
|
127
|
+
fun `runs after the task that unpacks the embedded AARs`() {
|
|
128
|
+
val project = ProjectBuilder.builder().withProjectDir(File(tempDir, "project")).build()
|
|
129
|
+
val explode = project.tasks.register("explodeDebugAar")
|
|
130
|
+
val task = project.tasks.register("processJniForTest", ProcessAndCopyJniLibsTask::class.java).get()
|
|
131
|
+
|
|
132
|
+
wireAarJniDirs(task, listOf(File(tempDir, "exploded/jni")), explode)
|
|
133
|
+
|
|
134
|
+
assertTrue(explode.get() in task.taskDependencies.getDependencies(task))
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.callstack.react.brownfield.shared
|
|
2
|
+
|
|
3
|
+
import org.gradle.api.Project
|
|
4
|
+
import org.gradle.testfixtures.ProjectBuilder
|
|
5
|
+
import org.junit.jupiter.api.Test
|
|
6
|
+
import org.junit.jupiter.api.io.TempDir
|
|
7
|
+
import java.io.File
|
|
8
|
+
import kotlin.test.assertFalse
|
|
9
|
+
import kotlin.test.assertTrue
|
|
10
|
+
|
|
11
|
+
class GradleExcludesTest {
|
|
12
|
+
@TempDir
|
|
13
|
+
lateinit var tempDir: File
|
|
14
|
+
|
|
15
|
+
private fun project(
|
|
16
|
+
name: String,
|
|
17
|
+
vararg configNames: String,
|
|
18
|
+
): Project =
|
|
19
|
+
ProjectBuilder.builder().withName(name).withProjectDir(File(tempDir, name)).build().also { project ->
|
|
20
|
+
configNames.forEach { project.configurations.create(it) }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private fun Project.excludeEverywhere(
|
|
24
|
+
group: String,
|
|
25
|
+
module: String? = null,
|
|
26
|
+
) = configurations.all { config ->
|
|
27
|
+
config.exclude(listOfNotNull("group" to group, module?.let { "module" to it }).toMap())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private fun excluded(
|
|
31
|
+
project: Project,
|
|
32
|
+
groupId: String,
|
|
33
|
+
artifactId: String,
|
|
34
|
+
) = gradleExcludes(project).any { it.matches(groupId, artifactId) }
|
|
35
|
+
|
|
36
|
+
@Test
|
|
37
|
+
fun `honors an exclude declared on every configuration`() {
|
|
38
|
+
val lib = project("lib", "implementation", "releaseRuntimeClasspath")
|
|
39
|
+
lib.excludeEverywhere("com.caverock", "androidsvg")
|
|
40
|
+
|
|
41
|
+
assertTrue(excluded(lib, "com.caverock", "androidsvg"))
|
|
42
|
+
assertFalse(excluded(lib, "com.caverock", "androidsvg-aar"))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Test
|
|
46
|
+
fun `a group-only exclude matches every module of the group`() {
|
|
47
|
+
val lib = project("lib", "api")
|
|
48
|
+
lib.excludeEverywhere("com.caverock")
|
|
49
|
+
|
|
50
|
+
assertTrue(excluded(lib, "com.caverock", "androidsvg-aar"))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Test
|
|
54
|
+
fun `ignores a variant-specific exclude`() {
|
|
55
|
+
val lib = project("lib", "implementation", "debugRuntimeClasspath")
|
|
56
|
+
lib.configurations.getByName("debugRuntimeClasspath").exclude(mapOf("group" to "com.caverock"))
|
|
57
|
+
|
|
58
|
+
assertFalse(excluded(lib, "com.caverock", "androidsvg"))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Test
|
|
62
|
+
fun `honors an exclude on a single runtime configuration`() {
|
|
63
|
+
val lib = project("lib", "embed")
|
|
64
|
+
lib.configurations.getByName("embed").exclude(mapOf("group" to "com.caverock", "module" to "androidsvg"))
|
|
65
|
+
|
|
66
|
+
assertTrue(excluded(lib, "com.caverock", "androidsvg"))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Test
|
|
70
|
+
fun `ignores configurations that do not feed the runtime`() {
|
|
71
|
+
val lib = project("lib", "implementation", "detekt")
|
|
72
|
+
lib.configurations.getByName("detekt").exclude(mapOf("group" to "org.jetbrains.kotlin"))
|
|
73
|
+
|
|
74
|
+
assertFalse(excluded(lib, "org.jetbrains.kotlin", "kotlin-stdlib"))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Test
|
|
78
|
+
fun `matches nothing without excludes`() {
|
|
79
|
+
assertFalse(excluded(project("lib", "implementation"), "com.caverock", "androidsvg"))
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -163,6 +163,36 @@ class MutatePomDependenciesNodeTest {
|
|
|
163
163
|
|
|
164
164
|
assertEquals(listOf("1.7.1"), versionsFor(dependenciesNode, "androidx.appcompat", "appcompat"))
|
|
165
165
|
}
|
|
166
|
+
|
|
167
|
+
@Test
|
|
168
|
+
fun `writes the brownfield module's excludes onto every injected dependency`() {
|
|
169
|
+
val dependenciesNode = dependenciesNodeFrom("<project><dependencies/></project>")
|
|
170
|
+
val toInject = VersionMediatingDependencySet()
|
|
171
|
+
toInject.add(DependencyInfo("com.foo", "charts", "1.0", "compile", false))
|
|
172
|
+
val excludes = listOf(GradleExclude("com.caverock", "androidsvg"), GradleExclude("com.legacy", null))
|
|
173
|
+
|
|
174
|
+
mutatePomDependenciesNode(dependenciesNode, toInject, excludes) { _, _ -> false }
|
|
175
|
+
|
|
176
|
+
val dependency = dependenciesNode.children().filterIsInstance<groovy.util.Node>().single()
|
|
177
|
+
val exclusions =
|
|
178
|
+
((dependency["exclusions"] as NodeList).single() as groovy.util.Node).children().filterIsInstance<groovy.util.Node>()
|
|
179
|
+
assertEquals(
|
|
180
|
+
listOf("com.caverock" to "androidsvg", "com.legacy" to "*"),
|
|
181
|
+
exclusions.map { (it["groupId"] as NodeList).text() to (it["artifactId"] as NodeList).text() },
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@Test
|
|
186
|
+
fun `writes no exclusions element without excludes`() {
|
|
187
|
+
val dependenciesNode = dependenciesNodeFrom("<project><dependencies/></project>")
|
|
188
|
+
val toInject = VersionMediatingDependencySet()
|
|
189
|
+
toInject.add(DependencyInfo("com.foo", "charts", "1.0", "compile", false))
|
|
190
|
+
|
|
191
|
+
mutatePomDependenciesNode(dependenciesNode, toInject) { _, _ -> false }
|
|
192
|
+
|
|
193
|
+
val dependency = dependenciesNode.children().filterIsInstance<groovy.util.Node>().single()
|
|
194
|
+
assertTrue((dependency["exclusions"] as NodeList).isEmpty())
|
|
195
|
+
}
|
|
166
196
|
}
|
|
167
197
|
|
|
168
198
|
class MutateModuleJsonVariantsTest {
|
|
@@ -219,4 +249,30 @@ class MutateModuleJsonVariantsTest {
|
|
|
219
249
|
val version = (deps.first()["version"] as? Map<String, Any>)?.get("requires")
|
|
220
250
|
assertEquals("1.7.1", version)
|
|
221
251
|
}
|
|
252
|
+
|
|
253
|
+
@Test
|
|
254
|
+
fun `writes the brownfield module's excludes onto every injected dependency`() {
|
|
255
|
+
val json = jsonWithVariant(mutableListOf())
|
|
256
|
+
val toInject = VersionMediatingDependencySet()
|
|
257
|
+
toInject.add(DependencyInfo("com.foo", "charts", "1.0", "compile", false))
|
|
258
|
+
val excludes = listOf(GradleExclude("com.caverock", "androidsvg"), GradleExclude("com.legacy", null))
|
|
259
|
+
|
|
260
|
+
mutateModuleJsonVariants(json, toInject, excludes) { _, _ -> false }
|
|
261
|
+
|
|
262
|
+
assertEquals(
|
|
263
|
+
listOf(mapOf("group" to "com.caverock", "module" to "androidsvg"), mapOf("group" to "com.legacy", "module" to "*")),
|
|
264
|
+
dependenciesOf(json).single()["excludes"],
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@Test
|
|
269
|
+
fun `writes no excludes field without excludes`() {
|
|
270
|
+
val json = jsonWithVariant(mutableListOf())
|
|
271
|
+
val toInject = VersionMediatingDependencySet()
|
|
272
|
+
toInject.add(DependencyInfo("com.foo", "charts", "1.0", "compile", false))
|
|
273
|
+
|
|
274
|
+
mutateModuleJsonVariants(json, toInject) { _, _ -> false }
|
|
275
|
+
|
|
276
|
+
assertNull(dependenciesOf(json).single()["excludes"])
|
|
277
|
+
}
|
|
222
278
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
package com.callstack.react.brownfield.utils
|
|
2
|
+
|
|
3
|
+
import com.callstack.react.brownfield.shared.UnresolvedArtifactInfo
|
|
4
|
+
import org.gradle.testfixtures.ProjectBuilder
|
|
5
|
+
import org.junit.jupiter.api.Test
|
|
6
|
+
import kotlin.test.assertEquals
|
|
7
|
+
import kotlin.test.assertFailsWith
|
|
8
|
+
|
|
9
|
+
class AndroidArchiveLibraryNamespaceFallbackTest {
|
|
10
|
+
private fun artifactFor(moduleName: String) =
|
|
11
|
+
UnresolvedArtifactInfo(
|
|
12
|
+
moduleGroup = "com.example",
|
|
13
|
+
moduleName = moduleName,
|
|
14
|
+
moduleVersion = "1.0.0",
|
|
15
|
+
file = null,
|
|
16
|
+
isExpoPublishDependency = false,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
@Test
|
|
20
|
+
fun `falls back to the AndroidManifest package when build-gradle declares no namespace`() {
|
|
21
|
+
val root = ProjectBuilder.builder().build()
|
|
22
|
+
val subProject =
|
|
23
|
+
ProjectBuilder.builder()
|
|
24
|
+
.withParent(root)
|
|
25
|
+
.withName("react-native-launch-arguments")
|
|
26
|
+
.build()
|
|
27
|
+
|
|
28
|
+
// No `namespace` declaration, mirroring libraries whose build.gradle predates AGP namespaces.
|
|
29
|
+
subProject.projectDir.mkdirs()
|
|
30
|
+
subProject.buildFile.writeText(
|
|
31
|
+
"""
|
|
32
|
+
apply plugin: 'com.android.library'
|
|
33
|
+
""".trimIndent(),
|
|
34
|
+
)
|
|
35
|
+
subProject.projectDir.resolve("src/main").mkdirs()
|
|
36
|
+
subProject.projectDir.resolve("src/main/AndroidManifest.xml").writeText(
|
|
37
|
+
"""
|
|
38
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
39
|
+
package="com.reactnativelauncharguments">
|
|
40
|
+
</manifest>
|
|
41
|
+
""".trimIndent(),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
val library = AndroidArchiveLibrary(root, artifactFor("react-native-launch-arguments"), "devRelease")
|
|
45
|
+
|
|
46
|
+
assertEquals("com.reactnativelauncharguments", library.getPackageName())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Test
|
|
50
|
+
fun `prefers the namespace declared in build-gradle over the manifest package`() {
|
|
51
|
+
val root = ProjectBuilder.builder().build()
|
|
52
|
+
val subProject =
|
|
53
|
+
ProjectBuilder.builder()
|
|
54
|
+
.withParent(root)
|
|
55
|
+
.withName("react-native-screens")
|
|
56
|
+
.build()
|
|
57
|
+
|
|
58
|
+
subProject.projectDir.mkdirs()
|
|
59
|
+
subProject.buildFile.writeText(
|
|
60
|
+
"""
|
|
61
|
+
apply plugin: 'com.android.library'
|
|
62
|
+
android {
|
|
63
|
+
namespace = "com.swmansion.rnscreens"
|
|
64
|
+
}
|
|
65
|
+
""".trimIndent(),
|
|
66
|
+
)
|
|
67
|
+
subProject.projectDir.resolve("src/main").mkdirs()
|
|
68
|
+
subProject.projectDir.resolve("src/main/AndroidManifest.xml").writeText(
|
|
69
|
+
"""
|
|
70
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
71
|
+
package="com.swmansion.rnscreens.legacy">
|
|
72
|
+
</manifest>
|
|
73
|
+
""".trimIndent(),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
val library = AndroidArchiveLibrary(root, artifactFor("react-native-screens"), "devRelease")
|
|
77
|
+
|
|
78
|
+
assertEquals("com.swmansion.rnscreens", library.getPackageName())
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Test
|
|
82
|
+
fun `reads the package from the manifest root element and ignores comments and child attributes`() {
|
|
83
|
+
val root = ProjectBuilder.builder().build()
|
|
84
|
+
val subProject =
|
|
85
|
+
ProjectBuilder.builder()
|
|
86
|
+
.withParent(root)
|
|
87
|
+
.withName("react-native-legacy-manifest")
|
|
88
|
+
.build()
|
|
89
|
+
|
|
90
|
+
subProject.projectDir.mkdirs()
|
|
91
|
+
subProject.buildFile.writeText(
|
|
92
|
+
"""
|
|
93
|
+
apply plugin: 'com.android.library'
|
|
94
|
+
""".trimIndent(),
|
|
95
|
+
)
|
|
96
|
+
subProject.projectDir.resolve("src/main").mkdirs()
|
|
97
|
+
subProject.projectDir.resolve("src/main/AndroidManifest.xml").writeText(
|
|
98
|
+
"""
|
|
99
|
+
<!-- legacy location: package="com.example.stale" -->
|
|
100
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
101
|
+
package="com.reactnativelegacymanifest">
|
|
102
|
+
<application>
|
|
103
|
+
<activity
|
|
104
|
+
android:name=".LegacyActivity"
|
|
105
|
+
android:exported="false"
|
|
106
|
+
android:targetPackage="com.example.target" />
|
|
107
|
+
</application>
|
|
108
|
+
</manifest>
|
|
109
|
+
""".trimIndent(),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
val library = AndroidArchiveLibrary(root, artifactFor("react-native-legacy-manifest"), "devRelease")
|
|
113
|
+
|
|
114
|
+
assertEquals("com.reactnativelegacymanifest", library.getPackageName())
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Test
|
|
118
|
+
fun `errors when neither build-gradle nor the manifest declare a namespace`() {
|
|
119
|
+
val root = ProjectBuilder.builder().build()
|
|
120
|
+
val subProject =
|
|
121
|
+
ProjectBuilder.builder()
|
|
122
|
+
.withParent(root)
|
|
123
|
+
.withName("no-namespace-anywhere")
|
|
124
|
+
.build()
|
|
125
|
+
|
|
126
|
+
subProject.projectDir.mkdirs()
|
|
127
|
+
subProject.buildFile.writeText(
|
|
128
|
+
"""
|
|
129
|
+
apply plugin: 'com.android.library'
|
|
130
|
+
""".trimIndent(),
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
val library = AndroidArchiveLibrary(root, artifactFor("no-namespace-anywhere"), "devRelease")
|
|
134
|
+
|
|
135
|
+
assertFailsWith<IllegalStateException> { library.getPackageName() }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -8,4 +8,9 @@ class ExtensionTest {
|
|
|
8
8
|
fun `experimentalIncludeTransitiveDependencies defaults to true`() {
|
|
9
9
|
assertTrue(Extension().experimentalIncludeTransitiveDependencies)
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
@Test
|
|
13
|
+
fun `dynamicLibs defaults to an empty list`() {
|
|
14
|
+
assertTrue(Extension().dynamicLibs.isEmpty())
|
|
15
|
+
}
|
|
11
16
|
}
|
|
@@ -299,6 +299,7 @@ class ExpoHostRuntimeDelegate: ExpoReactNativeFactoryDelegate {
|
|
|
299
299
|
#if canImport(EXUpdates)
|
|
300
300
|
if AppController.isInitialized(),
|
|
301
301
|
AppController.sharedInstance.isActiveController,
|
|
302
|
+
AppController.sharedInstance.isStarted,
|
|
302
303
|
let launchAssetURL = AppController.sharedInstance.launchAssetUrl()
|
|
303
304
|
{
|
|
304
305
|
return launchAssetURL
|
|
@@ -343,7 +344,8 @@ class ExpoHostRuntimeDelegate: ExpoReactNativeFactoryDelegate {
|
|
|
343
344
|
#if canImport(EXUpdates)
|
|
344
345
|
guard AppController.isInitialized() else { return false }
|
|
345
346
|
return !AppController.sharedInstance.isActiveController
|
|
346
|
-
|| AppController.sharedInstance.
|
|
347
|
+
|| (AppController.sharedInstance.isStarted
|
|
348
|
+
&& AppController.sharedInstance.launchAssetUrl() != nil)
|
|
347
349
|
#else
|
|
348
350
|
return true
|
|
349
351
|
#endif
|
|
@@ -16,7 +16,8 @@ final class ExpoUpdatesStartup: NSObject {
|
|
|
16
16
|
AppController.initializeWithoutStarting()
|
|
17
17
|
let controller = AppController.sharedInstance
|
|
18
18
|
guard controller.isActiveController else { completion(); return }
|
|
19
|
-
|
|
19
|
+
// expo-updates 57 traps in launchAssetUrl() until start() sets its startup procedure.
|
|
20
|
+
if updatesReady || (controller.isStarted && controller.launchAssetUrl() != nil) {
|
|
20
21
|
completion()
|
|
21
22
|
return
|
|
22
23
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.brownfieldGradlePluginDependency=exports.BROWNFIELD_PLUGIN_VERSION=void 0;var BROWNFIELD_PLUGIN_VERSION=exports.BROWNFIELD_PLUGIN_VERSION='2.0.0-
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.brownfieldGradlePluginDependency=exports.BROWNFIELD_PLUGIN_VERSION=void 0;var BROWNFIELD_PLUGIN_VERSION=exports.BROWNFIELD_PLUGIN_VERSION='2.0.0-alpha14';var brownfieldGradlePluginDependency=exports.brownfieldGradlePluginDependency=`classpath("com.callstack.react:brownfield-gradle-plugin:${BROWNFIELD_PLUGIN_VERSION}")`;
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR=void 0;exports.createAndroidModule=createAndroidModule;exports.renderTargetSdkBlock=renderTargetSdkBlock;exports.resolveCompileSdkVersionExpression=resolveCompileSdkVersionExpression;exports.resolveTargetSdkVersionExpression=resolveTargetSdkVersionExpression;exports.syncAndroidModuleExpoUpdatesFromAppFiles=syncAndroidModuleExpoUpdatesFromAppFiles;exports.syncAndroidModuleManifest=syncAndroidModuleManifest;exports.syncAndroidModuleStringResources=syncAndroidModuleStringResources;exports.withAndroidModuleFiles=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var fs=_interopRequireWildcard(require("node:fs"));var path=_interopRequireWildcard(require("node:path"));var _configPlugins=require("@expo/config-plugins");var _logging=require("../logging");var _engine=require("../template/engine");var _expoUtils=require("../expoUtils");var _androidManifest=require("./utils/androidManifest");var _expoUpdates=require("./utils/expo-updates");var _hermes=require("./utils/hermes");var _formatHelpers=require("./utils/formatHelpers");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t in e)"default"!==_t&&{}.hasOwnProperty.call(e,_t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t))&&(i.get||i.set)?o(f,_t,i):f[_t]=e[_t]);return f;})(e,t);}var EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR=exports.EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR=58;function renderMissingDimensionStrategyBlock(missingDimensionStrategies){if(missingDimensionStrategies.length<2){return'';}var args=(0,_formatHelpers.formatMissingDimensionStrategies)(missingDimensionStrategies);return` missingDimensionStrategy(${args})`;}function resolveCompileSdkVersionExpression(config){if(config.android.compileSdkVersion!=null){return config.android.compileSdkVersion.toString();}return'resolveRootProjectInt("compileSdkVersion")';}function resolveTargetSdkVersionExpression(config){if(config.android.targetSdkVersion!=null){return config.android.targetSdkVersion.toString();}return'resolveRootProjectInt("targetSdkVersion")';}function renderTargetSdkBlock(config,expoMajor){var templateVariant=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'expo';if(templateVariant==='vanilla'){return'';}if(expoMajor!==undefined&&expoMajor>=EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR){return'';}return`\n targetSdk = ${resolveTargetSdkVersionExpression(config)}`;}function createAndroidModule(_ref){var _minifyEnabled,_extraProguardRules;var androidDir=_ref.androidDir,config=_ref.config,rnVersion=_ref.rnVersion,projectRoot=_ref.projectRoot,expoMajor=_ref.expoMajor,_ref$templateVariant=_ref.templateVariant,templateVariant=_ref$templateVariant===void 0?'expo':_ref$templateVariant;var android=config.android;var moduleDir=path.join(androidDir,android.moduleName);_logging.Logger.logDebug(`Creating Android module in: ${androidDir}`);var hermesArtifact=(0,_hermes.getHermesArtifact)(rnVersion,projectRoot);var compileSdkVersionExpression=resolveCompileSdkVersionExpression(config);var targetSdkBlock=renderTargetSdkBlock(config,expoMajor,templateVariant);var minifyEnabled=(_minifyEnabled=android.minifyEnabled)!=null?_minifyEnabled:false;var extraProguardRules=(_extraProguardRules=android.extraProguardRules)!=null?_extraProguardRules:[];var extraProguardRulesText=extraProguardRules.join('\n');_logging.Logger.logDebug(`Resolved Hermes artifact: ${hermesArtifact.groupId}:${hermesArtifact.artifactId}:${hermesArtifact.version}`);var missingDimensionStrategiesList=(0,_formatHelpers.formatMissingDimensionStrategies)(android.missingDimensionStrategies);var missingDimensionStrategyBlock=renderMissingDimensionStrategyBlock(android.missingDimensionStrategies);var files=[{relativePath:'build.gradle.kts',content:(0,_engine.renderTemplate)('android','build.gradle.kts',{'{{PACKAGE_NAME}}':android.packageName,'{{MIN_SDK_VERSION}}':android.minSdkVersion.toString(),'{{TARGET_SDK_BLOCK}}':targetSdkBlock,'{{COMPILE_SDK_VERSION}}':compileSdkVersionExpression,'{{GROUP_ID}}':android.groupId,'{{ARTIFACT_ID}}':android.artifactId,'{{ARTIFACT_VERSION}}':android.version,'{{RN_VERSION}}':rnVersion,'{{HERMES_ARTIFACT}}':`${hermesArtifact.groupId}:${hermesArtifact.artifactId}:${hermesArtifact.version}`,'{{IS_MINIFY_ENABLED}}':minifyEnabled.toString(),'{{MISSING_DIMENSION_STRATEGIES}}':missingDimensionStrategiesList,'{{MISSING_DIMENSION_STRATEGY_BLOCK}}':missingDimensionStrategyBlock})},{relativePath:'gradle.properties',content:(0,_engine.renderTemplate)('android','gradle.properties',{})},{relativePath:`src/main/java/${config.android.packageName.replace(/\./g,'/')}/ReactNativeHostManager.kt`,content:(0,_engine.renderTemplate)('android',templateVariant==='vanilla'?'ReactNativeHostManager.vanilla.kt':'ReactNativeHostManager.post55.kt',{'{{PACKAGE_NAME}}':android.packageName})},{relativePath:'consumer-rules.pro',content:(0,_engine.renderTemplate)('android','consumer-rules.pro',{})},{relativePath:'proguard-rules.pro',content:(0,_engine.renderTemplate)('android','proguard-rules.pro',{'{{PACKAGE_NAME}}':android.packageName,'{{EXTRA_PROGUARD_RULES}}':extraProguardRulesText})}];for(var file of files){var filePath=path.join(moduleDir,file.relativePath);var fileDir=path.dirname(filePath);if(!fs.existsSync(fileDir)){fs.mkdirSync(fileDir,{recursive:true});}fs.writeFileSync(filePath,file.content,'utf8');_logging.Logger.logDebug(`Created file: ${filePath}`);}syncAndroidModuleExpoUpdatesFromAppFiles({androidDir:androidDir,config:config});_logging.Logger.logDebug(`Android module "${android.moduleName}" created at ${moduleDir}`);}function syncAndroidModuleManifest(_ref2){var androidDir=_ref2.androidDir,config=_ref2.config,expoUpdatesMetaData=_ref2.expoUpdatesMetaData;writeAndroidModuleFile(path.join(androidDir,config.android.moduleName),'src/main/AndroidManifest.xml',(0,_engine.renderTemplate)('android','AndroidManifest.xml',{'{{APPLICATION_BLOCK}}':(0,_androidManifest.renderLibraryManifestApplication)(expoUpdatesMetaData)}));}function syncAndroidModuleStringResources(_ref3){var androidDir=_ref3.androidDir,config=_ref3.config,expoUpdatesStringResources=_ref3.expoUpdatesStringResources;writeAndroidModuleFile(path.join(androidDir,config.android.moduleName),'src/main/res/values/strings.xml',(0,_engine.renderTemplate)('android','strings.xml',{'{{STRING_RESOURCES}}':(0,_androidManifest.renderLibraryStringResources)(expoUpdatesStringResources)}));}function writeAndroidModuleFile(moduleDir,relativePath,content){var filePath=path.join(moduleDir,relativePath);var fileDir=path.dirname(filePath);if(!fs.existsSync(fileDir)){fs.mkdirSync(fileDir,{recursive:true});}fs.writeFileSync(filePath,content,'utf8');_logging.Logger.logDebug(`Created file: ${filePath}`);}function syncAndroidModuleExpoUpdatesFromAppFiles(_ref4){var androidDir=_ref4.androidDir,config=_ref4.config;var appModuleName='app';var expoUpdatesMetaData=(0,_expoUpdates.readExpoUpdatesApplicationMetaData)(androidDir,appModuleName);var expoUpdatesStringResources=(0,_expoUpdates.readExpoUpdatesStringResources)(androidDir,appModuleName,expoUpdatesMetaData);syncAndroidModuleManifest({androidDir:androidDir,config:config,expoUpdatesMetaData:expoUpdatesMetaData});syncAndroidModuleStringResources({androidDir:androidDir,config:config,expoUpdatesStringResources:expoUpdatesStringResources});}var withAndroidModuleFiles=exports.withAndroidModuleFiles=function withAndroidModuleFiles(config,props){return(0,_configPlugins.withDangerousMod)(config,['android',(function(){var _ref5=(0,_asyncToGenerator2.default)(function*(dangerousConfig){var androidDir=path.join(dangerousConfig.modRequest.projectRoot,'android');var rnVersion;try{var rnPkgPath=require.resolve('react-native/package.json',{paths:[dangerousConfig.modRequest.projectRoot]});var rnPkg=require(rnPkgPath);rnVersion=rnPkg.version;_logging.Logger.logDebug(`Resolved react-native version: ${rnVersion}`);}catch(_unused){throw new Error('Could not resolve react-native package version. Please ensure you have installed dependencies.');}createAndroidModule({androidDir:androidDir,config:props,rnVersion:rnVersion,projectRoot:dangerousConfig.modRequest.projectRoot,expoMajor:(0,_expoUtils.getExpoInfo)(dangerousConfig).expoMajor});return dangerousConfig;});return function(_x){return _ref5.apply(this,arguments);};}())]);};
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR=void 0;exports.createAndroidModule=createAndroidModule;exports.renderTargetSdkBlock=renderTargetSdkBlock;exports.resolveCompileSdkVersionExpression=resolveCompileSdkVersionExpression;exports.resolveTargetSdkVersionExpression=resolveTargetSdkVersionExpression;exports.syncAndroidModuleExpoUpdatesFromAppFiles=syncAndroidModuleExpoUpdatesFromAppFiles;exports.syncAndroidModuleManifest=syncAndroidModuleManifest;exports.syncAndroidModuleStringResources=syncAndroidModuleStringResources;exports.withAndroidModuleFiles=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var fs=_interopRequireWildcard(require("node:fs"));var path=_interopRequireWildcard(require("node:path"));var _configPlugins=require("@expo/config-plugins");var _logging=require("../logging");var _engine=require("../template/engine");var _expoUtils=require("../expoUtils");var _androidManifest=require("./utils/androidManifest");var _expoUpdates=require("./utils/expo-updates");var _hermes=require("./utils/hermes");var _formatHelpers=require("./utils/formatHelpers");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t in e)"default"!==_t&&{}.hasOwnProperty.call(e,_t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t))&&(i.get||i.set)?o(f,_t,i):f[_t]=e[_t]);return f;})(e,t);}var EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR=exports.EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR=58;function renderMissingDimensionStrategyBlock(missingDimensionStrategies){if(missingDimensionStrategies.length<2){return'';}var args=(0,_formatHelpers.formatMissingDimensionStrategies)(missingDimensionStrategies);return` missingDimensionStrategy(${args})`;}var COORDINATE_PART=/^[A-Za-z0-9._-]+$/;function renderExcludeDependenciesBlock(excludeDependencies){if(!Array.isArray(excludeDependencies)){throw new Error('android.excludeDependencies must be a list of "group:module" or "group" strings.');}if(excludeDependencies.length===0){return'';}var lines=excludeDependencies.map(function(entry){var parts=entry.split(':');if(parts.length>2||!parts.every(function(part){return COORDINATE_PART.test(part);})){throw new Error(`android.excludeDependencies: '${entry}' is not in the form "group:module" or "group".`);}var _parts=(0,_slicedToArray2.default)(parts,2),group=_parts[0],module=_parts[1];return module?` exclude(group = "${group}", module = "${module}")`:` exclude(group = "${group}")`;});return`configurations.all {\n${lines.join('\n')}\n}\n\n`;}function resolveCompileSdkVersionExpression(config){if(config.android.compileSdkVersion!=null){return config.android.compileSdkVersion.toString();}return'resolveRootProjectInt("compileSdkVersion")';}function resolveTargetSdkVersionExpression(config){if(config.android.targetSdkVersion!=null){return config.android.targetSdkVersion.toString();}return'resolveRootProjectInt("targetSdkVersion")';}function renderTargetSdkBlock(config,expoMajor){var templateVariant=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'expo';if(templateVariant==='vanilla'){return'';}if(expoMajor!==undefined&&expoMajor>=EXPO_SDK_OMIT_TARGET_SDK_FROM_MAJOR){return'';}return`\n targetSdk = ${resolveTargetSdkVersionExpression(config)}`;}function createAndroidModule(_ref){var _minifyEnabled,_extraProguardRules;var androidDir=_ref.androidDir,config=_ref.config,rnVersion=_ref.rnVersion,projectRoot=_ref.projectRoot,expoMajor=_ref.expoMajor,_ref$templateVariant=_ref.templateVariant,templateVariant=_ref$templateVariant===void 0?'expo':_ref$templateVariant;var android=config.android;var moduleDir=path.join(androidDir,android.moduleName);_logging.Logger.logDebug(`Creating Android module in: ${androidDir}`);var hermesArtifact=(0,_hermes.getHermesArtifact)(rnVersion,projectRoot);var compileSdkVersionExpression=resolveCompileSdkVersionExpression(config);var targetSdkBlock=renderTargetSdkBlock(config,expoMajor,templateVariant);var minifyEnabled=(_minifyEnabled=android.minifyEnabled)!=null?_minifyEnabled:false;var extraProguardRules=(_extraProguardRules=android.extraProguardRules)!=null?_extraProguardRules:[];var extraProguardRulesText=extraProguardRules.join('\n');_logging.Logger.logDebug(`Resolved Hermes artifact: ${hermesArtifact.groupId}:${hermesArtifact.artifactId}:${hermesArtifact.version}`);var missingDimensionStrategiesList=(0,_formatHelpers.formatMissingDimensionStrategies)(android.missingDimensionStrategies);var missingDimensionStrategyBlock=renderMissingDimensionStrategyBlock(android.missingDimensionStrategies);var excludeDependenciesBlock=renderExcludeDependenciesBlock(android.excludeDependencies);var files=[{relativePath:'build.gradle.kts',content:(0,_engine.renderTemplate)('android','build.gradle.kts',{'{{PACKAGE_NAME}}':android.packageName,'{{MIN_SDK_VERSION}}':android.minSdkVersion.toString(),'{{TARGET_SDK_BLOCK}}':targetSdkBlock,'{{COMPILE_SDK_VERSION}}':compileSdkVersionExpression,'{{GROUP_ID}}':android.groupId,'{{ARTIFACT_ID}}':android.artifactId,'{{ARTIFACT_VERSION}}':android.version,'{{RN_VERSION}}':rnVersion,'{{HERMES_ARTIFACT}}':`${hermesArtifact.groupId}:${hermesArtifact.artifactId}:${hermesArtifact.version}`,'{{IS_MINIFY_ENABLED}}':minifyEnabled.toString(),'{{MISSING_DIMENSION_STRATEGIES}}':missingDimensionStrategiesList,'{{MISSING_DIMENSION_STRATEGY_BLOCK}}':missingDimensionStrategyBlock,'{{EXCLUDE_DEPENDENCIES_BLOCK}}':excludeDependenciesBlock})},{relativePath:'gradle.properties',content:(0,_engine.renderTemplate)('android','gradle.properties',{})},{relativePath:`src/main/java/${config.android.packageName.replace(/\./g,'/')}/ReactNativeHostManager.kt`,content:(0,_engine.renderTemplate)('android',templateVariant==='vanilla'?'ReactNativeHostManager.vanilla.kt':'ReactNativeHostManager.post55.kt',{'{{PACKAGE_NAME}}':android.packageName})},{relativePath:'consumer-rules.pro',content:(0,_engine.renderTemplate)('android','consumer-rules.pro',{})},{relativePath:'proguard-rules.pro',content:(0,_engine.renderTemplate)('android','proguard-rules.pro',{'{{PACKAGE_NAME}}':android.packageName,'{{EXTRA_PROGUARD_RULES}}':extraProguardRulesText})}];for(var file of files){var filePath=path.join(moduleDir,file.relativePath);var fileDir=path.dirname(filePath);if(!fs.existsSync(fileDir)){fs.mkdirSync(fileDir,{recursive:true});}fs.writeFileSync(filePath,file.content,'utf8');_logging.Logger.logDebug(`Created file: ${filePath}`);}syncAndroidModuleExpoUpdatesFromAppFiles({androidDir:androidDir,config:config});_logging.Logger.logDebug(`Android module "${android.moduleName}" created at ${moduleDir}`);}function syncAndroidModuleManifest(_ref2){var androidDir=_ref2.androidDir,config=_ref2.config,expoUpdatesMetaData=_ref2.expoUpdatesMetaData;writeAndroidModuleFile(path.join(androidDir,config.android.moduleName),'src/main/AndroidManifest.xml',(0,_engine.renderTemplate)('android','AndroidManifest.xml',{'{{APPLICATION_BLOCK}}':(0,_androidManifest.renderLibraryManifestApplication)(expoUpdatesMetaData)}));}function syncAndroidModuleStringResources(_ref3){var androidDir=_ref3.androidDir,config=_ref3.config,expoUpdatesStringResources=_ref3.expoUpdatesStringResources;writeAndroidModuleFile(path.join(androidDir,config.android.moduleName),'src/main/res/values/strings.xml',(0,_engine.renderTemplate)('android','strings.xml',{'{{STRING_RESOURCES}}':(0,_androidManifest.renderLibraryStringResources)(expoUpdatesStringResources)}));}function writeAndroidModuleFile(moduleDir,relativePath,content){var filePath=path.join(moduleDir,relativePath);var fileDir=path.dirname(filePath);if(!fs.existsSync(fileDir)){fs.mkdirSync(fileDir,{recursive:true});}fs.writeFileSync(filePath,content,'utf8');_logging.Logger.logDebug(`Created file: ${filePath}`);}function syncAndroidModuleExpoUpdatesFromAppFiles(_ref4){var androidDir=_ref4.androidDir,config=_ref4.config;var appModuleName='app';var expoUpdatesMetaData=(0,_expoUpdates.readExpoUpdatesApplicationMetaData)(androidDir,appModuleName);var expoUpdatesStringResources=(0,_expoUpdates.readExpoUpdatesStringResources)(androidDir,appModuleName,expoUpdatesMetaData);syncAndroidModuleManifest({androidDir:androidDir,config:config,expoUpdatesMetaData:expoUpdatesMetaData});syncAndroidModuleStringResources({androidDir:androidDir,config:config,expoUpdatesStringResources:expoUpdatesStringResources});}var withAndroidModuleFiles=exports.withAndroidModuleFiles=function withAndroidModuleFiles(config,props){return(0,_configPlugins.withDangerousMod)(config,['android',(function(){var _ref5=(0,_asyncToGenerator2.default)(function*(dangerousConfig){var androidDir=path.join(dangerousConfig.modRequest.projectRoot,'android');var rnVersion;try{var rnPkgPath=require.resolve('react-native/package.json',{paths:[dangerousConfig.modRequest.projectRoot]});var rnPkg=require(rnPkgPath);rnVersion=rnPkg.version;_logging.Logger.logDebug(`Resolved react-native version: ${rnVersion}`);}catch(_unused){throw new Error('Could not resolve react-native package version. Please ensure you have installed dependencies.');}createAndroidModule({androidDir:androidDir,config:props,rnVersion:rnVersion,projectRoot:dangerousConfig.modRequest.projectRoot,expoMajor:(0,_expoUtils.getExpoInfo)(dangerousConfig).expoMajor});return dangerousConfig;});return function(_x){return _ref5.apply(this,arguments);};}())]);};
|
|
2
2
|
//# sourceMappingURL=withAndroidModuleFiles.js.map
|