diff --git a/build.gradle b/build.gradle index 5c1d844b3..ebebc3172 100644 --- a/build.gradle +++ b/build.gradle @@ -108,6 +108,11 @@ allprojects { } } +task licenseCheck(type: Exec) { + executable '/usr/bin/python' + args('config/check_license.py') +} + subprojects { // Skip no-op project if (project.name == 'services') return @@ -164,6 +169,8 @@ subprojects { if (project.name == 'third_party') return + project.tasks.test.dependsOn licenseCheck + // Path to code generated with annotation processors. Note that this path is // chosen by the 'net.ltgt.apt' plugin, and may change if IDE-specific plugins // are applied, e.g., 'idea' or 'eclipse' diff --git a/config/check_license.py b/config/check_license.py new file mode 100644 index 000000000..1c5f68f6d --- /dev/null +++ b/config/check_license.py @@ -0,0 +1,47 @@ +# Copyright 2019 The Nomulus Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys +import re + +license = r".*Copyright \d{4} The Nomulus Authors\. All Rights Reserved\." +extensions = ("java", "js", "soy", "sql", "py", "sh") +non_included_patterns = {".git", "/build/", "/generated/", "node_modules/", "JUnitBackports.java", } + +def should_include_path(path): + for pattern in non_included_patterns: + if pattern in path: return False + return path.endswith(extensions) + +def get_files(): + result = [] + for root, dirnames, filenames in os.walk("."): + paths = [os.path.join(root, filename) for filename in filenames] + result.extend(filter(should_include_path, paths)) + return result + +if __name__ == "__main__": + all_files = get_files() + failed_files = [] + + for file in all_files: + with open(file, 'r') as f: + file_content = f.read() + if not re.match(license, file_content, re.DOTALL): + failed_files.append(file) + + if failed_files: + print("The following files did not match the license header: " + str(failed_files)) + sys.exit(1) diff --git a/core/src/main/java/google/registry/flows/FlowMetadata.java b/core/src/main/java/google/registry/flows/FlowMetadata.java index c2641bc06..c5d37100f 100644 --- a/core/src/main/java/google/registry/flows/FlowMetadata.java +++ b/core/src/main/java/google/registry/flows/FlowMetadata.java @@ -1,11 +1,11 @@ // Copyright 2017 The Nomulus Authors. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java index b0e15c5f9..4c617279d 100644 --- a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java +++ b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java @@ -1,4 +1,4 @@ - // Copyright 2017 The Nomulus Authors. All Rights Reserved. +// Copyright 2017 The Nomulus Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/karma.conf.js b/karma.conf.js index bd00ebb3d..34da248ec 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,3 +1,17 @@ +// Copyright 2019 The Nomulus Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + process.env.CHROME_BIN = require('puppeteer').executablePath() module.exports = function(config) {