@forthtilliath/expo-config-plugins 0.1.0 → 0.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/README.md CHANGED
@@ -19,7 +19,8 @@ npm install --save-dev @forthtilliath/expo-config-plugins
19
19
  { "propertyPrefix": "MYAPP" }
20
20
  ],
21
21
  "@forthtilliath/expo-config-plugins/withAndroidAbis",
22
- "@forthtilliath/expo-config-plugins/withShortCxxPath"
22
+ "@forthtilliath/expo-config-plugins/withShortCxxPath",
23
+ "@forthtilliath/expo-config-plugins/withKotlinJvmTarget"
23
24
  ]
24
25
  }
25
26
  }
@@ -59,9 +60,17 @@ On Windows, release builds can overflow the 260-character path limit inside `and
59
60
  | ------------ | -------- | --------------------------------- |
60
61
  | `stagingDir` | `string` | `C:/rncxx` on Windows, else unset |
61
62
 
63
+ ## `withKotlinJvmTarget` — one JVM target for Kotlin
64
+
65
+ Some native modules (e.g. `expo-dynamic-app-icon`) compile their Kotlin code for another JVM target than the project's Java code, and the build fails with "Inconsistent JVM-target compatibility". This plugin appends a block to `android/build.gradle` forcing every Kotlin compile task, in every subproject, to the same target.
66
+
67
+ | Option | Type | Default |
68
+ | ----------- | -------- | ------- |
69
+ | `jvmTarget` | `string` | `"17"` |
70
+
62
71
  ## Testing your own setup
63
72
 
64
- The transforms behind the plugins are exported as pure functions from `@forthtilliath/expo-config-plugins/transforms` (`applyReleaseSigning`, `applyAndroidAbis`, `applyShortCxxPath`).
73
+ The transforms behind the plugins are exported as pure functions from `@forthtilliath/expo-config-plugins/transforms` (`applyReleaseSigning`, `applyAndroidAbis`, `applyShortCxxPath`, `applyKotlinJvmTarget`).
65
74
 
66
75
  ## Scripts
67
76
 
@@ -38,6 +38,20 @@ export declare function applyAndroidAbis(properties: GradlePropertiesItem[], abi
38
38
  * @throws When the `namespace` line to anchor on isn't found.
39
39
  */
40
40
  export declare function applyShortCxxPath(contents: string, stagingDir: string): string;
41
+ /**
42
+ * Appends to the root `android/build.gradle` a block forcing every Kotlin
43
+ * compile task, in every subproject, to target `jvmTarget` — the Java code's
44
+ * target: a native module compiling its Kotlin for another one (e.g.
45
+ * expo-dynamic-app-icon) fails the build with "Inconsistent JVM-target
46
+ * compatibility". Already-patched contents are returned as is.
47
+ *
48
+ * @throws When `jvmTarget` isn't a JVM version such as `17` or `1.8`.
49
+ */
50
+ export declare function applyKotlinJvmTarget(contents: string, jvmTarget?: string): string;
51
+ export interface KotlinJvmTargetOptions {
52
+ /** JVM version Kotlin compiles for, e.g. `"21"`. @defaultValue `"17"` */
53
+ jvmTarget?: string;
54
+ }
41
55
  export interface ReleaseSigningOptions {
42
56
  /**
43
57
  * Prefix of the Gradle properties holding the upload key, e.g. `MYAPP` for
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,CAmBR;AAED,qFAAqF;AACrF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtB,4CAA4C;AAC5C,eAAO,MAAM,QAAQ,EAAE,SAAS,MAAM,EAAiC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,oBAAoB,EAAE,EAClC,IAAI,GAAE,SAAS,MAAM,EAAa,GACjC,oBAAoB,EAAE,CAcxB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAA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B;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -6,6 +6,7 @@ exports.ARM_ABIS = void 0;
6
6
  exports.applyReleaseSigning = applyReleaseSigning;
7
7
  exports.applyAndroidAbis = applyAndroidAbis;
8
8
  exports.applyShortCxxPath = applyShortCxxPath;
9
+ exports.applyKotlinJvmTarget = applyKotlinJvmTarget;
9
10
  /** The `signingConfig signingConfigs.debug` of the `release` build type (not the `debug` one's). */
10
11
  const RELEASE_USES_DEBUG_KEY = /(buildTypes\s*\{[\s\S]*?release\s*\{[^}]*?)signingConfig signingConfigs\.debug/;
11
12
  function releaseSigningConfig(prefix) {
@@ -87,3 +88,31 @@ function applyShortCxxPath(contents, stagingDir) {
87
88
 
88
89
  namespace`);
89
90
  }
