diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 448ae55c27..84cf80ce25 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -30,6 +30,7 @@ Future main(List args) async { print('The analyze.dart script must be run with --enable-asserts.'); exit(1); } + await _verifyNoMissingLicense(flutterRoot); await _verifyNoTestImports(flutterRoot); await _verifyNoTestPackageImports(flutterRoot); await _verifyGeneratedPluginRegistrants(flutterRoot); @@ -472,6 +473,30 @@ Future _verifyNoBadImportsInFlutterTools(String workingDirectory) async { } } +Future _verifyNoMissingLicense(String workingDirectory) async { + final List errors = []; + for (FileSystemEntity entity in Directory(path.join(workingDirectory, 'packages')) + .listSync(recursive: true) + .where((FileSystemEntity entity) => entity is File && path.extension(entity.path) == '.dart')) { + final File file = entity; + bool hasLicense = false; + final List lines = file.readAsLinesSync(); + if (lines.isNotEmpty) + hasLicense = lines.first.startsWith(RegExp(r'// Copyright \d{4}')); + if (!hasLicense) + 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'); + print(errors.join('\n')); + print('$redLine\n'); + exit(1); + } +} + final RegExp _testImportPattern = RegExp(r'''import (['"])([^'"]+_test\.dart)\1'''); const Set _exemptTestImports = { 'package:flutter_test/flutter_test.dart', diff --git a/packages/flutter/lib/src/animation/tween_sequence.dart b/packages/flutter/lib/src/animation/tween_sequence.dart index 79ed0eb2ac..fa13a03c2c 100644 --- a/packages/flutter/lib/src/animation/tween_sequence.dart +++ b/packages/flutter/lib/src/animation/tween_sequence.dart @@ -1,3 +1,7 @@ +// 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. + import 'package:flutter/foundation.dart'; import 'animation.dart'; diff --git a/packages/flutter/lib/src/widgets/scroll_configuration.dart b/packages/flutter/lib/src/widgets/scroll_configuration.dart index d55fd889d2..43693e3240 100644 --- a/packages/flutter/lib/src/widgets/scroll_configuration.dart +++ b/packages/flutter/lib/src/widgets/scroll_configuration.dart @@ -1,4 +1,4 @@ -/// Copyright 2016 The Chromium Authors. All rights reserved. +// Copyright 2016 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. diff --git a/packages/flutter/test/material/mergeable_material_test.dart b/packages/flutter/test/material/mergeable_material_test.dart index b36622d494..30d6c4696a 100644 --- a/packages/flutter/test/material/mergeable_material_test.dart +++ b/packages/flutter/test/material/mergeable_material_test.dart @@ -1,4 +1,4 @@ - // Copyright 2016 The Chromium Authors. All rights reserved. +// Copyright 2016 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. diff --git a/packages/flutter/test/material/raw_material_button_test.dart b/packages/flutter/test/material/raw_material_button_test.dart index a38705f740..29ef186919 100644 --- a/packages/flutter/test/material/raw_material_button_test.dart +++ b/packages/flutter/test/material/raw_material_button_test.dart @@ -1,3 +1,7 @@ +// 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. + import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index b1bea3ad9e..edeaaa9663 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -1,9 +1,9 @@ -import 'dart:ui'; - // Copyright 2015 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. +import 'dart:ui'; + import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/gestures.dart'; diff --git a/packages/flutter/test/rendering/editable_test.dart b/packages/flutter/test/rendering/editable_test.dart index da2ac53c9c..235805afa1 100644 --- a/packages/flutter/test/rendering/editable_test.dart +++ b/packages/flutter/test/rendering/editable_test.dart @@ -1,4 +1,4 @@ - // Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2017 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. diff --git a/packages/flutter/test/widgets/app_test.dart b/packages/flutter/test/widgets/app_test.dart index 08a7410d58..03c337da09 100644 --- a/packages/flutter/test/widgets/app_test.dart +++ b/packages/flutter/test/widgets/app_test.dart @@ -1,3 +1,7 @@ +// 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. + import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/async_lifecycle_test.dart b/packages/flutter/test/widgets/async_lifecycle_test.dart index 16d5528567..eb9d33b1e4 100644 --- a/packages/flutter/test/widgets/async_lifecycle_test.dart +++ b/packages/flutter/test/widgets/async_lifecycle_test.dart @@ -1,3 +1,7 @@ +// 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. + import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/inherited_model.dart b/packages/flutter/test/widgets/inherited_model.dart deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index 15423b2c75..440d25cff5 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -1,3 +1,7 @@ +// 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. + import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter/test/widgets/sliver_constraints_test.dart b/packages/flutter/test/widgets/sliver_constraints_test.dart index f1f0efcc1b..972ace5d7e 100644 --- a/packages/flutter/test/widgets/sliver_constraints_test.dart +++ b/packages/flutter/test/widgets/sliver_constraints_test.dart @@ -1,3 +1,7 @@ +// Copyright 2019 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. + import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter/test/widgets/test_border.dart b/packages/flutter/test/widgets/test_border.dart index 1f3c155ea5..2396cfce81 100644 --- a/packages/flutter/test/widgets/test_border.dart +++ b/packages/flutter/test/widgets/test_border.dart @@ -1,3 +1,7 @@ +// Copyright 2019 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. + import 'package:flutter/material.dart'; typedef Logger = void Function(String caller); diff --git a/packages/flutter_tools/lib/src/base/user_messages.dart b/packages/flutter_tools/lib/src/base/user_messages.dart index 230e7e4e08..b1778e489a 100644 --- a/packages/flutter_tools/lib/src/base/user_messages.dart +++ b/packages/flutter_tools/lib/src/base/user_messages.dart @@ -1,3 +1,7 @@ +// 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. + import 'context.dart'; UserMessages get userMessages => context[UserMessages]; diff --git a/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart b/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart index cb951ca8fb..053de6042d 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart @@ -1,4 +1,4 @@ -// Copyright 201 The Chromium Authors. All rights reserved. +// Copyright 2019 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. diff --git a/packages/flutter_tools/test/ios/simulators_test.dart b/packages/flutter_tools/test/ios/simulators_test.dart index 24507b5bd2..dcadc72682 100644 --- a/packages/flutter_tools/test/ios/simulators_test.dart +++ b/packages/flutter_tools/test/ios/simulators_test.dart @@ -1,3 +1,7 @@ +// Copyright 2017 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. + import 'dart:async'; import 'dart:io' show ProcessResult, Process; diff --git a/packages/flutter_tools/test/protocol_discovery_test.dart b/packages/flutter_tools/test/protocol_discovery_test.dart index 4c71291f15..aaeadf808a 100644 --- a/packages/flutter_tools/test/protocol_discovery_test.dart +++ b/packages/flutter_tools/test/protocol_discovery_test.dart @@ -1,4 +1,3 @@ - // Copyright 2016 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. diff --git a/packages/flutter_tools/test/src/pubspec_schema.dart b/packages/flutter_tools/test/src/pubspec_schema.dart index e0918bd43b..71bbeb11af 100644 --- a/packages/flutter_tools/test/src/pubspec_schema.dart +++ b/packages/flutter_tools/test/src/pubspec_schema.dart @@ -1,3 +1,7 @@ +// 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. + import 'package:file/file.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/flutter_manifest.dart';