Skip to content

Commit f1d7c19

Browse files
authored
Update plugin tool documentation and remove unused commands (#8411)
This removes the commands that respond to `bin/plugin make` and `bin/plugin run`.
1 parent bad0df2 commit f1d7c19

File tree

4 files changed

+28
-390
lines changed

4 files changed

+28
-390
lines changed

tool/plugin/README.md

Lines changed: 28 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,56 @@
1-
21
# Flutter Plugin Maintenance Tool
32

4-
The previous builder for the Flutter plugin was written in Ant. An expert in Ant would probably have no trouble maintaining it, but we have no such expert available. In order to increase stability and productivity we transformed the builder into a Dart command line tool, inspired by the Flutter tool. The tool is named `plugin`, since it helps with plugin development.
5-
3+
The previous builder for the Flutter plugin was written in Ant. An expert in Ant would probably have no trouble maintaining it, but we have
4+
no such expert available. In order to increase stability and productivity we transformed the builder into a Dart command line tool, inspired
5+
by the Flutter tool. The tool is named `plugin`, since it helps with plugin development.
66

77
## Functions
88

9-
The tool needs to perform several functions. Building is the basic one, but others are important too. Implementation note: these will be implemented as compound commands in the CLI tool (similar to `flutter doctor` or `flutter run` in the Flutter CLI tool).
9+
The tool needs to perform several functions. Building is the basic one, but others are important too. Implementation note: these will be
10+
implemented as compound commands in the CLI tool (similar to `flutter doctor` or `flutter run` in the Flutter CLI tool).
1011

11-
* `make`
12-
* `test`
13-
* `deploy`
14-
* `generate`
15-
* `lint`
12+
* `deploy`
13+
* `generate`
14+
* `lint`
1615

1716
Each command has its own set of optional arguments. If the CLI tool is invoked without a command then it will print its help message.
1817

1918
There are two global options. On the command line these are given prior to the command name.
2019

21-
22-
23-
* `-r, --release=XX`
24-
Use "release mode." The `XX` value specifies the release identifier, like 18 or 19.1. It will be shown in the "version" field of the plugin manager's listing for the Flutter plugin. In this mode additional constraints must be satisfied. The current git branch must have no unsaved changes and must be named "release_XX". The `.github/workflows/presubmit.yaml` file must be newer than the `product-matrix.json` file (see the `generate` command).
25-
* `-d, --cwd=<working-directory>`
26-
Set the root directory to the `working-directory` value. This should not be used when running the tool from the command line. It is only intended to be used when running tests from IntelliJ run configurations that have no way to specify the working directory.
27-
28-
29-
### Make
30-
31-
Builds may be targeted for local development or distribution.
32-
33-
34-
35-
* `-[no-]ij`
36-
Build for IntelliJ. Default is true; may be negated by including `no`.
37-
* `-[no-]as`
38-
Build for Android Studio. Default is true; may be negated by including `no`.
39-
* `-o, --only-version=ID`
40-
Only build the specified IntelliJ version. `ID` is one of the "version" strings in product-matrix.json.
41-
* `-u, --unpack`
42-
Normally the archive files are not unpacked if the corresponding directory exists. This flag forces the archive files to be unpacked.
43-
44-
45-
The make function must generate the correct `plugin.xml` for each platform and generate the correct artifacts for each. In release mode the archive files are always unpacked (--unpack is implied). The plugin files are saved in the `artifacts` directory. In release mode a subdirectory of `artifacts` is created which has the name of the release and they are put there. During a local dev/test run the subdirectory is not created and the created files are children of `artifacts`.
46-
47-
Returns a success or failure code to play nice with shell commands.
48-
49-
50-
### Test
51-
52-
Both unit and integration tests need to run, and tests should work whether running locally or on Travis.
53-
54-
55-
56-
* `-u, --[no-]unit
57-
`Run unit tests (or not).
58-
* `-i, --[no-]integration`
59-
Run GUI-based integration tests (or not).
60-
61-
TBD: We may need some mechanism to automatically upload testing artifacts, since we can no longer attach zip files to email. This could also potentially be addressed by creating a 'dev' channel for the plugin on the JetBrains store, and publishing to it when we have release candidates.
62-
20+
* `-r, --release=XX`
21+
Use "release mode." The `XX` value specifies the release identifier, like 18 or 19.1. It will be shown in the "version" field of the
22+
plugin manager's listing for the Flutter plugin. In this mode additional constraints must be satisfied. The current git branch must have
23+
no unsaved changes and must be named "release_XX". The `.github/workflows/presubmit.yaml` file must be newer than the
24+
`product-matrix.json` file (see the `generate` command).
25+
* `-d, --cwd=<working-directory>`
26+
Set the root directory to the `working-directory` value. This should not be used when running the tool from the command line. It is only
27+
intended to be used when running tests from IntelliJ run configurations that have no way to specify the working directory.
6328

6429
### Deploy
6530

66-
Automatically upload all required artifacts to the JetBrains site. This function will print instructions to retrieve the password from valentine then prompt for the password to log into the JetBrains site. It has no options. Returns a success or failure code to play nice with shell commands.
31+
Automatically upload all required artifacts to the JetBrains site. This function will print instructions to retrieve the password from
32+
valentine then prompt for the password to log into the JetBrains site. It has no options. Returns a success or failure code to play nice
33+
with shell commands.
6734
(Used primarily by the dev channel Kokoro job. Not sure if it works for uploading to the stable channel.)
6835

6936
### Generate
7037

71-
Generate a `plugin.xml` from `plugin.xml.template` to be used for launching a runtime workbench. This is different from the ones generated during building because it will have a version range that allows use in all targeted platforms.
72-
38+
This is now only used for live templates (see `resources/liveTemplates`).
7339

7440
### Lint
7541

7642
Run the lint tool. It checks for bad imports and prints a report of the Dart plugin API usage.
7743

78-
79-
## Examples
80-
81-
Build the Flutter plugin for IntelliJ and Android Studio, in distribution mode.
82-
83-
`plugin -r19.2 make`
84-
85-
Build a local version of the IntelliJ version of the plugin, not for distribution.
86-
87-
`plugin make --no-as`
88-
89-
Run integration tests without doing a build, assuming an edit-build-test cycle during development.
90-
91-
`plugin test --no-unit`
92-
93-
Build everything then run all tests. The big question here is: Can we get integration tests to run using the newly-built plugin rather than sources?
94-
95-
`plugin make && plugin test`
96-
9744
## Debugging
9845

99-
It can be difficult to debug issues that only occur with a deployable
100-
plugin built by `plugin make`. Here's how to set up remote
101-
debugging with IntelliJ:
46+
It can be difficult to debug issues that only occur with a deployable plugin. Here's how to set up remote debugging with IntelliJ:
10247

103-
In IntelliJ create a "Remote" type of run configuration. It
104-
shows you the command-line arg you need to add in the top
105-
text field of the run config. Copy that text.
48+
In IntelliJ create a "Remote" type of run configuration. It shows you the command-line arg you need to add in the top text field of the run
49+
config. Copy that text.
10650

107-
Now, (assuming you are on a Mac) find your IJ or AS app in
108-
the Finder. Right-click, 'Show Package Contents', open
109-
Contents, edit Info.plist. In the plist editor expand
110-
JVMOptions and then edit VMOptions. Append the copied text
111-
to the end. Save the plist editor and launch the AS or IJ app.
51+
Now, (assuming you are on a Mac) find your IJ or AS app in the Finder. Right-click, 'Show Package Contents', open Contents, edit Info.plist.
52+
In the plist editor expand JVMOptions and then edit VMOptions. Append the copied text to the end. Save the plist editor and launch the AS or
53+
IJ app.
11254

113-
Back in IntelliJ, select your new run config and click the
114-
debug icon to attach the debugger to the app. The copied
115-
text includes "suspend=n". If you want to set a breakpoint
116-
before execution begins change that 'n' to 'y'.
55+
Back in IntelliJ, select your new run config and click the debug icon to attach the debugger to the app. The copied text includes "
56+
suspend=n". If you want to set a breakpoint before execution begins change that 'n' to 'y'.

tool/plugin/lib/plugin.dart

Lines changed: 0 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ Future<int> main(List<String> args) async {
2121
var runner = BuildCommandRunner();
2222

2323
runner.addCommand(LintCommand(runner));
24-
runner.addCommand(GradleBuildCommand(runner));
2524
runner.addCommand(TestCommand(runner));
2625
runner.addCommand(DeployCommand(runner));
2726
runner.addCommand(GenerateCommand(runner));
28-
runner.addCommand(RunIdeCommand(runner));
2927

3028
try {
3129
return await runner.run(args) ?? 0;
@@ -201,170 +199,6 @@ void _copyResources(Directory from, Directory to) {
201199
}
202200
}
203201

204-
/// Build deployable plugin files. If the --release argument is given
205-
/// then perform additional checks to verify that the release environment
206-
/// is in good order.
207-
class GradleBuildCommand extends ProductCommand {
208-
@override
209-
final BuildCommandRunner runner;
210-
211-
GradleBuildCommand(this.runner) : super('make') {
212-
argParser.addOption(
213-
'only-version',
214-
abbr: 'o',
215-
help: 'Only build the specified IntelliJ version; useful for sharding '
216-
'builds on CI systems.',
217-
);
218-
argParser.addFlag(
219-
'unpack',
220-
abbr: 'u',
221-
help: 'Unpack the artifact files during provisioning, '
222-
'even if the cache appears fresh.\n'
223-
'This flag is ignored if --release is given.',
224-
defaultsTo: false,
225-
);
226-
argParser.addOption(
227-
'minor',
228-
abbr: 'm',
229-
help: 'Set the minor version number.',
230-
);
231-
argParser.addFlag('setup', abbr: 's', defaultsTo: true);
232-
}
233-
234-
@override
235-
String get description => 'Build a deployable version of the Flutter plugin, '
236-
'compiled against the specified artifacts.';
237-
238-
@override
239-
Future<int> doit() async {
240-
final argResults = this.argResults!;
241-
if (isReleaseMode) {
242-
if (argResults.flag('unpack')) {
243-
separator('Release mode (--release) implies --unpack');
244-
}
245-
if (!await performReleaseChecks(this)) {
246-
return 1;
247-
}
248-
}
249-
250-
// Check to see if we should only be building a specific version.
251-
final onlyVersion = argResults.option('only-version');
252-
253-
var buildSpecs = specs;
254-
if (onlyVersion != null && onlyVersion.isNotEmpty) {
255-
buildSpecs = specs.where((spec) => spec.version == onlyVersion).toList();
256-
if (buildSpecs.isEmpty) {
257-
log("No spec found for version '$onlyVersion'");
258-
return 1;
259-
}
260-
}
261-
262-
final minorNumber = argResults.option('minor');
263-
if (minorNumber != null) {
264-
pluginCount = int.parse(minorNumber) - 1;
265-
}
266-
267-
var result = 0;
268-
for (var spec in buildSpecs) {
269-
if (spec.channel != channel) {
270-
continue;
271-
}
272-
if (!(isForIntelliJ && isForAndroidStudio)) {
273-
// This is a little more complicated than I'd like because the default
274-
// is to always do both.
275-
if (isForAndroidStudio && !spec.isAndroidStudio) continue;
276-
if (isForIntelliJ && spec.isAndroidStudio) continue;
277-
}
278-
279-
pluginCount++;
280-
if (spec.isDevChannel && !isDevChannel) {
281-
spec.buildForMaster();
282-
}
283-
284-
separator('Building flutter-intellij.jar');
285-
await removeAll('build');
286-
287-
log('$spec');
288-
289-
result = await applyEdits(spec, () async {
290-
return await externalBuildCommand(spec);
291-
});
292-
if (result != 0) {
293-
log('applyEdits() returned ${result.toString()}');
294-
return result;
295-
}
296-
297-
try {
298-
result = await savePluginArtifact(spec);
299-
if (result != 0) {
300-
return result;
301-
}
302-
} catch (ex) {
303-
log("$ex");
304-
return 1;
305-
}
306-
307-
separator('Built artifact');
308-
final releaseFilePath = releasesFilePath(spec);
309-
final file = File(releaseFilePath);
310-
final fileSize = file.lengthSync() / 1000000;
311-
log('$releaseFilePath, $fileSize MB');
312-
}
313-
if (argResults.option('only-version') == null) {
314-
checkAndClearAppliedEditCommands();
315-
}
316-
// Print a summary of the collection of plugin versions built:
317-
var builtVersions = buildSpecs.map((spec) => spec.name).toList().join(', ');
318-
log(
319-
'\nMake of the ${buildSpecs.length} builds was '
320-
'successful: $builtVersions.',
321-
);
322-
return result;
323-
}
324-
325-
Future<int> externalBuildCommand(BuildSpec spec) async {
326-
var pluginFile = File('resources/META-INF/plugin.xml');
327-
var studioFile = File('resources/META-INF/studio-contribs.xml');
328-
var pluginSrc = pluginFile.readAsStringSync();
329-
var studioSrc = studioFile.readAsStringSync();
330-
try {
331-
return await runner.buildPlugin(spec, buildVersionNumber(spec));
332-
} finally {
333-
pluginFile.writeAsStringSync(pluginSrc);
334-
studioFile.writeAsStringSync(studioSrc);
335-
}
336-
}
337-
338-
Future<int> savePluginArtifact(BuildSpec spec) async {
339-
final file = File(releasesFilePath(spec));
340-
341-
// Log the contents of ./build/distributions, this is useful in debugging
342-
// in general and especially useful for the Kokoro bot which is run remotely
343-
final result = Process.runSync('ls', [
344-
'-laf',
345-
'-laf',
346-
'build/distributions',
347-
]);
348-
log('Content generated in ./build/distributions:\n${result.stdout}');
349-
350-
var source = File('build/distributions/flutter-intellij.zip');
351-
if (!source.existsSync()) {
352-
source = File('build/distributions/flutter-intellij-kokoro.zip');
353-
}
354-
_copyFile(source, file.parent, filename: p.basename(file.path));
355-
await _stopDaemon();
356-
return 0;
357-
}
358-
359-
Future<int> _stopDaemon() async {
360-
if (Platform.isWindows) {
361-
return await exec('.\\gradlew.bat', ['--stop']);
362-
} else {
363-
return await exec('./gradlew', ['--stop']);
364-
}
365-
}
366-
}
367-
368202
/// Either the --release or --channel options must be provided.
369203
/// The permanent token is read from the file specified by Kokoro.
370204
/// This is used by Kokoro to build and upload the dev version of the plugin.
@@ -516,42 +350,6 @@ class GenerateCommand extends ProductCommand {
516350
}
517351
}
518352

519-
/// Run the IDE using the gradle task "runIde"
520-
class RunIdeCommand extends ProductCommand {
521-
@override
522-
final BuildCommandRunner runner;
523-
524-
RunIdeCommand(this.runner) : super('run');
525-
526-
@override
527-
String get description => 'Run the IDE plugin';
528-
529-
@override
530-
Future<int> doit() async {
531-
final javaHome = Platform.environment['JAVA_HOME'];
532-
if (javaHome == null) {
533-
log('JAVA_HOME environment variable not set - this is needed by Gradle.');
534-
return 1;
535-
}
536-
log('JAVA_HOME=$javaHome');
537-
538-
// TODO(jwren) The IDE run is determined currently by the isUnitTestTarget
539-
// in the product-matrix.json, while useful, a new field should be added
540-
// into the product-matrix.json instead of re-using this field,
541-
// Or, the run IDE should be passed via the command line (I don't like this
542-
// as much.)
543-
final spec = specs.firstWhere((s) => s.isUnitTestTarget);
544-
return await _runIde(spec);
545-
}
546-
547-
Future<int> _runIde(BuildSpec spec) async {
548-
// run './gradlew runIde'
549-
return await applyEdits(spec, () async {
550-
return await runner.runGradleCommand(['runIde'], spec, '1', 'false');
551-
});
552-
}
553-
}
554-
555353
abstract class ProductCommand extends Command<int> {
556354
@override
557355
final String name;

0 commit comments

Comments
 (0)