91
+ const KOTLIN_JVM_TARGET_MARKER = "withKotlinJvmTarget";
92
+ /**
93
+ * Appends to the root `android/build.gradle` a block forcing every Kotlin
94
+ * compile task, in every subproject, to target `jvmTarget` — the Java code's
95
+ * target: a native module compiling its Kotlin for another one (e.g.
96
+ * expo-dynamic-app-icon) fails the build with "Inconsistent JVM-target
97
+ * compatibility". Already-patched contents are returned as is.
98
+ *
99
+ * @throws When `jvmTarget` isn't a JVM version such as `17` or `1.8`.
100
+ */
101
+ function applyKotlinJvmTarget(contents, jvmTarget = "17") {
102
+ if (!/^(1\.8|\d{1,2})$/.test(jvmTarget)) {
103
+ throw new Error(`withKotlinJvmTarget: invalid jvmTarget option "${jvmTarget}" (e.g. 17)`);
104
+ }
105
+ if (contents.includes(KOTLIN_JVM_TARGET_MARKER))
106
+ return contents;
107
+ return `${contents.trimEnd()}
108
+
109
+ // ${KOTLIN_JVM_TARGET_MARKER}: Kotlin targets the same JVM as Java (avoids "Inconsistent JVM-target compatibility").
110
+ subprojects {
111
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
112
+ compilerOptions {
113
+ jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_${jvmTarget.replace(".", "_")})
114
+ }
115
+ }
116
+ }
117
+ `;
118
+ }
@@ -0,0 +1,14 @@
1
+ import { type ConfigPlugin } from "expo/config-plugins";
2
+ import { type KotlinJvmTargetOptions } from "./transforms.js";
3
+ /**
4
+ * Makes every Kotlin compile task target the same JVM as the Java code (17
5
+ * by default): some native modules (e.g. expo-dynamic-app-icon) compile
6
+ * their Kotlin for another target, and the build fails with "Inconsistent
7
+ * JVM-target compatibility".
8
+ *
9
+ * `"@forthtilliath/expo-config-plugins/withKotlinJvmTarget"`, or
10
+ * `["@forthtilliath/expo-config-plugins/withKotlinJvmTarget", { "jvmTarget": "21" }]`
11
+ */
12
+ declare const withKotlinJvmTarget: ConfigPlugin<KotlinJvmTargetOptions | undefined>;
13
+ export = withKotlinJvmTarget;
14
+ //# sourceMappingURL=withKotlinJvmTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withKotlinJvmTarget.d.ts","sourceRoot":"","sources":["../src/withKotlinJvmTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA0B,MAAM,qBAAqB,CAAC;AAEhF,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;GAQG;AACH,QAAA,MAAM,mBAAmB,EAAE,YAAY,CAAC,sBAAsB,GAAG,SAAS,CAUtE,CAAC;AAEL,SAAS,mBAAmB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ const config_plugins_1 = require("expo/config-plugins");
3
+ const transforms_js_1 = require("./transforms.js");
4
+ /**
5
+ * Makes every Kotlin compile task target the same JVM as the Java code (17
6
+ * by default): some native modules (e.g. expo-dynamic-app-icon) compile
7
+ * their Kotlin for another target, and the build fails with "Inconsistent
8
+ * JVM-target compatibility".
9
+ *
10
+ * `"@forthtilliath/expo-config-plugins/withKotlinJvmTarget"`, or
11
+ * `["@forthtilliath/expo-config-plugins/withKotlinJvmTarget", { "jvmTarget": "21" }]`
12
+ */
13
+ const withKotlinJvmTarget = (config, options) => (0, config_plugins_1.withProjectBuildGradle)(config, (mod) => {
14
+ mod.modResults.contents = (0, transforms_js_1.applyKotlinJvmTarget)(mod.modResults.contents, options?.jvmTarget);
15
+ return mod;
16
+ });
17
+ module.exports = withKotlinJvmTarget;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@forthtilliath/expo-config-plugins",
3
- "version": "0.1.0",
4
- "description": "Expo config plugins for sideloaded Android apps: release signing with your own key, ARM-only native code, short CMake paths on Windows.",
3
+ "version": "0.2.0",
4
+ "description": "Expo config plugins for sideloaded Android apps: release signing with your own key, ARM-only native code, short CMake paths on Windows, one JVM target for Kotlin.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -20,6 +20,7 @@
20
20
  "./withReleaseSigning": "./dist/withReleaseSigning.js",
21
21
  "./withAndroidAbis": "./dist/withAndroidAbis.js",
22
22
  "./withShortCxxPath": "./dist/withShortCxxPath.js",
23
+ "./withKotlinJvmTarget": "./dist/withKotlinJvmTarget.js",
23
24
  "./transforms": "./dist/transforms.js",
24
25
  "./package.json": "./package.json"
25
26
  },
@@ -28,12 +29,12 @@
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/node": "^26.2.0",
31
- "@vitest/coverage-v8": "5.0.2",
32
+ "@vitest/coverage-v8": "5.0.5",
32
33
  "eslint": "10.7.0",
33
34
  "expo": "~57.0.9",
34
35
  "typescript": "^5.9.3",
35
- "vitest": "^5.0.2",
36
- "@forthtilliath/eslint-config": "0.9.0",
36
+ "vitest": "^5.0.5",
37
+ "@forthtilliath/eslint-config": "0.10.0",
37
38
  "@forthtilliath/typescript-config": "0.1.1"
38
39
  },
39
40
  "scripts": {