这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions packages/flutter_tools/lib/src/android/gradle_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,7 @@ final outdatedGradleHandler = GradleHandledError(
test: _outdatedGradlePattern.hasMatch,
handler: ({required String line, required FlutterProject project, required bool usesAndroidX}) async {
final File gradleFile = project.android.hostAppGradleFile;
final File gradlePropertiesFile = project.directory
.childDirectory('android')
.childDirectory(utils.gradleDirectoryName)
.childDirectory(utils.gradleWrapperDirectoryName)
.childFile(utils.gradleWrapperPropertiesFilename);
final File gradlePropertiesFile = project.android.gradleWrapperPropertiesFile;
globals.printBox(
'${globals.logger.terminal.warningMark} Your project needs to upgrade Gradle and the Android Gradle plugin.\n\n'
'To fix this issue, replace the following content:\n'
Expand Down Expand Up @@ -507,11 +503,7 @@ final incompatibleJavaAndGradleVersionsHandler = GradleHandledError(
},
handler:
({required String line, required FlutterProject project, required bool usesAndroidX}) async {
final File gradlePropertiesFile = project.directory
.childDirectory('android')
.childDirectory(utils.gradleDirectoryName)
.childDirectory(utils.gradleWrapperDirectoryName)
.childFile(utils.gradleWrapperPropertiesFilename);
final File gradlePropertiesFile = project.android.gradleWrapperPropertiesFile;
// TODO(reidbaker): Replace URL with constant defined in
// https://github.com/flutter/flutter/pull/123916.
globals.printBox(
Expand Down
12 changes: 12 additions & 0 deletions packages/flutter_tools/lib/src/project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,18 @@ class AndroidProject extends FlutterProjectPlatform {
return hostAppGradleRoot.childFile('AndroidManifest.xml');
}

/// Gets the Gradle wrapper properties file.
///
/// This file is located under `gradle/wrapper/gradle-wrapper.properties`
/// in the host app's Gradle root directory. It defines the distribution
/// settings for the Gradle wrapper.
File get gradleWrapperPropertiesFile {
return hostAppGradleRoot
.childDirectory('gradle')
.childDirectory('wrapper')
.childFile('gradle-wrapper.properties');
}

File get generatedPluginRegistrantFile {
return hostAppGradleRoot
.childDirectory('app')
Expand Down
25 changes: 25 additions & 0 deletions packages/flutter_tools/test/general.shard/project_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,31 @@ plugins {
});
});

group('Android project file getters', () {
_testInMemory(
'Project.android.gradleWrapperPropertiesFile resolves to gradle/wrapper/gradle-wrapper.properties',
() async {
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync(
'flutter_project_test.',
);
final Directory androidDir = tempDir.childDirectory('android')
..createSync(recursive: true);

// Create gradle/wrapper/gradle-wrapper.properties inside the fake android dir
final File expected =
androidDir
.childDirectory('gradle')
.childDirectory('wrapper')
.childFile('gradle-wrapper.properties')
..createSync(recursive: true);

final FlutterProject project = FlutterProject.fromDirectory(tempDir);

expect(project.android.gradleWrapperPropertiesFile.path, expected.path);
},
);
});

group('workspaces', () {
_testInMemory('fails on invalid pubspec.yaml', () async {
final Directory directory = globals.fs.directory('myproject');
Expand Down