Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ matrix:
- sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools -y
- pip3 install wheel # install wheel first explicitly
- pip3 install pyyaml
install: true
script: MAVEN_OPTS='-Xmx3000m' mvn -DskipTests -Dforbiddenapis.skip=true -Dcheckstyle.skip=true -Dpmd.skip=true -Dmaven.javadoc.skip=true -pl '!benchmarks' -B --fail-at-end clean install -Pdist -Pbundle-contrib-exts
install: MAVEN_OPTS='-Xmx3000m' mvn install -q -ff -DskipTests -B
script: ./build.sh

# processing module test
- env:
Expand Down
27 changes: 27 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -e
# 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.

MAVEN_OPTS='-Xmx3000m'

mkdir -p target

# Generate dependency reports and checks they are valid.
docs/_bin/generate-license-dependency-reports.py . target --clean-maven-artifact-transfer

docs/_bin/generate-license.py licenses/APACHE2 licenses.yaml LICENSES.BINARY --dependency-reports target/license-reports

# Build binary distribution. Note that the below command internally runs 'docs/_bin/generate-license.py' without license check which overwrites LICENSES.BINARY file generated by the above command. This must be fine since both commands are supposed to generate the same contents.
mvn -DskipTests -Dforbiddenapis.skip=true -Dcheckstyle.skip=true -Dpmd.skip=true -Dmaven.javadoc.skip=true -pl '!benchmarks' -B --fail-at-end install -Pdist -Pbundle-contrib-exts
18 changes: 1 addition & 17 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,7 @@
</configuration>
</execution>
<execution>
<id>generate-dependency-reports</id>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.parent.basedir}/docs/_bin/generate-license-dependency-reports.py</executable>
<arguments>
<argument>${project.basedir}/../</argument>
<argument>${project.basedir}/target</argument>
<argument>--clean-maven-artifact-transfer</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>verify-and-generate-license</id>
<id>generate-license</id>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
Expand All @@ -156,7 +141,6 @@
<arguments>
<argument>${project.basedir}/../licenses/APACHE2</argument>
<argument>${project.basedir}/../licenses.yaml</argument>
<argument>${project.basedir}/target/license-reports</argument>
<argument>${project.basedir}/../LICENSE.BINARY</argument>
</arguments>
</configuration>
Expand Down
35 changes: 22 additions & 13 deletions docs/_bin/generate-license.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import sys
from html.parser import HTMLParser
import argparse


class DependencyReportParser(HTMLParser):
Expand Down Expand Up @@ -544,16 +545,24 @@ def generate_license(apache_license_v2, license_yaml):
print_outfile("")


# TODO: add options: debug mode
if len(sys.argv) != 5:
sys.stderr.write("usage: {} <path to apache license file> <path to license.yaml> <root to maven dependency reports> <path to output file>".format(sys.argv[0]))
sys.exit(1)

with open(sys.argv[1]) as apache_license_file:
apache_license_v2 = apache_license_file.read()
license_yaml = sys.argv[2]
dependency_reports_root = sys.argv[3]

with open(sys.argv[4], "w") as outfile:
check_licenses(license_yaml, dependency_reports_root)
generate_license(apache_license_v2, license_yaml)
if __name__ == "__main__":
try:
parser = argparse.ArgumentParser(description='Check and generate license file.')
parser.add_argument('apache_license', metavar='<path to apache license file>', type=str)
parser.add_argument('license_yaml', metavar='<path to license.yaml>', type=str)
parser.add_argument('out_path', metavar='<path to output file>', type=str)
parser.add_argument('--dependency-reports', dest='dependency_reports_root', type=str, default=None, metavar='<root to maven dependency reports>')
args = parser.parse_args()

with open(args.apache_license) as apache_license_file:
apache_license_v2 = apache_license_file.read()
license_yaml = args.license_yaml
dependency_reports_root = args.dependency_reports_root

with open(args.out_path, "w") as outfile:
if dependency_reports_root is not None:
check_licenses(license_yaml, dependency_reports_root)
generate_license(apache_license_v2, license_yaml)

except KeyboardInterrupt:
print('Interrupted, closing.')