Do not use project in do last (#139325)
- Use copy task that branches for 8.3 and above to avoid using project.exec in a dolast block. part 1/n for flutter/flutter/issues/138523 This PR does not test the 8.3 branch but instead builds the ability to write a branching gradle test. After fixing this project.exec action there I discovered a second that needs to be removed or migrated in order for the build to work. Related reading https://docs.gradle.org/8.0/userguide/configuration_cache.html#config_cache:requirements https://docs.gradle.org/current/javadoc/org/gradle/process/ExecOperations.html (not used but considered) https://docs.gradle.org/8.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:fileMode
This commit is contained in:
@@ -14,15 +14,37 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
final String gradlew = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
final String gradlewExecutable = Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
final String gradlewExecutable =
|
||||
Platform.isWindows ? '.\\$gradlew' : './$gradlew';
|
||||
final String fileReadWriteMode = Platform.isWindows ? 'rw-rw-rw-' : 'rw-r--r--';
|
||||
final String platformLineSep = Platform.isWindows ? '\r\n': '\n';
|
||||
final String platformLineSep = Platform.isWindows ? '\r\n' : '\n';
|
||||
|
||||
/// Combines several TaskFunctions with trivial success value into one.
|
||||
TaskFunction combine(List<TaskFunction> tasks) {
|
||||
return () async {
|
||||
for (final TaskFunction task in tasks) {
|
||||
final TaskResult result = await task();
|
||||
if (result.failed) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return TaskResult.success(null);
|
||||
};
|
||||
}
|
||||
|
||||
/// Tests that the Flutter module project template works and supports
|
||||
/// adding Flutter to an existing Android app.
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
class ModuleTest {
|
||||
ModuleTest(
|
||||
this.buildTarget, {
|
||||
this.gradleVersion = '7.6.3',
|
||||
});
|
||||
|
||||
final String buildTarget;
|
||||
final String gradleVersion;
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
section('Running: $buildTarget');
|
||||
section('Find Java');
|
||||
|
||||
final String? javaHome = await findJavaHome();
|
||||
@@ -253,11 +275,25 @@ exitCode: $exitCode
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper',
|
||||
'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
);
|
||||
|
||||
final File analyticsOutputFile = File(path.join(tempDir.path, 'analytics.log'));
|
||||
// Modify gradle version to passed in version.
|
||||
// This is somehow the wrong file.
|
||||
final File gradleWrapperProperties = File(path.join(
|
||||
hostApp.path, 'gradle', 'wrapper', 'gradle-wrapper.properties'));
|
||||
String propertyContent = await gradleWrapperProperties.readAsString();
|
||||
propertyContent = propertyContent.replaceFirst(
|
||||
'REPLACEME',
|
||||
gradleVersion,
|
||||
);
|
||||
section(propertyContent);
|
||||
await gradleWrapperProperties.writeAsString(propertyContent, flush: true);
|
||||
|
||||
final File analyticsOutputFile =
|
||||
File(path.join(tempDir.path, 'analytics.log'));
|
||||
|
||||
section('Build debug host APK');
|
||||
|
||||
@@ -442,5 +478,12 @@ exitCode: $exitCode
|
||||
} finally {
|
||||
rmTree(tempDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
// ignore: avoid_redundant_argument_values
|
||||
ModuleTest('module-gradle-7.6', gradleVersion: '7.6.3').call,
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-REPLACEME-all.zip
|
||||
|
||||
Reference in New Issue
Block a user