Ensure android.enableR8 is appended to a new line (#43187)
This commit is contained in:
@@ -387,8 +387,14 @@ void migrateToR8(Directory directory) {
|
||||
}
|
||||
printTrace('set `android.enableR8=true` in gradle.properties');
|
||||
try {
|
||||
gradleProperties
|
||||
.writeAsStringSync('android.enableR8=true\n', mode: FileMode.append);
|
||||
// Add `android.enableR8=true` to the next line in gradle.properties.
|
||||
if (propertiesContent.isNotEmpty && !propertiesContent.endsWith('\n')) {
|
||||
gradleProperties
|
||||
.writeAsStringSync('\nandroid.enableR8=true\n', mode: FileMode.append);
|
||||
} else {
|
||||
gradleProperties
|
||||
.writeAsStringSync('android.enableR8=true\n', mode: FileMode.append);
|
||||
}
|
||||
} on FileSystemException {
|
||||
throwToolExit(
|
||||
'The tool failed to add `android.enableR8=true` to ${gradleProperties.path}. '
|
||||
|
||||
@@ -1410,6 +1410,27 @@ Exception in thread "main" java.lang.NullPointerException
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => FakeProcessManager(<FakeCommand>[]),
|
||||
});
|
||||
|
||||
testUsingContext('appends android.enableR8=true to the new line', () {
|
||||
final Directory sampleAppAndroid = fs.directory('/sample-app/android');
|
||||
sampleAppAndroid.createSync(recursive: true);
|
||||
sampleAppAndroid.childFile('gradle.properties')
|
||||
.writeAsStringSync('org.gradle.jvmargs=-Xmx1536M');
|
||||
|
||||
migrateToR8(sampleAppAndroid);
|
||||
|
||||
expect(testLogger.traceText, contains('set `android.enableR8=true` in gradle.properties'));
|
||||
expect(
|
||||
sampleAppAndroid.childFile('gradle.properties').readAsStringSync(),
|
||||
equals(
|
||||
'org.gradle.jvmargs=-Xmx1536M\n'
|
||||
'android.enableR8=true\n'
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => FakeProcessManager(<FakeCommand>[]),
|
||||
});
|
||||
});
|
||||
|
||||
group('isAppUsingAndroidX', () {
|
||||
|
||||
Reference in New Issue
Block a user