Skip to content

Commit 8a76110

Browse files
authored
Remove some old build logic that is unused: AntBuildCommand (#7745)
1 parent 97401f3 commit 8a76110

File tree

2 files changed

+58
-106
lines changed

2 files changed

+58
-106
lines changed

tool/plugin/lib/plugin.dart

Lines changed: 42 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Future<int> main(List<String> args) async {
2222
var runner = BuildCommandRunner();
2323

2424
runner.addCommand(LintCommand(runner));
25-
runner.addCommand(AntBuildCommand(runner));
2625
runner.addCommand(GradleBuildCommand(runner));
2726
runner.addCommand(TestCommand(runner));
2827
runner.addCommand(DeployCommand(runner));
@@ -292,82 +291,14 @@ void _copyResources(Directory from, Directory to) {
292291
}
293292
}
294293

295-
class AntBuildCommand extends BuildCommand {
296-
AntBuildCommand(BuildCommandRunner runner) : super(runner, 'build');
297-
298-
@override
299-
Future<int> doit() async {
300-
return GradleBuildCommand(runner).doit();
301-
}
302-
303-
@override
304-
Future<int> externalBuildCommand(BuildSpec spec) async {
305-
// Not used
306-
return 0;
307-
}
308-
309-
@override
310-
Future<int> savePluginArtifact(BuildSpec spec) async {
311-
// Not used
312-
return 0;
313-
}
314-
}
315-
316-
class GradleBuildCommand extends BuildCommand {
317-
GradleBuildCommand(BuildCommandRunner runner) : super(runner, 'make');
318-
319-
@override
320-
Future<int> externalBuildCommand(BuildSpec spec) async {
321-
var pluginFile = File('resources/META-INF/plugin.xml');
322-
var studioFile = File('resources/META-INF/studio-contribs.xml');
323-
var pluginSrc = pluginFile.readAsStringSync();
324-
var studioSrc = studioFile.readAsStringSync();
325-
try {
326-
await genPluginFiles(spec, 'resources');
327-
return await runner.buildPlugin(spec, buildVersionNumber(spec));
328-
} finally {
329-
pluginFile.writeAsStringSync(pluginSrc);
330-
studioFile.writeAsStringSync(studioSrc);
331-
}
332-
}
333-
334-
@override
335-
Future<int> savePluginArtifact(BuildSpec spec) async {
336-
final file = File(releasesFilePath(spec));
337-
final version = buildVersionNumber(spec);
338-
var source = File('build/distributions/flutter-intellij-$version.zip');
339-
if (!source.existsSync()) {
340-
// Setting the plugin name in Gradle should eliminate the need for this,
341-
// but it does not.
342-
// TODO(messick) Find a way to make the Kokoro file name: flutter-intellij-DEV.zip
343-
source = File('build/distributions/flutter-intellij-kokoro-$version.zip');
344-
}
345-
_copyFile(
346-
source,
347-
file.parent,
348-
filename: p.basename(file.path),
349-
);
350-
await _stopDaemon();
351-
return 0;
352-
}
353-
354-
Future<int> _stopDaemon() async {
355-
if (Platform.isWindows) {
356-
return await exec('.\\third_party\\gradlew.bat', ['--stop']);
357-
} else {
358-
return await exec('./third_party/gradlew', ['--stop']);
359-
}
360-
}
361-
}
362-
363294
/// Build deployable plugin files. If the --release argument is given
364295
/// then perform additional checks to verify that the release environment
365296
/// is in good order.
366-
abstract class BuildCommand extends ProductCommand {
297+
class GradleBuildCommand extends ProductCommand {
367298
@override
368299
final BuildCommandRunner runner;
369300

370-
BuildCommand(this.runner, String commandName) : super(commandName) {
301+
GradleBuildCommand(this.runner) : super('make') {
371302
argParser.addOption('only-version',
372303
abbr: 'o',
373304
help: 'Only build the specified IntelliJ version; useful for sharding '
@@ -387,10 +318,6 @@ abstract class BuildCommand extends ProductCommand {
387318
String get description => 'Build a deployable version of the Flutter plugin, '
388319
'compiled against the specified artifacts.';
389320

390-
Future<int> externalBuildCommand(BuildSpec spec);
391-
392-
Future<int> savePluginArtifact(BuildSpec spec);
393-
394321
@override
395322
Future<int> doit() async {
396323
final argResults = this.argResults!;
@@ -466,9 +393,49 @@ abstract class BuildCommand extends ProductCommand {
466393
if (argResults.option('only-version') == null) {
467394
checkAndClearAppliedEditCommands();
468395
}
396+
return 0;
397+
}
469398

399+
Future<int> externalBuildCommand(BuildSpec spec) async {
400+
var pluginFile = File('resources/META-INF/plugin.xml');
401+
var studioFile = File('resources/META-INF/studio-contribs.xml');
402+
var pluginSrc = pluginFile.readAsStringSync();
403+
var studioSrc = studioFile.readAsStringSync();
404+
try {
405+
await genPluginFiles(spec, 'resources');
406+
return await runner.buildPlugin(spec, buildVersionNumber(spec));
407+
} finally {
408+
pluginFile.writeAsStringSync(pluginSrc);
409+
studioFile.writeAsStringSync(studioSrc);
410+
}
411+
}
412+
413+
Future<int> savePluginArtifact(BuildSpec spec) async {
414+
final file = File(releasesFilePath(spec));
415+
final version = buildVersionNumber(spec);
416+
var source = File('build/distributions/flutter-intellij-$version.zip');
417+
if (!source.existsSync()) {
418+
// Setting the plugin name in Gradle should eliminate the need for this,
419+
// but it does not.
420+
// TODO(messick) Find a way to make the Kokoro file name: flutter-intellij-DEV.zip
421+
source = File('build/distributions/flutter-intellij-kokoro-$version.zip');
422+
}
423+
_copyFile(
424+
source,
425+
file.parent,
426+
filename: p.basename(file.path),
427+
);
428+
await _stopDaemon();
470429
return 0;
471430
}
431+
432+
Future<int> _stopDaemon() async {
433+
if (Platform.isWindows) {
434+
return await exec('.\\third_party\\gradlew.bat', ['--stop']);
435+
} else {
436+
return await exec('./third_party/gradlew', ['--stop']);
437+
}
438+
}
472439
}
473440

474441
/// Either the --release or --channel options must be provided.

tool/plugin/test/plugin_test.dart

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import 'package:test/test.dart';
1111

1212
void main() {
1313
group("create", () {
14-
test('build', () {
15-
expect(AntBuildCommand(BuildCommandRunner()).name, "build");
16-
});
17-
1814
test('make', () {
1915
expect(GradleBuildCommand(BuildCommandRunner()).name, "make");
2016
});
@@ -35,8 +31,8 @@ void main() {
3531
group("spec", () {
3632
test('build', () async {
3733
var runner = makeTestRunner();
38-
await runner.run(["-r=19", "-d../..", "build"]).whenComplete(() {
39-
var specs = (runner.commands['build'] as ProductCommand).specs;
34+
await runner.run(["-r=19", "-d../..", "make"]).whenComplete(() {
35+
var specs = (runner.commands['make'] as ProductCommand).specs;
4036
expect(specs, isNotNull);
4137
expect(
4238
specs.map((spec) => spec.ideaProduct).toList(),
@@ -146,9 +142,9 @@ void main() {
146142
group('build', () {
147143
test('plugin.xml', () async {
148144
var runner = makeTestRunner();
149-
late TestBuildCommand cmd;
150-
await runner.run(["-d../..", "build"]).whenComplete(() {
151-
cmd = (runner.commands['build'] as TestBuildCommand);
145+
late TestMakeCommand cmd;
146+
await runner.run(["-d../..", "make"]).whenComplete(() {
147+
cmd = (runner.commands['make'] as TestMakeCommand);
152148
});
153149
var spec = cmd.specs[0];
154150
await removeAll('../../build/classes');
@@ -163,7 +159,7 @@ void main() {
163159

164160
test('only-version', () async {
165161
ProductCommand command =
166-
makeTestRunner().commands['build'] as ProductCommand;
162+
makeTestRunner().commands['make'] as ProductCommand;
167163
var results = command.argParser.parse(['--only-version=2023.1']);
168164
expect(results['only-version'], '2023.1');
169165
});
@@ -173,41 +169,41 @@ void main() {
173169
test('parses release', () async {
174170
var runner = makeTestRunner();
175171
late ProductCommand command;
176-
await runner.run(["-d../..", '-r22.0', "build"]).whenComplete(() {
177-
command = (runner.commands['build'] as ProductCommand);
172+
await runner.run(["-d../..", '-r22.0', "make"]).whenComplete(() {
173+
command = (runner.commands['make'] as ProductCommand);
178174
});
179175
expect(command.release, '22.0');
180176
});
181177
test('parses release partial number', () async {
182178
var runner = makeTestRunner();
183179
late ProductCommand command;
184-
await runner.run(["-d../..", '-r22', "build"]).whenComplete(() {
185-
command = (runner.commands['build'] as ProductCommand);
180+
await runner.run(["-d../..", '-r22', "make"]).whenComplete(() {
181+
command = (runner.commands['make'] as ProductCommand);
186182
});
187183
expect(command.release, '22.0');
188184
});
189185

190186
test('isReleaseValid', () async {
191187
var runner = makeTestRunner();
192188
late ProductCommand command;
193-
await runner.run(["-d../..", '-r22.0', "build"]).whenComplete(() {
194-
command = (runner.commands['build'] as ProductCommand);
189+
await runner.run(["-d../..", '-r22.0', "make"]).whenComplete(() {
190+
command = (runner.commands['make'] as ProductCommand);
195191
});
196192
expect(command.isReleaseValid, true);
197193
});
198194
test('isReleaseValid partial version', () async {
199195
var runner = makeTestRunner();
200196
late ProductCommand command;
201-
await runner.run(["-d../..", '-r22', "build"]).whenComplete(() {
202-
command = (runner.commands['build'] as ProductCommand);
197+
await runner.run(["-d../..", '-r22', "make"]).whenComplete(() {
198+
command = (runner.commands['make'] as ProductCommand);
203199
});
204200
expect(command.isReleaseValid, true);
205201
});
206202
test('isReleaseValid bad version', () async {
207203
var runner = makeTestRunner();
208204
late ProductCommand command;
209-
await runner.run(["-d../..", '-r22.0.0', "build"]).whenComplete(() {
210-
command = (runner.commands['build'] as ProductCommand);
205+
await runner.run(["-d../..", '-r22.0.0', "make"]).whenComplete(() {
206+
command = (runner.commands['make'] as ProductCommand);
211207
});
212208
expect(command.isReleaseValid, false);
213209
});
@@ -216,24 +212,13 @@ void main() {
216212

217213
BuildCommandRunner makeTestRunner() {
218214
var runner = BuildCommandRunner();
219-
runner.addCommand(TestBuildCommand(runner));
220215
runner.addCommand(TestMakeCommand(runner));
221216
runner.addCommand(TestTestCommand(runner));
222217
runner.addCommand(TestDeployCommand(runner));
223218
runner.addCommand(TestGenCommand(runner));
224219
return runner;
225220
}
226221

227-
class TestBuildCommand extends AntBuildCommand {
228-
TestBuildCommand(super.runner);
229-
230-
@override
231-
bool get isTesting => true;
232-
233-
@override
234-
Future<int> doit() async => Future(() => 0);
235-
}
236-
237222
class TestMakeCommand extends GradleBuildCommand {
238223
TestMakeCommand(super.runner);
239224

0 commit comments

Comments
 (0)