Skip to content

Commit 5d50636

Browse files
authored
Remove product-matrix.json and related code (#8726)
This deletes the `product-matrix.json` file and places that use it. I checked that `bin/plugin generate` still works (though we probably don't need this either) to make sure the plugin tool still compiles. Related to #8723
1 parent 6f73f07 commit 5d50636

4 files changed

Lines changed: 7 additions & 253 deletions

File tree

product-matrix.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

tool/plugin/lib/build_spec.dart

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -132,35 +132,3 @@ class BuildSpec {
132132
}
133133
}
134134

135-
/// This represents a BuildSpec that is used to generate the plugin.xml
136-
/// that is used during development. It needs to span all possible versions.
137-
/// The product-matrix.json file lists the versions in increasing build order.
138-
/// The first one is the earliest version used during development and the
139-
/// last one is the latest used during development. This BuildSpec combines
140-
/// those two.
141-
class SyntheticBuildSpec extends BuildSpec {
142-
late final BuildSpec alternate;
143-
144-
SyntheticBuildSpec.fromJson(
145-
super.json,
146-
super.releaseNum,
147-
List<BuildSpec> specs,
148-
) : super.fromJson() {
149-
try {
150-
// 'isUnitTestTarget' should always be in the spec for the latest IntelliJ (not AS).
151-
alternate = specs.firstWhere((s) => s.isUnitTestTarget);
152-
} on StateError catch (_) {
153-
log('No build spec defines "isUnitTestTarget"');
154-
exit(1);
155-
}
156-
}
157-
158-
@override
159-
String get sinceBuild => alternate.sinceBuild;
160-
161-
@override
162-
String get untilBuild => alternate.untilBuild;
163-
164-
@override
165-
bool get isSynthetic => true;
166-
}

tool/plugin/lib/plugin.dart

Lines changed: 6 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// code is governed by a BSD-style license that can be found in the LICENSE file.
33

44
import 'dart:async';
5-
import 'dart:convert';
65
import 'dart:io';
76

87
import 'package:args/args.dart';
@@ -11,7 +10,6 @@ import 'package:git/git.dart';
1110
import 'package:path/path.dart' as p;
1211

1312
import 'build_spec.dart';
14-
import 'edit.dart';
1513
import 'globals.dart';
1614
import 'lint.dart';
1715
import '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-
5947
List<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

9171
Future<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-
172145
void _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.
287255
class GenerateCommand extends ProductCommand {
288256
@override
289257
final BuildCommandRunner runner;
@@ -353,7 +321,6 @@ class GenerateCommand extends ProductCommand {
353321
abstract 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-
}

tool/plugin/test/plugin_test.dart

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ import 'dart:io';
66

77
import 'package:plugin_tool/plugin.dart';
88
import 'package:plugin_tool/runner.dart';
9-
import 'package:string_validator/string_validator.dart' as validator;
109
import 'package:test/test.dart';
1110

1211
void main() {
1312
group("create", () {
14-
test('test', () {
15-
expect(TestCommand(BuildCommandRunner()).name, "test");
16-
});
17-
1813
test('deploy', () {
1914
expect(DeployCommand(BuildCommandRunner()).name, "deploy");
2015
});
@@ -24,60 +19,6 @@ void main() {
2419
});
2520
});
2621

27-
group("spec", () {
28-
/// This method has assertions which can be made for all commands in this
29-
/// test group.
30-
void buildSpecAssertions(BuildCommandRunner runner, String command) {
31-
var specs = (runner.commands[command] as ProductCommand).specs;
32-
expect(specs, isList);
33-
expect(specs, isNotEmpty);
34-
35-
// channel should be set to stable in the product-matrix.json
36-
for (String channel in specs.map((spec) => spec.channel).toList()) {
37-
expect(channel, anyOf('stable'));
38-
}
39-
40-
// name should be set to stable in the product-matrix.json
41-
for (String name in specs.map((spec) => spec.name).toList()) {
42-
expect(name, isNotEmpty);
43-
expect(name.length, 6);
44-
expect(name, validator.isFloat);
45-
}
46-
47-
// ideaProduct should be android-studio or IC
48-
for (String ideaProduct
49-
in specs.map((spec) => spec.ideaProduct).toList()) {
50-
expect(ideaProduct, anyOf('android-studio', 'IC'));
51-
}
52-
53-
// sinceBuild should be in the form of '243'
54-
for (String sinceBuild in specs.map((spec) => spec.sinceBuild).toList()) {
55-
expect(sinceBuild.length, 3);
56-
expect(sinceBuild, validator.isNumeric);
57-
}
58-
59-
// untilBuild should be in the form of '243.*'
60-
for (String untilBuild in specs.map((spec) => spec.untilBuild).toList()) {
61-
expect(untilBuild.length, 5);
62-
expect(untilBuild.substring(0, 2), validator.isNumeric);
63-
}
64-
}
65-
66-
test('test', () async {
67-
var runner = makeTestRunner();
68-
await runner.run(["-r=19", "-d../..", "test"]).whenComplete(() {
69-
buildSpecAssertions(runner, "test");
70-
});
71-
});
72-
73-
test('deploy', () async {
74-
var runner = makeTestRunner();
75-
await runner.run(["-r19", "-d../..", "deploy"]).whenComplete(() {
76-
buildSpecAssertions(runner, "deploy");
77-
});
78-
});
79-
});
80-
8122
group('release', () {
8223
test('simple', () async {
8324
var runner = makeTestRunner();
@@ -144,8 +85,7 @@ void main() {
14485

14586
BuildCommandRunner makeTestRunner() {
14687
var runner = BuildCommandRunner();
147-
runner.addCommand(TestTestCommand(runner));
148-
runner.addCommand(TestDeployCommand(runner));
88+
runner.addCommand(TestDeployCommand(runner));
14989
runner.addCommand(TestGenCommand(runner));
15090
return runner;
15191
}
@@ -188,13 +128,3 @@ class TestGenCommand extends GenerateCommand {
188128
@override
189129
Future<int> doit() async => Future(() => 0);
190130
}
191-
192-
class TestTestCommand extends TestCommand {
193-
TestTestCommand(super.runner);
194-
195-
@override
196-
bool get isTesting => true;
197-
198-
@override
199-
Future<int> doit() async => Future(() => 0);
200-
}

0 commit comments

Comments
 (0)