From 2281396c08d748c1cb09c5428e7a6266a818edc9 Mon Sep 17 00:00:00 2001 From: Aldrin Piri Date: Tue, 23 May 2017 12:47:12 -0400 Subject: [PATCH 1/2] MINIFI-177 Incorporating Apache RAT to build with a custom target of apache-rat. Updating non-compliant files and/or listing exclusions in .rat-excludes This commit introduces a separate CMake file to manage the acquisition of the RAT binary. Run RAT as part of Travis builds. --- .gitignore | 19 ++++++++ .travis.yml | 2 +- CMakeLists.txt | 3 ++ cmake/RunApacheRAT.cmake | 44 +++++++++++++++++++ examples/iOSPort/iOSPortREADME.md | 15 +++++++ libminifi/cmake/iOS.cmake | 17 +++++++ libminifi/test/Server.cpp | 18 ++++++++ .../test/resources/TestControllerServices.yml | 18 ++++++++ .../resources/TestProvenanceReporting.yml | 18 ++++++++ thirdparty/apache-rat/.rat-excludes | 8 ++++ 10 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 cmake/RunApacheRAT.cmake create mode 100644 thirdparty/apache-rat/.rat-excludes diff --git a/.gitignore b/.gitignore index 990e6c4736..4a4c064a27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,21 @@ +# 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. +# + # Standard ignores .DS_Store @@ -28,6 +46,7 @@ thirdparty/**/*.o thirdparty/**/*.a libminifi/test/**/*.a docs/generated +thirdparty/apache-rat/apache-rat* # Ignore source files that have been placed in the docker directory during build docker/minificppsource diff --git a/.travis.yml b/.travis.yml index 61cbbeef09..b74f40dd05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,4 +63,4 @@ matrix: - package='graphviz'; [[ $(brew ls --versions ${package}) ]] && { brew outdated ${package} || brew upgrade ${package}; } || brew install ${package} script: - - mkdir ./build && cd ./build && cmake .. && make VERBOSE=1 && make test ARGS="--output-on-failure" && make linter && make docs + - mkdir ./build && cd ./build && cmake .. && make VERBOSE=1 && make test ARGS="--output-on-failure" && make linter && make apache-rat && make docs diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c65d146f8..ee2e83369d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,8 +148,11 @@ include(BuildTests) include(BuildDocs) +include(RunApacheRAT) + include(DockerConfig) + # Create a custom build target that will run the linter. add_custom_target( linter diff --git a/cmake/RunApacheRAT.cmake b/cmake/RunApacheRAT.cmake new file mode 100644 index 0000000000..7fd512c44d --- /dev/null +++ b/cmake/RunApacheRAT.cmake @@ -0,0 +1,44 @@ +# 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. + +# Find the preferred Apache mirror to use for the download by querying the list of mirrors and filtering out 'preferred' +execute_process(COMMAND curl -s https://www.apache.org/dyn/closer.lua/?asjson=1 + COMMAND grep preferred + COMMAND awk "{print $2}" + COMMAND tr -d "\"" + TIMEOUT 10 + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE MIRROR_URL ) + +ExternalProject_Add( + rat-binary + PREFIX "apache-rat" + URL "${MIRROR_URL}creadur/apache-rat-0.12/apache-rat-0.12-bin.tar.gz" + URL_HASH SHA1=e84dffe8b354871c29f5078b823a726508474a6c + DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/thirdparty/apache-rat + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) + +# Custom target to run Apache Release Audit Tool (RAT) +add_custom_target( + apache-rat + COMMAND java -jar ${CMAKE_BINARY_DIR}/apache-rat/src/rat-binary/apache-rat-0.12.jar -E ${CMAKE_SOURCE_DIR}/thirdparty/apache-rat/.rat-excludes -d ${CMAKE_SOURCE_DIR} | grep -B 1 -A 15 Summary ) + + +add_dependencies(apache-rat rat-binary) diff --git a/examples/iOSPort/iOSPortREADME.md b/examples/iOSPort/iOSPortREADME.md index 3631b05941..11e5005ea0 100644 --- a/examples/iOSPort/iOSPortREADME.md +++ b/examples/iOSPort/iOSPortREADME.md @@ -1,3 +1,18 @@ + + 1) Install XCode 2) Build libminfi.a cd libminifi, mkdir lib, cd lib diff --git a/libminifi/cmake/iOS.cmake b/libminifi/cmake/iOS.cmake index 57b82f9063..87148f71a1 100644 --- a/libminifi/cmake/iOS.cmake +++ b/libminifi/cmake/iOS.cmake @@ -1,3 +1,20 @@ +# 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. + # This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake # files which are included with CMake 2.8.4 # It has been altered for iOS development diff --git a/libminifi/test/Server.cpp b/libminifi/test/Server.cpp index 875e7a9e96..bb3e6829b1 100644 --- a/libminifi/test/Server.cpp +++ b/libminifi/test/Server.cpp @@ -1,3 +1,21 @@ +/** + * + * 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. + */ + /* A simple server in the internet domain using TCP The port number is passed as an argument */ #include diff --git a/libminifi/test/resources/TestControllerServices.yml b/libminifi/test/resources/TestControllerServices.yml index 3923c87aa7..d2d2a5a6ad 100644 --- a/libminifi/test/resources/TestControllerServices.yml +++ b/libminifi/test/resources/TestControllerServices.yml @@ -1,3 +1,21 @@ +# +# 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. +# Flow Controller: name: MiNiFi Flow id: 2438e3c8-015a-1000-79ca-83af40ec1990 diff --git a/libminifi/test/resources/TestProvenanceReporting.yml b/libminifi/test/resources/TestProvenanceReporting.yml index 5b906a5262..375a4a942f 100644 --- a/libminifi/test/resources/TestProvenanceReporting.yml +++ b/libminifi/test/resources/TestProvenanceReporting.yml @@ -1,3 +1,21 @@ +# +# 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. +# Flow Controller: name: MiNiFi Flow id: 2438e3c8-015a-1000-79ca-83af40ec1990 diff --git a/thirdparty/apache-rat/.rat-excludes b/thirdparty/apache-rat/.rat-excludes new file mode 100644 index 0000000000..ccd4a6ac48 --- /dev/null +++ b/thirdparty/apache-rat/.rat-excludes @@ -0,0 +1,8 @@ +thirdparty +generated +build +spdlog +cmake-build-debug +.gitignore +CPPLINT.cfg +cn.pass \ No newline at end of file From e358737a76279d381cffca91cdfd24615c862eac Mon Sep 17 00:00:00 2001 From: Aldrin Piri Date: Thu, 1 Jun 2017 10:54:33 -0400 Subject: [PATCH 2/2] Updating build to only check for and download binary RAT artifact when apache-rat target is invoked. Make use of SHA512 instead of SHA1 --- CMakeLists.txt | 11 +++++++---- cmake/RunApacheRAT.cmake | 35 +++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee2e83369d..fdae7ea502 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,13 +148,16 @@ include(BuildTests) include(BuildDocs) -include(RunApacheRAT) - include(DockerConfig) - # Create a custom build target that will run the linter. add_custom_target( linter COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.sh ${CMAKE_SOURCE_DIR}/libminifi/include/ ${CMAKE_SOURCE_DIR}/libminifi/src/ - COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.sh ${CMAKE_SOURCE_DIR}/libminifi/include/ ${CMAKE_SOURCE_DIR}/libminifi/test/ ) \ No newline at end of file + COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.sh ${CMAKE_SOURCE_DIR}/libminifi/include/ ${CMAKE_SOURCE_DIR}/libminifi/test/ ) + +# Custom target to download and run Apache Release Audit Tool (RAT) +add_custom_target( + apache-rat + ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/RunApacheRAT.cmake + COMMAND java -jar ${CMAKE_SOURCE_DIR}/thirdparty/apache-rat/apache-rat-0.12/apache-rat-0.12.jar -E ${CMAKE_SOURCE_DIR}/thirdparty/apache-rat/.rat-excludes -d ${CMAKE_SOURCE_DIR} | grep -B 1 -A 15 Summary ) diff --git a/cmake/RunApacheRAT.cmake b/cmake/RunApacheRAT.cmake index 7fd512c44d..76e329ba43 100644 --- a/cmake/RunApacheRAT.cmake +++ b/cmake/RunApacheRAT.cmake @@ -15,6 +15,8 @@ # specific language governing permissions and limitations # under the License. +# This file is invoked in CMake script mode from the source root of the overall project + # Find the preferred Apache mirror to use for the download by querying the list of mirrors and filtering out 'preferred' execute_process(COMMAND curl -s https://www.apache.org/dyn/closer.lua/?asjson=1 COMMAND grep preferred @@ -24,21 +26,22 @@ execute_process(COMMAND curl -s https://www.apache.org/dyn/closer.lua/?asjson=1 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE MIRROR_URL ) -ExternalProject_Add( - rat-binary - PREFIX "apache-rat" - URL "${MIRROR_URL}creadur/apache-rat-0.12/apache-rat-0.12-bin.tar.gz" - URL_HASH SHA1=e84dffe8b354871c29f5078b823a726508474a6c - DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/thirdparty/apache-rat - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) - -# Custom target to run Apache Release Audit Tool (RAT) -add_custom_target( - apache-rat - COMMAND java -jar ${CMAKE_BINARY_DIR}/apache-rat/src/rat-binary/apache-rat-0.12.jar -E ${CMAKE_SOURCE_DIR}/thirdparty/apache-rat/.rat-excludes -d ${CMAKE_SOURCE_DIR} | grep -B 1 -A 15 Summary ) +# Make use of parent thirdparty by adjusting relative to the source of this CMake file +set(PARENT_THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/../thirdparty") +set(RAT_BASENAME "apache-rat-0.12") +set(RAT_DIR "${PARENT_THIRDPARTY_DIR}/apache-rat") +set(RAT_BINARY "${RAT_DIR}/${RAT_BASENAME}-bin/${RAT_BASENAME}.jar") +file(DOWNLOAD + "${MIRROR_URL}creadur/${RAT_BASENAME}/${RAT_BASENAME}-bin.tar.gz" + "${RAT_DIR}/${RAT_BASENAME}-bin.tar.gz" + EXPECTED_HASH SHA512=460d53fa3e1546d960bd03ebd97c930a39306cffd98c9ebc09bf22f9e50a9723578b98c4e7dc71dd6f19dfb6dae00811cb11a4eabce70c21502a6cef2d9fd2fa ) -add_dependencies(apache-rat rat-binary) +execute_process( + COMMAND tar xf "${RAT_DIR}/${RAT_BASENAME}-bin.tar.gz" -C "${RAT_DIR}" + COMMAND grep preferred + COMMAND awk "{print $2}" + COMMAND tr -d "\"" + TIMEOUT 10 + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE MIRROR_URL ) \ No newline at end of file