22// code is governed by a BSD-style license that can be found in the LICENSE file.
33
44import 'dart:async' ;
5- import 'dart:convert' ;
65import 'dart:io' ;
76
87import 'package:args/args.dart' ;
@@ -11,7 +10,6 @@ import 'package:git/git.dart';
1110import 'package:path/path.dart' as p;
1211
1312import 'build_spec.dart' ;
14- import 'edit.dart' ;
1513import 'globals.dart' ;
1614import 'lint.dart' ;
1715import 'runner.dart' ;
@@ -21,7 +19,6 @@ Future<int> main(List<String> args) async {
2119 var runner = BuildCommandRunner ();
2220
2321 runner.addCommand (LintCommand (runner));
24- runner.addCommand (TestCommand (runner));
2522 runner.addCommand (DeployCommand (runner));
2623 runner.addCommand (GenerateCommand (runner));
2724
@@ -47,15 +44,6 @@ void copyResources({required String from, required String to}) {
4744 _copyResources (Directory (from), Directory (to));
4845}
4946
50- List <BuildSpec > createBuildSpecs (ProductCommand command) {
51- var specs = < BuildSpec > [];
52- var input = readProductMatrix ();
53- for (var json in input) {
54- specs.add (BuildSpec .fromJson (json, command.release));
55- }
56- return specs;
57- }
58-
5947List <File > findJars (String path) {
6048 final dir = Directory (path);
6149 return dir
@@ -74,18 +62,10 @@ List<String> findJavaFiles(String path) {
7462 .toList ();
7563}
7664
77- bool isTravisFileValid () {
78- var travisPath = p.join (rootPath, '.github/workflows/presubmit.yaml' );
79- var travisFile = File (travisPath);
80- if (! travisFile.existsSync ()) {
81- return false ;
82- }
83- var matrixPath = p.join (rootPath, 'product-matrix.json' );
84- var matrixFile = File (matrixPath);
85- if (! matrixFile.existsSync ()) {
86- throw 'product-matrix.json is missing' ;
87- }
88- return isNewer (travisFile, matrixFile);
65+ bool isPresubmitFileValid () {
66+ var presubmitPath = p.join (rootPath, '.github/workflows/presubmit.yaml' );
67+ var presubmitFile = File (presubmitPath);
68+ return presubmitFile.existsSync ();
8969}
9070
9171Future <int > jar (String directory, String outFile) async {
@@ -130,7 +110,7 @@ Future<bool> performReleaseChecks(ProductCommand cmd) async {
130110 name.lastIndexOf (RegExp (r"\.[0-9]" )) == name.length - 2 ;
131111 }
132112 if (result) {
133- if (isTravisFileValid ()) {
113+ if (isPresubmitFileValid ()) {
134114 return result;
135115 } else {
136116 log ('the presubmit.yaml file needs updating: plugin generate' );
@@ -162,13 +142,6 @@ Future<bool> performReleaseChecks(ProductCommand cmd) async {
162142 return false ;
163143}
164144
165- List <Map <String , Object ?>> readProductMatrix () {
166- var contents =
167- File (p.join (rootPath, 'product-matrix.json' )).readAsStringSync ();
168- var map = json.decode (contents);
169- return (map['list' ] as List <Object ?>).cast <Map <String , Object ?>>();
170- }
171-
172145void _copyFile (File file, Directory to, {String filename = '' }) {
173146 if (! file.existsSync ()) {
174147 throw "${file .path } does not exist" ;
@@ -278,12 +251,7 @@ https://plugins.jetbrains.com/plugin/uploadPlugin
278251 }
279252}
280253
281- /// Generate the plugin.xml from the plugin.xml.template file. If the --release
282- /// argument is given, create a git branch and commit the new file to it,
283- /// assuming the release checks pass.
284- ///
285- /// Note: The product-matrix.json file includes a build spec for the EAP version
286- /// at the end. When the EAP version is released that needs to be updated.
254+ /// This is only used to generate live templates for the Flutter plugin.
287255class GenerateCommand extends ProductCommand {
288256 @override
289257 final BuildCommandRunner runner;
@@ -353,7 +321,6 @@ class GenerateCommand extends ProductCommand {
353321abstract class ProductCommand extends Command <int > {
354322 @override
355323 final String name;
356- late List <BuildSpec > specs;
357324
358325 ProductCommand (this .name) {
359326 addProductFlags (argParser, name[0 ].toUpperCase () + name.substring (1 ));
@@ -448,7 +415,6 @@ abstract class ProductCommand extends Command<int> {
448415 @override
449416 Future <int > run () async {
450417 await _initGlobals ();
451- await _initSpecs ();
452418 try {
453419 return await doit ();
454420 } catch (ex, stack) {
@@ -471,17 +437,6 @@ abstract class ProductCommand extends Command<int> {
471437 lastReleaseDate = await dateOfLastRelease ();
472438 }
473439 }
474-
475- Future <int > _initSpecs () async {
476- specs = createBuildSpecs (this );
477- for (var i = 0 ; i < specs.length; i++ ) {
478- if (isDevChannel) {
479- specs[i].buildForDev ();
480- }
481- await specs[i].initChangeLog ();
482- }
483- return specs.length;
484- }
485440}
486441
487442/// A crude rename utility. The IntelliJ feature does not work on the case
@@ -597,66 +552,3 @@ class RenamePackageCommand extends ProductCommand {
597552 }
598553 }
599554}
600-
601- /// Build the tests if necessary then run them and return any failure code.
602- class TestCommand extends ProductCommand {
603- @override
604- final BuildCommandRunner runner;
605-
606- TestCommand (this .runner) : super ('test' ) {
607- argParser.addFlag (
608- 'skip' ,
609- negatable: false ,
610- help: 'Do not run tests, just unpack artifaccts' ,
611- abbr: 's' ,
612- );
613- argParser.addFlag ('setup' , abbr: 'p' , defaultsTo: true );
614- }
615-
616- @override
617- String get description => 'Run the tests for the Flutter plugin.' ;
618-
619- @override
620- Future <int > doit () async {
621- final javaHome = Platform .environment['JAVA_HOME' ];
622- if (javaHome == null ) {
623- log ('ERROR: JAVA_HOME environment variable not set - this is needed by gradle.' );
624- return 1 ;
625- }
626-
627- log ('JAVA_HOME=$javaHome ' );
628-
629- // Case 1: Handle skipping tests
630- if (argResults != null && argResults! .flag ('skip' )) {
631- log ('Skipping unit tests as requested.' );
632- return 0 ;
633- }
634-
635- // Filter for all unit test targets
636- final unitTestTargets = specs.where ((s) => s.isUnitTestTarget).toList ();
637-
638- // Case 2: Zero unit test targets
639- if (unitTestTargets.isEmpty) {
640- log ('ERROR: No unit test target found in the specifications. Cannot run tests.' );
641- return 1 ;
642- }
643-
644- // Case 3: More than one unit test target
645- if (unitTestTargets.length > 1 ) {
646- final targetNames = unitTestTargets.map ((s) => s.name).join (', ' );
647- log ('ERROR: More than one unit test target found: $targetNames . Please specify which one to run, or ensure only one exists.' );
648- return 1 ;
649- }
650-
651- // Happy Case: Exactly one unit test target
652- final spec = unitTestTargets.first;
653- return await _runUnitTests (spec);
654- }
655-
656- Future <int > _runUnitTests (BuildSpec spec) async {
657- // run './gradlew test'
658- return await applyEdits (spec, () async {
659- return await runner.runGradleCommand (['test' ], spec, '1' , 'true' );
660- });
661- }
662- }
0 commit comments