mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[flutter_tool] fix deletion of gradle wrapper artifacts in cache (#78911)
This commit is contained in:
parent
64d9650e51
commit
975fb0f06c
@ -1293,11 +1293,13 @@ class GradleWrapper extends CachedArtifact {
|
||||
OperatingSystemUtils operatingSystemUtils,
|
||||
) async {
|
||||
final Uri archiveUri = _toStorageUri(version);
|
||||
await artifactUpdater.downloadZippedTarball('Downloading Gradle Wrapper...', archiveUri, location);
|
||||
await artifactUpdater.downloadZippedTarball('Downloading Gradle Wrapper...', archiveUri, location);
|
||||
// Delete property file, allowing templates to provide it.
|
||||
fileSystem.file(fileSystem.path.join(location.path, 'gradle', 'wrapper', 'gradle-wrapper.properties')).deleteSync();
|
||||
// Remove NOTICE file. Should not be part of the template.
|
||||
fileSystem.file(fileSystem.path.join(location.path, 'NOTICE')).deleteSync();
|
||||
final File propertiesFile = fileSystem.file(fileSystem.path.join(location.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'));
|
||||
final File noticeFile = fileSystem.file(fileSystem.path.join(location.path, 'NOTICE'));
|
||||
ErrorHandlingFileSystem.deleteIfExists(propertiesFile);
|
||||
ErrorHandlingFileSystem.deleteIfExists(noticeFile);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -136,6 +136,28 @@ void main() {
|
||||
expect(gradleWrapper.isUpToDateInner(fileSystem), false);
|
||||
});
|
||||
|
||||
testWithoutContext('Gradle wrapper will delete .properties/NOTICES if they exist', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Cache cache = Cache.test(fileSystem: fileSystem, processManager: FakeProcessManager.any());
|
||||
final OperatingSystemUtils operatingSystemUtils = OperatingSystemUtils(
|
||||
processManager: FakeProcessManager.any(),
|
||||
platform: FakePlatform(),
|
||||
logger: BufferLogger.test(),
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
final GradleWrapper gradleWrapper = GradleWrapper(cache);
|
||||
final Directory directory = cache.getCacheDir(fileSystem.path.join('artifacts', 'gradle_wrapper'));
|
||||
final File propertiesFile = fileSystem.file(fileSystem.path.join(directory.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'))
|
||||
..createSync(recursive: true);
|
||||
final File noticeFile = fileSystem.file(fileSystem.path.join(directory.path, 'NOTICE'))
|
||||
..createSync(recursive: true);
|
||||
|
||||
await gradleWrapper.updateInner(FakeArtifactUpdater(), fileSystem, operatingSystemUtils);
|
||||
|
||||
expect(propertiesFile, isNot(exists));
|
||||
expect(noticeFile, isNot(exists));
|
||||
});
|
||||
|
||||
testWithoutContext('Gradle wrapper should be up to date, only if all cached artifact are available', () {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Cache cache = Cache.test(fileSystem: fileSystem, processManager: FakeProcessManager.any());
|
||||
@ -941,3 +963,10 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
|
||||
reinitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
class FakeArtifactUpdater extends Fake implements ArtifactUpdater {
|
||||
@override
|
||||
Future<void> downloadZippedTarball(String message, Uri url, Directory location) async {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user