|
1 | 1 | const assert = require('assert');
|
2 |
| -const { withProjectBuildGradle } = require('expo/config-plugins'); |
| 2 | +const { withAppBuildGradle } = require('expo/config-plugins'); |
3 | 3 |
|
4 |
| -const withJscAndroidProjectBuildGradle = (config) => { |
5 |
| - return withProjectBuildGradle(config, (config) => { |
| 4 | +const withJscAndroidAppBuildGradle = (config) => { |
| 5 | + return withAppBuildGradle(config, (config) => { |
6 | 6 | assert(config.modResults.language === 'groovy');
|
7 |
| - if (!config.modResults.contents.match(/\/\/ Local dist maven repo/)) { |
8 |
| - const mavenRepo = ` |
9 |
| - maven { |
10 |
| - // Local dist maven repo |
11 |
| - url('../../dist') |
12 |
| - }`; |
13 |
| - config.modResults.contents = config.modResults.contents.replace( |
14 |
| - /^(allprojects \{[\s\S]+?repositories \{)/gm, |
15 |
| - `$1${mavenRepo}` |
16 |
| - ); |
17 |
| - } |
18 |
| - |
19 | 7 | if (
|
20 | 8 | !config.modResults.contents.match(
|
21 |
| - /io\.github\.react-native-community:jsc-android:/ |
| 9 | + /@generated withJscAndroidAppBuildGradle/ |
22 | 10 | )
|
23 | 11 | ) {
|
24 |
| - config.modResults.contents += ` |
25 |
| -allprojects { |
| 12 | + const code = ` |
| 13 | +// [begin] @generated withJscAndroidAppBuildGradle |
| 14 | +afterEvaluate { |
| 15 | + project.rootProject.allprojects { |
| 16 | + // Remove original mavenCentral |
| 17 | + repositories.removeIf { repo -> |
| 18 | + repo instanceof MavenArtifactRepository && repo.url.toString().contains('https://repo.maven.apache.org/maven2') |
| 19 | + } |
| 20 | +
|
| 21 | + repositories { |
| 22 | + maven { |
| 23 | + // Local dist maven repo |
| 24 | + url("\${rootDir}/../../dist") |
| 25 | + } |
| 26 | +
|
| 27 | + mavenCentral { |
| 28 | + content { |
| 29 | + excludeGroup('org.webkit') |
| 30 | + excludeGroup('io.github.react-native-community') |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | +
|
26 | 36 | configurations.all {
|
27 | 37 | resolutionStrategy.dependencySubstitution {
|
28 | 38 | substitute(module('org.webkit:android-jsc'))
|
29 | 39 | .using(module('io.github.react-native-community:jsc-android:+'))
|
30 | 40 | }
|
31 | 41 | }
|
32 | 42 | }
|
| 43 | +// [end] @generated withJscAndroidAppBuildGradle |
33 | 44 | `;
|
| 45 | + config.modResults.contents += code; |
34 | 46 | }
|
35 |
| - |
36 | 47 | return config;
|
37 | 48 | });
|
38 | 49 | };
|
39 | 50 |
|
40 | 51 | const withJscAndroid = (config) => {
|
41 |
| - config = withJscAndroidProjectBuildGradle(config); |
| 52 | + config = withJscAndroidAppBuildGradle(config); |
42 | 53 | return config;
|
43 | 54 | };
|
44 | 55 |
|
|
0 commit comments