License update (#45373) * Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
diff --git a/dev/bots/accept_android_sdk_licenses.sh b/dev/bots/accept_android_sdk_licenses.sh index a5b6abb..858d96d 100755 --- a/dev/bots/accept_android_sdk_licenses.sh +++ b/dev/bots/accept_android_sdk_licenses.sh
@@ -1,4 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + set -e # This script is only meant to be run by the Cirrus CI system, not locally.
diff --git a/dev/bots/analyze-sample-code.dart b/dev/bots/analyze-sample-code.dart index 767aab6..ba2a2d0 100644 --- a/dev/bots/analyze-sample-code.dart +++ b/dev/bots/analyze-sample-code.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 6f4d386..093d399 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -49,6 +49,7 @@ /// For example: /// bin/cache/dart-sdk/bin/dart dev/bots/analyze.dart --dart-sdk=/tmp/dart-sdk Future<void> main(List<String> arguments) async { + print('$clock STARTING ANALYSIS'); try { await run(arguments); } on ExitException catch (error) { @@ -65,28 +66,48 @@ exit(1); } + print('$clock Deprecations...'); await verifyDeprecations(flutterRoot); + + print('$clock Licenses...'); await verifyNoMissingLicense(flutterRoot); + + print('$clock Test imports...'); await verifyNoTestImports(flutterRoot); + + print('$clock Test package imports...'); await verifyNoTestPackageImports(flutterRoot); + + print('$clock Generated plugin registrants...'); await verifyGeneratedPluginRegistrants(flutterRoot); + + print('$clock Bad imports (framework)...'); await verifyNoBadImportsInFlutter(flutterRoot); + + print('$clock Bad imports (tools)...'); await verifyNoBadImportsInFlutterTools(flutterRoot); + + print('$clock Internationalization...'); await verifyInternationalizations(); + + print('$clock Trailing spaces...'); await verifyNoTrailingSpaces(); // Ensure that all package dependencies are in sync. + print('$clock Package dependencies...'); await runCommand(flutter, <String>['update-packages', '--verify-only'], workingDirectory: flutterRoot, ); // Analyze all the sample code in the repo + print('$clock Sample code...'); await runCommand(dart, <String>[path.join(flutterRoot, 'dev', 'bots', 'analyze-sample-code.dart')], workingDirectory: flutterRoot, ); // Analyze all the Dart code in the repo. + print('$clock Dart analysis...'); await _runFlutterAnalyze(flutterRoot, options: <String>[ '--flutter-repo', ...arguments, @@ -94,6 +115,7 @@ // Try with the --watch analyzer, to make sure it returns success also. // The --benchmark argument exits after one run. + print('$clock Dart analysis (with --watch)...'); await _runFlutterAnalyze(flutterRoot, options: <String>[ '--flutter-repo', '--watch', @@ -102,8 +124,8 @@ ]); // Try analysis against a big version of the gallery; generate into a temporary directory. + print('$clock Dart analysis (mega gallery)...'); final Directory outDir = Directory.systemTemp.createTempSync('flutter_mega_gallery.'); - try { await runCommand(dart, <String>[ @@ -113,13 +135,11 @@ ], workingDirectory: flutterRoot, ); - { - await _runFlutterAnalyze(outDir.path, options: <String>[ - '--watch', - '--benchmark', - ...arguments, - ]); - } + await _runFlutterAnalyze(outDir.path, options: <String>[ + '--watch', + '--benchmark', + ...arguments, + ]); } finally { outDir.deleteSync(recursive: true); } @@ -146,7 +166,7 @@ Future<void> verifyDeprecations(String workingDirectory) async { final List<String> errors = <String>[]; - for (File file in _dartFiles(workingDirectory)) { + for (File file in _allFiles(workingDirectory, 'dart')) { int lineNumber = 0; final List<String> lines = file.readAsLinesSync(); final List<int> linesWithDeprecations = <int>[]; @@ -212,24 +232,53 @@ } } +String _generateLicense(String prefix) { + assert(prefix != null); + return '${prefix}Copyright 2014 The Flutter Authors. All rights reserved.\n' + '${prefix}Use of this source code is governed by a BSD-style license that can be\n' + '${prefix}found in the LICENSE file.'; +} + Future<void> verifyNoMissingLicense(String workingDirectory) async { + await _verifyNoMissingLicenseForExtension(workingDirectory, 'dart', _generateLicense('// '), skipShrine: true); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'java', _generateLicense('// ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'h', _generateLicense('// ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'm', _generateLicense('// ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'swift', _generateLicense('// ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'gradle', _generateLicense('// ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'gn', _generateLicense('# ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'sh', '#!/usr/bin/env bash\n' + _generateLicense('# ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'bat', '@ECHO off\n' + _generateLicense('REM ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'ps1', _generateLicense('# ')); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'html', '<!DOCTYPE HTML>\n<!-- ${_generateLicense('')} -->', trailingBlank: false); + await _verifyNoMissingLicenseForExtension(workingDirectory, 'xml', '<!-- ${_generateLicense('')} -->'); +} + +Future<void> _verifyNoMissingLicenseForExtension(String workingDirectory, String extension, String license, { bool trailingBlank = true, bool skipShrine = true }) async { + assert(!license.endsWith('\n')); + final String licensePattern = license + '\n' + (trailingBlank ? '\n' : ''); final List<String> errors = <String>[]; - for (FileSystemEntity entity in _dartFiles(workingDirectory)) { + for (FileSystemEntity entity in _allFiles(workingDirectory, extension)) { final File file = entity; - bool hasLicense = false; - final List<String> lines = file.readAsLinesSync(); - if (lines.isNotEmpty) - hasLicense = lines.first.startsWith(RegExp(r'// Copyright \d{4}')); - if (!hasLicense) + if (skipShrine && path.split(file.path).contains('shrine')) + continue; // TODO(ianh): I'm investigating relicensing this directory. + final String contents = file.readAsStringSync().replaceAll('\r\n', '\n'); + if (contents.isEmpty) + continue; // let's not go down the /bin/true rabbit hole + if (!contents.startsWith(licensePattern)) errors.add(file.path); } // Fail if any errors if (errors.isNotEmpty) { print('$redLine'); - final String s = errors.length == 1 ? '' : 's'; - print('${bold}License headers cannot be found at the beginning of the following file$s.$reset\n'); + final String s = errors.length == 1 ? ' does' : 's do'; + print('${bold}The following ${errors.length} file$s not have the right license header:$reset\n'); print(errors.join('\n')); print('$redLine\n'); + print('The expected license header is:'); + print('$license'); + if (trailingBlank) + print('...followed by a blank line.'); exit(1); } } @@ -575,13 +624,21 @@ return true; } -Iterable<File> _dartFiles(String workingDirectory) sync* { +Iterable<File> _allFiles(String workingDirectory, String extension) sync* { final Set<FileSystemEntity> pending = <FileSystemEntity>{ Directory(workingDirectory) }; while (pending.isNotEmpty) { final FileSystemEntity entity = pending.first; pending.remove(entity); + if (path.extension(entity.path) == '.tmpl') + continue; if (entity is File) { - if (path.extension(entity.path) == '.dart') + if (_isGeneratedPluginRegistrant(entity)) + continue; + if (path.basename(entity.path) == 'flutter_export_environment.sh') + continue; + if (path.basename(entity.path) == 'gradlew.bat') + continue; + if (path.extension(entity.path) == '.$extension') yield entity; } else if (entity is Directory) { if (File(path.join(entity.path, '.dartignore')).existsSync()) @@ -590,6 +647,8 @@ continue; if (path.basename(entity.path) == '.dart_tool') continue; + if (path.basename(entity.path) == 'build') + continue; pending.addAll(entity.listSync()); } }
diff --git a/dev/bots/codelabs_build_test.sh b/dev/bots/codelabs_build_test.sh index 721bd5c..ef594a9 100755 --- a/dev/bots/codelabs_build_test.sh +++ b/dev/bots/codelabs_build_test.sh
@@ -1,6 +1,7 @@ -#!/bin/bash -# Copyright 2018 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. set -ex
diff --git a/dev/bots/debug_smoke_ftl.sh b/dev/bots/debug_smoke_ftl.sh index bca29b8..333e2d5 100755 --- a/dev/bots/debug_smoke_ftl.sh +++ b/dev/bots/debug_smoke_ftl.sh
@@ -1,4 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. set -e
diff --git a/dev/bots/deploy_gallery.sh b/dev/bots/deploy_gallery.sh index 3553ef1..34267c4 100755 --- a/dev/bots/deploy_gallery.sh +++ b/dev/bots/deploy_gallery.sh
@@ -1,4 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. set -e
diff --git a/dev/bots/docs.sh b/dev/bots/docs.sh index 3df24c8..d99eea1 100755 --- a/dev/bots/docs.sh +++ b/dev/bots/docs.sh
@@ -1,4 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + set -e function deploy {
diff --git a/dev/bots/download_android_sdk.sh b/dev/bots/download_android_sdk.sh index cafa3f4..84817f4 100755 --- a/dev/bots/download_android_sdk.sh +++ b/dev/bots/download_android_sdk.sh
@@ -1,4 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. set -e
diff --git a/dev/bots/download_goldctl.ps1 b/dev/bots/download_goldctl.ps1 index f83cd8c..3b2275c 100644 --- a/dev/bots/download_goldctl.ps1 +++ b/dev/bots/download_goldctl.ps1
@@ -1,3 +1,7 @@ +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + $url= "https://storage.googleapis.com/chrome-infra/depot_tools.zip" $zipPath = "C:\Windows\Temp\depot_tools.zip" $path = "C:\Windows\Temp\depot_tools"
diff --git a/dev/bots/download_goldctl.sh b/dev/bots/download_goldctl.sh index 7fcaa1f..8f1077e 100755 --- a/dev/bots/download_goldctl.sh +++ b/dev/bots/download_goldctl.sh
@@ -1,4 +1,7 @@ #!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git ./depot_tools cd depot_tools
diff --git a/dev/bots/download_open_jdk.sh b/dev/bots/download_open_jdk.sh index 313ce05..aa746e7 100755 --- a/dev/bots/download_open_jdk.sh +++ b/dev/bots/download_open_jdk.sh
@@ -1,4 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. set -e
diff --git a/dev/bots/firebase_testlab.sh b/dev/bots/firebase_testlab.sh index 98f1020..2f3e568 100755 --- a/dev/bots/firebase_testlab.sh +++ b/dev/bots/firebase_testlab.sh
@@ -1,4 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. # The tests to run on Firebase Test Lab. # Currently, the test consists on building an Android App Bundle and ensuring
diff --git a/dev/bots/flutter_compact_formatter.dart b/dev/bots/flutter_compact_formatter.dart index 5afc14c..5462808 100644 --- a/dev/bots/flutter_compact_formatter.dart +++ b/dev/bots/flutter_compact_formatter.dart
@@ -1,4 +1,4 @@ -// Copyright 2019 The Flutter Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index 9dc33ca..7b85d32 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart index f240a5c..352865f 100644 --- a/dev/bots/run_command.dart +++ b/dev/bots/run_command.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 3b57a3d..2c4f99a 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart b/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart index 9ae5f93..d15804d 100644 --- a/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart +++ b/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart
@@ -1,4 +1,4 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/analyze-sample-code_test.dart b/dev/bots/test/analyze-sample-code_test.dart index 8b6d5b9..1e18691 100644 --- a/dev/bots/test/analyze-sample-code_test.dart +++ b/dev/bots/test/analyze-sample-code_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart b/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart index 796ed45..aad90fb 100644 --- a/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart +++ b/dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/analyze_test.dart b/dev/bots/test/analyze_test.dart index 865169d..4eb0bf9 100644 --- a/dev/bots/test/analyze_test.dart +++ b/dev/bots/test/analyze_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -58,13 +58,23 @@ test('analyze.dart - verifyNoMissingLicense', () async { final String result = await capture(() => verifyNoMissingLicense(path.join('test', 'analyze-test-input', 'root')), exitCode: 1); - expect(result, ''' -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -License headers cannot be found at the beginning of the following file. - -test/analyze-test-input/root/packages/foo/foo.dart -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -'''.replaceAll('/', Platform.isWindows ? '\\' : '/')); + expect(result, + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' + + + ( + 'The following 1 file does not have the right license header:\n' + '\n' + 'test/analyze-test-input/root/packages/foo/foo.dart\n' + .replaceAll('/', Platform.isWindows ? '\\' : '/') + ) + + + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' + '\n' + 'The expected license header is:\n' + '// Copyright 2014 The Flutter Authors. All rights reserved.\n' + '// Use of this source code is governed by a BSD-style license that can be\n' + '// found in the LICENSE file.\n' + '...followed by a blank line.\n' + ); }); }
diff --git a/dev/bots/test/bot_test.dart b/dev/bots/test/bot_test.dart index 975df9e..d47d91f 100644 --- a/dev/bots/test/bot_test.dart +++ b/dev/bots/test/bot_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/common.dart b/dev/bots/test/common.dart index d6e0e1f..4060c06 100644 --- a/dev/bots/test/common.dart +++ b/dev/bots/test/common.dart
@@ -1,4 +1,4 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/fake_process_manager.dart b/dev/bots/test/fake_process_manager.dart index 29f3cda..2baf6ee 100644 --- a/dev/bots/test/fake_process_manager.dart +++ b/dev/bots/test/fake_process_manager.dart
@@ -1,4 +1,4 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/fake_process_manager_test.dart b/dev/bots/test/fake_process_manager_test.dart index 5447214..b74576c 100644 --- a/dev/bots/test/fake_process_manager_test.dart +++ b/dev/bots/test/fake_process_manager_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index 78a5cc6..21dadad 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/sdk_directory_has_space_test.dart b/dev/bots/test/sdk_directory_has_space_test.dart index a80cda5..eeca11d 100644 --- a/dev/bots/test/sdk_directory_has_space_test.dart +++ b/dev/bots/test/sdk_directory_has_space_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/test/test_test.dart b/dev/bots/test/test_test.dart index 31df83f..ce2e3fb 100644 --- a/dev/bots/test/test_test.dart +++ b/dev/bots/test/test_test.dart
@@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/dev/bots/unpublish_package.dart b/dev/bots/unpublish_package.dart index 518919f..c0f779e 100644 --- a/dev/bots/unpublish_package.dart +++ b/dev/bots/unpublish_package.dart
@@ -1,4 +1,4 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. +// Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.