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: https://github.com/facebook/react-native/pull/20853

Differential Revision: D9733888

Pulled By: hramos

fbshipit-source-id: 22853480d7ba7be65e3387effda2fd6c72b6906a
This commit is contained in:
Matei Radu 2018-09-08 04:20:45 -07:00 committed by Facebook Github Bot
parent db9b468dd1
commit 4dfdec9b28
4 changed files with 16 additions and 14 deletions

View File

@ -1,5 +1,5 @@
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:27.1.1"
compile "com.facebook.react:react-native:+"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.facebook.react:react-native:+"
}

View File

@ -1,9 +1,9 @@
dependencies {
compile project(':test')
compile(project(':test2')) {
implementation project(':test')
implementation(project(':test2')) {
exclude(group: 'org.unwanted', module: 'test10')
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:27.1.1"
compile "com.facebook.react:react-native:+"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.facebook.react:react-native:+"
}

View File

@ -26,12 +26,12 @@ describe('makeBuildPatch', () => {
it('should make a correct patch', () => {
const {patch} = makeBuildPatch(name);
expect(patch).toBe(` compile project(':${name}')\n`);
expect(patch).toBe(` implementation project(':${name}')\n`);
});
it('should make a correct install check pattern', () => {
const {installPattern} = makeBuildPatch(name);
const match = `/\\s{4}(compile)(\\(|\\s)(project)\\(\\':${name}\\'\\)(\\)|\\s)/`;
const match = `/\\s{4}(implementation)(\\(|\\s)(project)\\(\\':${name}\\'\\)(\\)|\\s)/`;
expect(installPattern.toString()).toBe(match);
});
});
@ -39,12 +39,14 @@ describe('makeBuildPatch', () => {
describe('makeBuildPatchWithScopedPackage', () => {
it('should make a correct patch', () => {
const {patch} = makeBuildPatch(scopedName);
expect(patch).toBe(` compile project(':${normalizedScopedName}')\n`);
expect(patch).toBe(
` implementation project(':${normalizedScopedName}')\n`,
);
});
it('should make a correct install check pattern', () => {
const {installPattern} = makeBuildPatch(scopedName);
const match = `/\\s{4}(compile)(\\(|\\s)(project)\\(\\':${normalizedScopedName}\\'\\)(\\)|\\s)/`;
const match = `/\\s{4}(implementation)(\\(|\\s)(project)\\(\\':${normalizedScopedName}\\'\\)(\\)|\\s)/`;
expect(installPattern.toString()).toBe(match);
});
});

View File

@ -12,12 +12,12 @@ const normalizeProjectName = require('./normalizeProjectName');
module.exports = function makeBuildPatch(name) {
const normalizedProjectName = normalizeProjectName(name);
const installPattern = new RegExp(
`\\s{4}(compile)(\\(|\\s)(project)\\(\\\':${normalizedProjectName}\\\'\\)(\\)|\\s)`,
`\\s{4}(implementation)(\\(|\\s)(project)\\(\\\':${normalizedProjectName}\\\'\\)(\\)|\\s)`,
);
return {
installPattern,
pattern: /[^ \t]dependencies {(\r\n|\n)/,
patch: ` compile project(':${normalizedProjectName}')\n`,
patch: ` implementation project(':${normalizedProjectName}')\n`,
};
};