zentol commented on a change in pull request #14296: URL: https://github.com/apache/flink/pull/14296#discussion_r535024954
########## File path: tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/licensecheck/JarFileChecker.java ########## @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.flink.tools.ci.licensecheck; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * Checks the Jar files created by the build process + */ +public class JarFileChecker { + private static final Logger LOG = LoggerFactory.getLogger(JarFileChecker.class); + + public int run(Path path) throws IOException { + List<Path> files = getBuildJars(path); + + LOG.info("considering jar files " + files); + + int severeIssues = 0; + for (Path file: files) { + severeIssues += checkJar(file); + } + + return severeIssues; + } + + private int checkJar(Path file) throws IOException { + int severeIssues = 0; + boolean metaInfNoticeSeen = false; + boolean metaInfLicenseSeen = false; + + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file.toFile()))) { + ZipEntry ze; + while ((ze = zis.getNextEntry()) != null) { + if (ze.getName().equals("LICENSE")) { + LOG.error("Jar file {} contains a LICENSE file in the root folder", file); + severeIssues++; + } + if (ze.getName().equals("META-INF/NOTICE")) { + metaInfNoticeSeen = true; + } + if (ze.getName().equals("META-INF/LICENSE")) { Review comment: we should also reject META-INF/LICENSE.txt ########## File path: tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/licensecheck/JarFileChecker.java ########## @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.flink.tools.ci.licensecheck; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * Checks the Jar files created by the build process + */ +public class JarFileChecker { + private static final Logger LOG = LoggerFactory.getLogger(JarFileChecker.class); + + public int run(Path path) throws IOException { + List<Path> files = getBuildJars(path); + + LOG.info("considering jar files " + files); + + int severeIssues = 0; + for (Path file: files) { + severeIssues += checkJar(file); + } + + return severeIssues; + } + + private int checkJar(Path file) throws IOException { + int severeIssues = 0; + boolean metaInfNoticeSeen = false; + boolean metaInfLicenseSeen = false; + + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file.toFile()))) { + ZipEntry ze; + while ((ze = zis.getNextEntry()) != null) { + if (ze.getName().equals("LICENSE")) { + LOG.error("Jar file {} contains a LICENSE file in the root folder", file); Review comment: Let's explicitly give instructions on what to do here; validate whether the license is required, manually adding it to our licensing setup, and adding an exclusion to the shade plugin. ########## File path: tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/licensecheck/JarFileChecker.java ########## @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.flink.tools.ci.licensecheck; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * Checks the Jar files created by the build process + */ +public class JarFileChecker { + private static final Logger LOG = LoggerFactory.getLogger(JarFileChecker.class); + + public int run(Path path) throws IOException { + List<Path> files = getBuildJars(path); + + LOG.info("considering jar files " + files); + + int severeIssues = 0; + for (Path file: files) { + severeIssues += checkJar(file); + } + + return severeIssues; + } + + private int checkJar(Path file) throws IOException { + int severeIssues = 0; + boolean metaInfNoticeSeen = false; + boolean metaInfLicenseSeen = false; + + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file.toFile()))) { + ZipEntry ze; + while ((ze = zis.getNextEntry()) != null) { + if (ze.getName().equals("LICENSE")) { Review comment: maybe instead check that no root file contains the word "license"? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
