Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3e86400
Add `archive` package to dependencies.
firephreek Mar 23, 2022
d88ac74
Add `stripComponents` function to util.dart
firephreek Mar 23, 2022
d12f561
Add a platform-agnostic function for extracting content from a tar'd …
firephreek Mar 23, 2022
105b3b3
Throw explicit FileSystemException from `getFileOrThrow`
firephreek Mar 23, 2022
c4da661
Use the more specific osError.message and fall back to message if not…
firephreek Mar 23, 2022
4cb06f9
Implement platform-agnostic zip file extraction.
firephreek Mar 23, 2022
e589ae4
Indirection function to select the platform specific gradle wrapper.
firephreek Mar 23, 2022
ca09091
Refactor _stopDaemon to use gradle selector.
firephreek Mar 23, 2022
840b83f
Simplify `runGradleCommand` using a block for version 4.1 and gradle …
firephreek Mar 23, 2022
0d20819
extractZip just takes a file path, not an artifact.
firephreek Mar 23, 2022
6f72f63
Replace calls to `unzip` on OS to a platform-agnostic call.
firephreek Mar 23, 2022
10fb7fe
Replace calls to `tar` on OS to a platform-agnostic call.
firephreek Mar 23, 2022
17aa4c0
Remove redundant code.
firephreek Mar 23, 2022
b52e5f3
Replace `deleteBuildContents` shell call with platform-agnostic call.
firephreek Mar 23, 2022
57102bc
Replace `moveToArtifacts` shell call with platform-agnostic call.
firephreek Mar 23, 2022
3a63e48
Replace `removeAll` shell call with a platform-agnostic version.
firephreek Mar 23, 2022
408b398
Add try/catch for `jar` command to notify the user if the shell comma…
firephreek Mar 23, 2022
b78788b
Add dependency on `http` to support download operations.
firephreek Mar 23, 2022
b881c9d
Replace shell call to curl with platform-agnostic version.
firephreek Mar 23, 2022
0c9b201
Rename `curl` to `download`
firephreek Mar 23, 2022
e85efd3
Fix pathing updates to use platform separators.
firephreek Mar 23, 2022
14117a8
Normalize file paths to use OS separators.
firephreek Mar 23, 2022
a1e2674
Cleanup and import optimization
firephreek Mar 23, 2022
cb2296f
Use empty string as default instead of null.
firephreek Mar 23, 2022
ad3d092
Remove param from _flushToFile
firephreek Mar 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ void main(List<String> args) => grind(args);
@Task('Check plugin URLs for live-ness')
void checkUrls() async {
log('checking URLs in FlutterBundle.properties...');
var lines =
await File('flutter-idea/src/io/flutter/FlutterBundle.properties').readAsLines();
var lines = await File('flutter-idea/src/io/flutter/FlutterBundle.properties')
.readAsLines();
for (var line in lines) {
var split = line.split('=');
if (split.length == 2) {
Expand Down
64 changes: 26 additions & 38 deletions tool/plugin/lib/artifact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ class Artifact {
bool get isZip => file.endsWith('.zip');

bool exists() {
if (FileSystemEntity.isFileSync('artifacts/$file')) return true;
var artifactFilePath = p.join('artifacts', file);
if (FileSystemEntity.isFileSync(artifactFilePath)) return true;
convertToTar();
return FileSystemEntity.isFileSync('artifacts/$file');
return FileSystemEntity.isFileSync(artifactFilePath);
}

String get outPath => p.join(rootPath, 'artifacts', output);
Expand All @@ -39,7 +40,7 @@ class Artifact {
}

class ArtifactManager {
final String base =
final String baseUri =
'https://storage.googleapis.com/flutter_infra_release/flutter/intellij';

final List<Artifact> artifacts = [];
Expand Down Expand Up @@ -72,42 +73,44 @@ class ArtifactManager {
doDownload = false;
}

var path = 'artifacts/${artifact.file}';
if (FileSystemEntity.isFileSync(path)) {
alreadyDownloaded(path);
var artifactFilePath = p.join('artifacts', artifact.file);
if (FileSystemEntity.isFileSync(artifactFilePath)) {
alreadyDownloaded(artifactFilePath);
} else {
if (artifact.isZip) {
var tarPath = _convertToTar(path);
var tarPath = _convertToTar(artifactFilePath);
if (FileSystemEntity.isFileSync(tarPath)) {
artifact.convertToTar();
alreadyDownloaded(tarPath);
}
}
if (doDownload) {
log('downloading $path...');
result = await curl('$base/${artifact.file}', to: path);
log('downloading $artifactFilePath...');
var artifactUri = p.join(baseUri, artifact.file);

result = await download(artifactUri, to: artifactFilePath);
if (result != 0) {
log('download failed');
}
var archiveFile = File(path);
var archiveFile = File(artifactFilePath);
if (!_isValidDownloadArtifact(archiveFile)) {
// If the file is missing the server returns a small file containing
// an error message. Delete it and try again. The smallest file we
// store in the cloud is over 700K.
log('archive file not found: $base/${artifact.file}');
log('archive file not found: $artifactUri');
archiveFile.deleteSync();
if (artifact.isZip) {
artifact.convertToTar();
path = 'artifacts/${artifact.file}';
result = await curl('$base/${artifact.file}', to: path);

result = await download(artifactUri, to: artifactFilePath);
if (result != 0) {
log('download failed');
artifacts.remove(artifact);
continue;
}
var archiveFile = File(path);
var archiveFile = File(artifactFilePath);
if (!_isValidDownloadArtifact(archiveFile)) {
log('archive file not found: $base/${artifact.file}');
log('archive file not found: $artifactUri');
archiveFile.deleteSync();
artifacts.remove(artifact);
continue;
Expand All @@ -122,23 +125,17 @@ class ArtifactManager {

// clear unpacked cache
if (rebuildCache || !FileSystemEntity.isDirectorySync(artifact.outPath)) {
await removeAll(artifact.outPath);
removeAll(artifact.outPath);
}
if (isCacheDirectoryValid(artifact)) {
continue;
}

// expand
if (Directory(artifact.outPath).existsSync()) {
await removeAll(artifact.outPath);
}
createDir(artifact.outPath);

if (artifact.isZip) {
if (artifact.bareArchive) {
result = await exec(
'unzip', ['-q', '-d', artifact.output, artifact.file],
cwd: 'artifacts');
result = extractZip(artifact.file,
cwd: 'artifacts', targetDirectory: artifact.output);

var files = Directory(artifact.outPath).listSync();
if (files.length < 3) /* Might have .DS_Store */ {
// This is the Mac zip case.
Expand All @@ -152,24 +149,15 @@ class ArtifactManager {
Directory("${artifact.outPath}Temp").renameSync(artifact.outPath);
}
} else {
result = await exec('unzip', ['-q', artifact.file], cwd: 'artifacts');
result = extractZip(artifact.file, cwd: 'artifacts');
}
} else {
result = await exec(
'tar',
[
'--strip-components=1',
'-zxf',
artifact.file,
'-C',
artifact.output
],
cwd: p.join(rootPath, 'artifacts'),
);
result = extractTar(artifact,
cwd: 'artifacts', targetDirectory: artifact.output);
}
if (result != 0) {
log('unpacking failed');
await removeAll(artifact.output);
removeAll(artifact.output);
break;
}

Expand Down
15 changes: 9 additions & 6 deletions tool/plugin/lib/edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'dart:async';
import 'dart:io';

import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;

import 'build_spec.dart';
import 'util.dart';
Expand Down Expand Up @@ -96,17 +97,20 @@ class Unused extends EditCommand {
}

class EditAndroidModuleLibraryManager extends EditCommand {
final _moduleManagerPath = p.join('flutter-studio', 'src', 'io', 'flutter',
'android', 'AndroidModuleLibraryManager.java');

@override
String get path =>
'flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java';
String get path => _moduleManagerPath;

@override
String convert(BuildSpec spec) {
// Starting with 3.6 we need to call a simplified init().
// This is where the $PROJECT_FILE$ macro is defined, #registerComponents.

var libMgrPath = _moduleManagerPath;
if (spec.version.startsWith('4.2')) {
var processedFile = File(
'flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java');
var processedFile = File(libMgrPath);
var source = processedFile.readAsStringSync();
var original = source;
source = source.replaceAll("ProjectExImpl", "ProjectImpl");
Expand All @@ -133,8 +137,7 @@ class EditAndroidModuleLibraryManager extends EditCommand {
return original;
} else {
if (spec.version.startsWith('2021.2')) {
var processedFile = File(
'flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java');
var processedFile = File(libMgrPath);
var source = processedFile.readAsStringSync();
var original = source;
source = source.replaceAll(
Expand Down
2 changes: 1 addition & 1 deletion tool/plugin/lib/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const int cloudErrorFileMaxSize = 1000; // In bytes.
// Globals are initialized early in ProductCommand. These are used in various
// top-level functions. This is not ideal, but the "proper" solution would be
// to move nearly all the top-level functions to methods in ProductCommand.
String rootPath;
String rootPath = '';
String lastReleaseName;
DateTime lastReleaseDate;
int pluginCount = 0;
Loading