Skip to content

Commit 4dfdec9

Browse files
matei-radufacebook-github-bot
authored andcommitted
Update link command for Android project (#20853)
Summary: Motivation: -------------- PR #20767 bumped the version of the Android Gradle Plugin to v3 which uses the newer Gradle dependency configurations `implementation` and `api` which make `compile` obsolete. While the PR updated the template Gradle configuration, it did not cover the `link` command which will still link native modules using `compile` resulting in a warning message beeing displayed during an app build. Since `compile` will be eventually removed by Gradle, this commit updates the `link` command to attach native modules using `implementation`. Pull Request resolved: #20853 Differential Revision: D9733888 Pulled By: hramos fbshipit-source-id: 22853480d7ba7be65e3387effda2fd6c72b6906a
1 parent db9b468 commit 4dfdec9

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies {
2-
compile fileTree(dir: "libs", include: ["*.jar"])
3-
compile "com.android.support:appcompat-v7:27.1.1"
4-
compile "com.facebook.react:react-native:+"
2+
implementation fileTree(dir: "libs", include: ["*.jar"])
3+
implementation "com.android.support:appcompat-v7:27.1.1"
4+
implementation "com.facebook.react:react-native:+"
55
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
dependencies {
2-
compile project(':test')
3-
compile(project(':test2')) {
2+
implementation project(':test')
3+
implementation(project(':test2')) {
44
exclude(group: 'org.unwanted', module: 'test10')
55
}
6-
compile fileTree(dir: "libs", include: ["*.jar"])
7-
compile "com.android.support:appcompat-v7:27.1.1"
8-
compile "com.facebook.react:react-native:+"
6+
implementation fileTree(dir: "libs", include: ["*.jar"])
7+
implementation "com.android.support:appcompat-v7:27.1.1"
8+
implementation "com.facebook.react:react-native:+"
99
}

local-cli/link/__tests__/android/makeBuildPatch.spec.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,27 @@ describe('makeBuildPatch', () => {
2626

2727
it('should make a correct patch', () => {
2828
const {patch} = makeBuildPatch(name);
29-
expect(patch).toBe(` compile project(':${name}')\n`);
29+
expect(patch).toBe(` implementation project(':${name}')\n`);
3030
});
3131

3232
it('should make a correct install check pattern', () => {
3333
const {installPattern} = makeBuildPatch(name);
34-
const match = `/\\s{4}(compile)(\\(|\\s)(project)\\(\\':${name}\\'\\)(\\)|\\s)/`;
34+
const match = `/\\s{4}(implementation)(\\(|\\s)(project)\\(\\':${name}\\'\\)(\\)|\\s)/`;
3535
expect(installPattern.toString()).toBe(match);
3636
});
3737
});
3838

3939
describe('makeBuildPatchWithScopedPackage', () => {
4040
it('should make a correct patch', () => {
4141
const {patch} = makeBuildPatch(scopedName);
42-
expect(patch).toBe(` compile project(':${normalizedScopedName}')\n`);
42+
expect(patch).toBe(
43+
` implementation project(':${normalizedScopedName}')\n`,
44+
);
4345
});
4446

4547
it('should make a correct install check pattern', () => {
4648
const {installPattern} = makeBuildPatch(scopedName);
47-
const match = `/\\s{4}(compile)(\\(|\\s)(project)\\(\\':${normalizedScopedName}\\'\\)(\\)|\\s)/`;
49+
const match = `/\\s{4}(implementation)(\\(|\\s)(project)\\(\\':${normalizedScopedName}\\'\\)(\\)|\\s)/`;
4850
expect(installPattern.toString()).toBe(match);
4951
});
5052
});

local-cli/link/android/patches/makeBuildPatch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const normalizeProjectName = require('./normalizeProjectName');
1212
module.exports = function makeBuildPatch(name) {
1313
const normalizedProjectName = normalizeProjectName(name);
1414
const installPattern = new RegExp(
15-
`\\s{4}(compile)(\\(|\\s)(project)\\(\\\':${normalizedProjectName}\\\'\\)(\\)|\\s)`,
15+
`\\s{4}(implementation)(\\(|\\s)(project)\\(\\\':${normalizedProjectName}\\\'\\)(\\)|\\s)`,
1616
);
1717

1818
return {
1919
installPattern,
2020
pattern: /[^ \t]dependencies {(\r\n|\n)/,
21-
patch: ` compile project(':${normalizedProjectName}')\n`,
21+
patch: ` implementation project(':${normalizedProjectName}')\n`,
2222
};
2323
};

0 commit comments

Comments
 (0)