You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2017/01/04 22:51:28 UTC
[08/10] asterixdb git commit: ASTERIXDB-1720 - Generate License /
Notice Files
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-installer/src/main/licenses/NOTICE
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-installer/src/main/licenses/NOTICE b/asterixdb/asterix-installer/src/main/licenses/NOTICE
deleted file mode 100644
index a047a44..0000000
--- a/asterixdb/asterix-installer/src/main/licenses/NOTICE
+++ /dev/null
@@ -1,722 +0,0 @@
-Apache AsterixDB Managix Installer
-Copyright 2016 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-AsterixDB utilizes many libraries, which come with the following applicable NOTICE(s):
-
- - repo/avro-1.7.4.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache Avro
- Copyright 2009-2013 The Apache Software Foundation
-
- - repo/commons-logging-1.1.1.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Commons Logging
- Copyright 2001-2007 The Apache Software Foundation
-
- - repo/derby-10.10.1.1.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache Derby
- Copyright 2004-2013 The Apache Software Foundation
-
- =========================================================================
-
- Portions of Derby were originally developed by
- International Business Machines Corporation and are
- licensed to the Apache Software Foundation under the
- "Software Grant and Corporate Contribution License Agreement",
- informally known as the "Derby CLA".
- The following copyright notice(s) were affixed to portions of the code
- with which this file is now or was at one time distributed
- and are placed here unaltered.
-
- (C) Copyright 1997,2004 International Business Machines Corporation. All rights reserved.
-
- (C) Copyright IBM Corp. 2003.
-
-
- =========================================================================
-
-
- The JDBC apis for small devices and JDBC3 (under java/stubs/jsr169 and
- java/stubs/jdbc3) were produced by trimming sources supplied by the
- Apache Harmony project. In addition, the Harmony SerialBlob and
- SerialClob implementations are used. The following notice covers the Harmony sources:
-
- Portions of Harmony were originally developed by
- Intel Corporation and are licensed to the Apache Software
- Foundation under the "Software Grant and Corporate Contribution
- License Agreement", informally known as the "Intel Harmony CLA".
-
-
- - repo/guice-3.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Google Guice - Core Library
- Copyright 2006-2011 Google, Inc.
-
- - repo/guice-servlet-3.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Google Guice - Extensions - Servlet
- Copyright 2006-2011 Google, Inc.
-
- - repo/hive-ant-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Ant Utilities
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-common-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Common
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-exec-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Query Language
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-metastore-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Metastore
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-serde-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Serde
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-shims-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Shims
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-shims-0.20-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Shims 0.20
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-shims-0.20S-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Shims 0.20S
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-shims-0.23-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Shims 0.23
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-shims-common-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Shims Common
- Copyright 2014 The Apache Software Foundation
-
- - repo/hive-shims-common-secure-0.13.0.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Hive Shims Secure Common
- Copyright 2014 The Apache Software Foundation
-
- - repo/plexus-utils-3.0.7.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- This product includes software developed by the Indiana University
- Extreme! Lab (http://www.extreme.indiana.edu/)
-
- This product includes software developed by
- ThoughtWorks (http://www.thoughtworks.com).
-
- This product includes software developed by
- javolution (http://javolution.org/).
-
- This product includes software developed by
- Rome (https://rome.dev.java.net/).
-
-- repo/velocity-1.5.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache Velocity
-
- Copyright (C) 2000-2007 The Apache Software Foundation
-
- - repo/wicket-core-1.5.2.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
- Apache Wicket
- Copyright 2006-2011 Apache Software Foundation
-
- This product includes software from QOS.ch (http://slf4j.org) licensed under the X11 license
- Copyright (c) 2004-2008 QOS.ch
-
- Contains Diff library from Mavens JRCS, released under
- The Apache Software License, Version 1.1.
- (c) 1999-2003
-
- org.apache.wicket.markup.html.form.upload.MultiFileUploadField.js is taken from [1]
- and has the following notice:
- "Licence:
- Use this however/wherever you like, just don't blame me if it breaks
- anything.
-
- Credit:
- If you're nice, you'll leave this bit:
-
- Class by Stickman -- http://www.the-stickman.com
- with thanks to:
- [for Safari fixes]
- Luis Torrefranca -- http://www.law.pitt.edu
- and
- Shawn Parker & John Pennypacker -- http://www.fuzzycoconut.com
- [for duplicate name bug]
- 'neal'"
- [1]: http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
- - repo/wicket-request-1.5.2.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Wicket Request
- Copyright 2006-2011 Apache Software Foundation
-
- - repo/wicket-util-1.5.2.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Wicket Util
- Copyright 2006-2011 Apache Software Foundation
-
- - repo/xercesImpl-2.9.1.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache Xerces Java
- Copyright 1999-2007 The Apache Software Foundation
-
- Portions of this software were originally based on the following:
- - software copyright (c) 1999, IBM Corporation., http://www.ibm.com.
- - software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
- - voluntary contributions made by Paul Eng on behalf of the
- Apache Software Foundation that were originally developed at iClick, Inc.,
- software copyright (c) 1999.
-
- - repo/xml-apis-1.3.04.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache XML Commons XML APIs
- Copyright 2006 The Apache Software Foundation.
-
-
- Portions of this software were originally based on the following:
- - software copyright (c) 1999, IBM Corporation., http://www.ibm.com.
- - software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
- - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org
-
- - repo/httpclient-4.2.2.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache HttpComponents HttpClient
- Copyright 1999-2012 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/httpcore-4.2.2.jar in asterix/asterix-server-0.8.8-binary-assembly.zip
-
- Apache HttpComponents HttpCore
- Copyright 2005-2012 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- This project contains annotations derived from JCIP-ANNOTATIONS
- Copyright (c) 2005 Brian Goetz and Tim Peierls. See http://www.jcip.net
-
-- repo/ant-1.9.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Ant
- Copyright 1999-2013 The Apache Software Foundation
-
- The <sync> task is based on code Copyright (c) 2002, Landmark
- Graphics Corp that has been kindly donated to the Apache Software
- Foundation.
- - repo/ant-launcher-1.9.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Ant
- Copyright 1999-2013 The Apache Software Foundation
-
- The <sync> task is based on code Copyright (c) 2002, Landmark
- Graphics Corp that has been kindly donated to the Apache Software
- Foundation.
- - repo/commons-beanutils-1.7.0.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-beanutils-core-1.8.0.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
- Apache Commons BeanUtils
-
- Copyright 2000-2008 The Apache Software Foundation
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-cli-1.2.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
- and .installer/hadoop-0.20.2/lib/commons-cli-1.2.jar
-
- Apache Commons CLI
- Copyright 2001-2009 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-codec-1.4.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Codec
-
- Copyright 2002-2009 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
-
- - repo/commons-collections-3.2.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Collections
-
- Copyright 2001-2008 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-compress-1.4.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Compress
- Copyright 2002-2012 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
- - repo/commons-configuration-1.6.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
- Apache Commons Configuration
-
- Copyright 2001-2008 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-daemon-1.0.13.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Daemon
- Copyright 1999-2013 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
- - repo/commons-digester-1.8.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
- Apache Jakarta Commons Digester
-
- Copyright 2001-2006 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-io-2.4.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
- and lib/commons-io-2.4.jar
-
- Apache Commons IO
-
- Copyright 2002-2012 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
-
-
- - repo/commons-lang-2.5.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Lang
-
- Copyright 2001-2010 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-lang3-3.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Lang
- Copyright 2001-2011 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- This product includes software from the Spring Framework,
- under the Apache License 2.0 (see: StringUtils.containsWhitespace())
-
- - repo/commons-logging-api-1.0.4.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- - .installer/hadoop-0.20.2/lib/commons-logging--1.0.4.jar
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/commons-math-2.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Math
- Copyright 2001-2010 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- ===============================================================================
- The LinearConstraint, LinearObjectiveFunction, LinearOptimizer,
- RelationShip, SimplexSolver and SimplexTableau classes in package
- org.apache.commons.math.optimization.linear include software developed by
- Benjamin McCann (http://www.benmccann.com) and distributed with
- the following copyright: Copyright 2009 Google Inc.
- ===============================================================================
-
- This product includes software developed by the
- University of Chicago, as Operator of Argonne National
- Laboratory.
- The LevenbergMarquardtOptimizer class in package
- org.apache.commons.math.optimization.general includes software
- translated from the lmder, lmpar and qrsolv Fortran routines
- from the Minpack package
- Minpack Copyright Notice (1999) University of Chicago. All rights reserved
- ===============================================================================
-
- The GraggBulirschStoerIntegrator class in package
- org.apache.commons.math.ode.nonstiff includes software translated
- from the odex Fortran routine developed by E. Hairer and G. Wanner.
- Original source copyright:
- Copyright (c) 2004, Ernst Hairer
- ===============================================================================
-
- The EigenDecompositionImpl class in package
- org.apache.commons.math.linear includes software translated
- from some LAPACK Fortran routines. Original source copyright:
- Copyright (c) 1992-2008 The University of Tennessee. All rights reserved.
- ===============================================================================
-
- The MersenneTwister class in package org.apache.commons.math.random
- includes software translated from the 2002-01-26 version of
- the Mersenne-Twister generator written in C by Makoto Matsumoto and Takuji
- Nishimura. Original source copyright:
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
- All rights reserved
- ===============================================================================
-
- The complete text of licenses and disclaimers associated with the the original
- sources enumerated above at the time of code translation are in the LICENSE.txt
- file.
-
- - repo/commons-net-3.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons Net
-
- Copyright 2001-2012 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
-
-
- - repo/datanucleus-api-jdo-3.2.6.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- =========================================================================
- == NOTICE file corresponding to section 4(d) of the Apache License, ==
- == Version 2.0, in this case for the DataNucleus distribution. ==
- =========================================================================
-
- ===================================================================
- This product includes software developed by many individuals,
- including the following:
- ===================================================================
- Erik Bengtson
- Andy Jefferson
-
-
- ===================================================================
- This product has included contributions from some individuals,
- including the following:
- ===================================================================
-
- - repo/datanucleus-core-3.2.10.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- =========================================================================
- == NOTICE file corresponding to section 4(d) of the Apache License, ==
- == Version 2.0, in this case for the DataNucleus distribution. ==
- =========================================================================
-
- ===================================================================
- This product includes software developed by many individuals,
- including the following:
- ===================================================================
- Erik Bengtson
- Andy Jefferson
-
-
- ===================================================================
- This product has included contributions from some individuals,
- including the following:
- ===================================================================
- Joerg von Frantzius
- Thomas Marti
- Barry Haddow
- Marco Schulze
- Ralph Ullrich
- David Ezzio
- Brendan de Beer
- David Eaves
- Martin Taal
- Tony Lai
- Roland Szabo
- Marcus Mennemeier
- Xuan Baldauf
- Eric Sultan
-
-
- ===================================================================
- This product also includes software developed by the TJDO project
- (http://tjdo.sourceforge.net/).
- ===================================================================
-
- - repo/datanucleus-rdbms-3.2.9.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
- =========================================================================
- == NOTICE file corresponding to section 4(d) of the Apache License, ==
- == Version 2.0, in this case for the DataNucleus distribution. ==
- =========================================================================
-
- ===================================================================
- This product includes software developed by many individuals,
- including the following:
- ===================================================================
- Andy Jefferson
- Erik Bengtson
- Joerg von Frantzius
- Marco Schulze
-
-
- ===================================================================
- This product has included contributions from some individuals,
- including the following:
- ===================================================================
- Barry Haddow
- Ralph Ullrich
- David Ezzio
- Brendan de Beer
- David Eaves
- Martin Taal
- Tony Lai
- Roland Szabo
- Anton Troshin (Timesten)
-
-
- ===================================================================
- This product also includes software developed by the TJDO project
- (http://tjdo.sourceforge.net/).
- ===================================================================
-
- ===================================================================
- This product also includes software developed by the Apache Commons project
- (http://commons.apache.org/).
- ===================================================================
-
- - repo/groovy-all-2.1.6.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Commons CLI
- Copyright 2001-2009 The Apache Software Foundation
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/hive-exec-0.13.0.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Thrift
- Copyright 2006-2010 The Apache Software Foundation.
-
- This product includes software developed at
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/httpclient-4.2.2.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache HttpComponents HttpClient
-
- Copyright 1999-2012 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
-
- - repo/httpcore-4.2.2.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache HttpComponents HttpCore
-
- Copyright 2005-2012 The Apache Software Foundation
-
-
-
- This product includes software developed by
-
- The Apache Software Foundation (http://www.apache.org/).
-
-
-
- This project contains annotations derived from JCIP-ANNOTATIONS
-
- Copyright (c) 2005 Brian Goetz and Tim Peierls. See http://www.jcip.net
-
- - repo/jdo2-api-2.3-20090302111651.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Java Data Objects (JDO)
- Copyright 2005-2006 The Apache Software Foundation
-
- This product includes software developed at
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/jdo-api-3.0.1.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Java Data Objects (JDO)
-
- Copyright 2005-2006 The Apache Software Foundation
-
-
-
- This product includes software developed at
-
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/libthrift-0.9.0.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- Apache Thrift
- Copyright 2006-2010 The Apache Software Foundation.
-
- This product includes software developed at
- The Apache Software Foundation (http://www.apache.org/).
-
- - repo/netty-3.2.2.Final.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- The Netty Project
- =================
-
- Please visit the Netty web site for more information:
-
- * http://www.jboss.org/netty/
-
- Copyright 2009 Red Hat, Inc.
-
- Red Hat licenses this product to you under the Apache License, version 2.0 (the
- "License"); you may not use this product 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.
-
- Also, please refer to each LICENSE.<component>.txt file, which is located in
- the 'license' directory of the distribution file, for the license terms of the
- components that this product depends on.
-
- -------------------------------------------------------------------------------
- This product contains the extensions to Java Collections Framework which has
- been derived from the works by JSR-166 EG, Doug Lea, and Jason T. Greene:
-
- * LICENSE:
- * license/LICENSE.jsr177y.txt (Public Domain)
- * HOMEPAGE:
- * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/
- * http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbosscache/experimental/jsr166/
-
- This product contains a modified version of Robert Harder's Public Domain
- Base64 Encoder and Decoder, which can be obtained at:
-
- * LICENSE:
- * license/LICENSE.base64.txt (Public Domain)
- * HOMEPAGE:
- * http://iharder.sourceforge.net/current/java/base64/
-
- This product contains a modified version of 'JZlib', a re-implementation of
- zlib in pure Java, which can be obtained at:
-
- * LICENSE:
- * license/LICENSE.jzlib.txt (BSD Style License)
- * HOMEPAGE:
- * http://www.jcraft.com/jzlib/
-
- - repo/netty-3.6.2.Final.jar in asterix/asterix-server-0.8.8-incubating-binary-assembly.zip
-
- The Netty Project
- =================
-
- Please visit the Netty web site for more information:
-
- * http://netty.io/
-
- Copyright 2011 The Netty Project
-
- The Netty Project 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.
-
- Also, please refer to each LICENSE.<component>.txt file, which is located in
- the 'license' directory of the distribution file, for the license terms of the
- components that this product depends on.
-
- -------------------------------------------------------------------------------
- This product contains the extensions to Java Collections Framework which has
- been derived from the works by JSR-166 EG, Doug Lea, and Jason T. Greene:
-
- * LICENSE:
- * license/LICENSE.jsr166y.txt (Public Domain)
- * HOMEPAGE:
- * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/
- * http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbosscache/experimental/jsr166/
-
- This product contains a modified version of Robert Harder's Public Domain
- Base64 Encoder and Decoder, which can be obtained at:
-
- * LICENSE:
- * license/LICENSE.base64.txt (Public Domain)
- * HOMEPAGE:
- * http://iharder.sourceforge.net/current/java/base64/
-
- This product contains a modified version of 'JZlib', a re-implementation of
- zlib in pure Java, which can be obtained at:
-
- * LICENSE:
- * license/LICENSE.jzlib.txt (BSD Style License)
- * HOMEPAGE:
- * http://www.jcraft.com/jzlib/
-
-- lib/log4j-1.2.15.jar
-
- Apache log4j
- Copyright 2007 The Apache Software Foundation
-
- This product includes software developed at
- The Apache Software Foundation (http://www.apache.org/).
-
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/pom.xml b/asterixdb/asterix-maven-plugins/license-automation-plugin/pom.xml
new file mode 100644
index 0000000..df701d9
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ! 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.
+ !-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.asterix</groupId>
+ <artifactId>asterix-maven-plugins</artifactId>
+ <version>0.8.9-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>maven-plugin</packaging>
+
+ <artifactId>license-automation-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.8.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.23</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DependencySet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DependencySet.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DependencySet.java
new file mode 100644
index 0000000..64e5f7d
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DependencySet.java
@@ -0,0 +1,45 @@
+/*
+ * 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.asterix.license;
+
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class DependencySet {
+
+ @SuppressWarnings("unused") // set by Maven configuration
+ private String location;
+
+ @SuppressWarnings({"unused", "MismatchedQueryAndUpdateOfCollection"}) // set by Maven configuration
+ private List<String> includes;
+
+ private List<Pattern> patterns;
+
+ public String getLocation() {
+ return location;
+ }
+
+ public List<Pattern> getPatterns() {
+ if (patterns == null) {
+ patterns = includes.stream().map(LicenseMojo::compileGAWildcardPattern).collect(Collectors.toList());
+ }
+ return patterns;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DownloadLicensesMojo.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DownloadLicensesMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DownloadLicensesMojo.java
new file mode 100644
index 0000000..cb9f172
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/DownloadLicensesMojo.java
@@ -0,0 +1,89 @@
+/*
+ * 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.asterix.license;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.ProjectBuildingException;
+
+@Mojo(name = "licensedownload",
+ requiresProject = true,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
+public class DownloadLicensesMojo extends LicenseMojo {
+
+ @Parameter(required = true)
+ private File downloadDir;
+
+ @Parameter(defaultValue = "30")
+ private int timeoutSecs;
+
+ @java.lang.Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ init();
+ addDependenciesToLicenseMap();
+ final int timeoutMillis = (int) TimeUnit.SECONDS.toMillis(timeoutSecs);
+ //noinspection ResultOfMethodCallIgnored
+ downloadDir.mkdirs();
+ AtomicInteger counter = new AtomicInteger();
+ getLicenseMap().values().parallelStream().forEach(entry -> {
+ final int i = counter.incrementAndGet();
+ final String url = entry.getLicense().getUrl();
+ String fileName = entry.getLicense().getContentFile(false);
+ doDownload(timeoutMillis, i, url, fileName);
+ });
+ } catch (IOException | ProjectBuildingException e) {
+ throw new MojoExecutionException("Unexpected exception: " + e, e);
+ }
+ }
+
+ private void doDownload(int timeoutMillis, int id, String url, String fileName) {
+ try {
+ HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
+ conn.setConnectTimeout(timeoutMillis);
+ conn.setReadTimeout(timeoutMillis);
+ conn.setRequestMethod("GET");
+ final File outFile = new File(downloadDir, fileName);
+ getLog().info("[" + id + "] " + url + " -> " + outFile);
+ final InputStream is = conn.getInputStream();
+ FileWriter writer = new FileWriter(outFile);
+ IOUtils.copy(is, writer, conn.getContentEncoding());
+ writer.close();
+ getLog().info("[" + id + "] ...done!");
+ } catch (IOException e) {
+ getLog().warn("[" + id + "] ...error downloading " + url + ": " + e);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java
new file mode 100644
index 0000000..3b3e190
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java
@@ -0,0 +1,42 @@
+/*
+ * 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.asterix.license;
+
+import java.io.File;
+
+public class ExtraLicenseFile {
+ private File file;
+ private String location;
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
new file mode 100644
index 0000000..894b73d
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
@@ -0,0 +1,335 @@
+/*
+ * 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.asterix.license;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.function.BiConsumer;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Pattern;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SequenceWriter;
+import freemarker.cache.FileTemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import org.apache.asterix.license.freemarker.IndentDirective;
+import org.apache.asterix.license.freemarker.LoadFileDirective;
+import org.apache.asterix.license.project.LicensedProjects;
+import org.apache.asterix.license.project.Project;
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.ProjectBuildingException;
+
+@Mojo(name = "generate",
+ requiresProject = true,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
+public class GenerateFileMojo extends LicenseMojo {
+
+ public static final Pattern FOUNDATION_PATTERN = Pattern.compile("^\\s*This product includes software developed " +
+ "(at|by) The Apache Software Foundation \\(http://www.apache.org/\\).\\s*$".replace(" ", "\\s+"),
+ Pattern.DOTALL | Pattern.MULTILINE);
+
+ public static final Comparator<String> WHITESPACE_NORMALIZED_COMPARATOR =
+ (o1, o2) -> o1.replaceAll("\\s+", " ").compareTo(o2.replaceAll("\\s+", " "));
+
+ @Parameter(required = true)
+ private File templateRootDir;
+
+ @Parameter(defaultValue = "${project.build.directory}/generated-sources")
+ private File outputDir;
+
+ @Parameter
+ private List<GeneratedFile> generatedFiles = new ArrayList<>();
+
+ @Parameter(defaultValue = "${project.build.sourceEncoding}")
+ private String encoding;
+
+ @Parameter
+ private File licenseMapOutputFile;
+
+ @Parameter
+ private List<ExtraLicenseFile> extraLicenseMaps = new ArrayList<>();
+
+ @Parameter
+ protected Map<String, String> templateProperties = new HashMap<>();
+
+ private SortedMap<String, SortedSet<Project>> noticeMap;
+
+ @java.lang.Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ init();
+ readExtraMaps();
+ addDependenciesToLicenseMap();
+ resolveLicenseContent();
+ resolveNoticeFiles();
+ resolveLicenseFiles();
+ rebuildLicenseContentProjectMap();
+ buildNoticeProjectMap();
+ persistLicenseMap();
+ combineCommonGavs();
+ generateFiles();
+ } catch (IOException | TemplateException | ProjectBuildingException e) {
+ throw new MojoExecutionException("Unexpected exception: " + e, e);
+ }
+ }
+
+ private void resolveLicenseContent() throws IOException {
+ for (LicensedProjects licensedProjects : licenseMap.values()) {
+ final LicenseSpec license = licensedProjects.getLicense();
+ if (license.getContent() == null) {
+ getLog().debug("Resolving content for " + license.getUrl() + " (" + license.getContentFile() + ")");
+ File cFile = new File(license.getContentFile());
+ if (!cFile.isAbsolute()) {
+ cFile = new File(licenseDirectory, license.getContentFile());
+ }
+ if (!cFile.exists()) {
+ getLog().warn("MISSING: license content file (" + cFile + ") for url: " + license.getUrl());
+ license.setContent("MISSING: " + license.getContentFile() + " (" + license.getUrl() + ")");
+ } else {
+ StringWriter sw = new StringWriter();
+ LicenseUtil.readAndTrim(sw, cFile);
+ license.setContent(sw.toString());
+ }
+ }
+ }
+ }
+
+ private void combineCommonGavs() {
+ for (LicensedProjects licensedProjects : licenseMap.values()) {
+ Map<String, Project> projectMap = new HashMap<>();
+ for (Iterator<Project> iter = licensedProjects.getProjects().iterator(); iter.hasNext(); ) {
+ Project project = iter.next();
+ if (projectMap.containsKey(project.gav())) {
+ Project first = projectMap.get(project.gav());
+ first.setLocation(first.getLocation() + "," + project.getLocation());
+ iter.remove();
+ } else {
+ projectMap.put(project.gav(), project);
+ }
+ }
+ }
+ }
+
+ private void generateFiles() throws TemplateException, IOException {
+ Map<String, Object> props = getProperties();
+
+ Configuration config = new Configuration();
+ config.setTemplateLoader(new FileTemplateLoader(templateRootDir));
+ for (GeneratedFile generation : generatedFiles) {
+ Template template = config.getTemplate(generation.getTemplate());
+
+ if (template == null) {
+ throw new IOException("Could not load template " + generation.getTemplate());
+ }
+
+ outputDir.mkdirs();
+ final File file = new File(outputDir, generation.getOutputFile());
+ getLog().info("Writing " + file + "...");
+ try (final FileWriter writer = new FileWriter(file)) {
+ template.process(props, writer);
+ }
+ }
+ }
+
+ protected Map<String, Object> getProperties() {
+ Map<String, Object> props = new HashMap<>();
+ props.put("indent", new IndentDirective());
+ props.put("loadfile", new LoadFileDirective());
+ props.put("project", project);
+ props.put("noticeMap", noticeMap.entrySet());
+ props.put("licenseMap", licenseMap.entrySet());
+ props.putAll(templateProperties);
+ return props;
+ }
+
+ private void readExtraMaps() throws IOException {
+ final ObjectMapper objectMapper = new ObjectMapper();
+ for (ExtraLicenseFile extraLicenseFile : extraLicenseMaps) {
+ for (LicensedProjects projects :
+ objectMapper.readValue(extraLicenseFile.getFile(), LicensedProjects[].class)) {
+ LicenseSpec spec = urlToLicenseMap.get(projects.getLicense().getUrl());
+ if (spec != null) {
+ // TODO(mblow): probably we should always favor the extra map...
+ // propagate any license content we may have with what already has been loaded
+ if (projects.getLicense().getContent() != null &&
+ spec.getContent() == null) {
+ spec.setContent(projects.getLicense().getContent());
+ }
+ // propagate any license displayName we may have with what already has been loaded
+ if (projects.getLicense().getDisplayName() != null &&
+ spec.getDisplayName() == null) {
+ spec.setDisplayName(projects.getLicense().getDisplayName());
+ }
+ }
+ for (Project project : projects.getProjects()) {
+ project.setLocation(extraLicenseFile.getLocation());
+ addProject(project, projects.getLicense());
+ }
+ }
+ }
+ }
+
+ private void persistLicenseMap() throws IOException {
+ if (licenseMapOutputFile != null) {
+ licenseMapOutputFile.getParentFile().mkdirs();
+ SequenceWriter sw = new ObjectMapper().writerWithDefaultPrettyPrinter()
+ .writeValues(licenseMapOutputFile).init(true);
+ for (LicensedProjects entry : licenseMap.values()) {
+ sw.write(entry);
+ }
+ sw.close();
+ }
+ }
+
+ private void rebuildLicenseContentProjectMap() {
+ int counter = 0;
+ Map<String, LicensedProjects> licenseMap2 = new TreeMap<>(WHITESPACE_NORMALIZED_COMPARATOR);
+ for (LicensedProjects lps : licenseMap.values()) {
+ for (Project project : lps.getProjects()) {
+ String licenseText = project.getLicenseText();
+ if (licenseText == null) {
+ getLog().warn("Using license other than from within artifact: " + project.gav());
+ licenseText = lps.getLicense().getContent();
+ }
+ if (!licenseMap2.containsKey(licenseText)) {
+ LicenseSpec spec = lps.getLicense();
+ if (!licenseText.equals(lps.getLicense().getContent())) {
+ spec = new LicenseSpec(new ArrayList<>(), licenseText, null, spec.getDisplayName(),
+ spec.getMetric(), spec.getUrl() + (counter++));
+ }
+ licenseMap2.put(licenseText, new LicensedProjects(spec));
+ }
+ licenseMap2.get(licenseText).addProject(project);
+ }
+ }
+ licenseMap = licenseMap2;
+ }
+
+ private Set<Project> getProjects() {
+ Set<Project> projects = new HashSet<>();
+ licenseMap.values().forEach(p -> projects.addAll(p.getProjects()));
+ return projects;
+ }
+
+ private void buildNoticeProjectMap() {
+ noticeMap = new TreeMap<>(WHITESPACE_NORMALIZED_COMPARATOR);
+ for (Project project : getProjects()) {
+ final String noticeText = project.getNoticeText();
+ if (noticeText == null) {
+ continue;
+ }
+ if (!noticeMap.containsKey(noticeText)) {
+ noticeMap.put(noticeText, new TreeSet<>(Project.PROJECT_COMPARATOR));
+ }
+ noticeMap.get(noticeText).add(project);
+ }
+ }
+
+ private void resolveNoticeFiles() throws MojoExecutionException, IOException {
+ resolveArtifactFiles("NOTICE", entry -> entry.getName().matches("(.*/|^)" + "NOTICE" + "(.txt)?"),
+ Project::setNoticeText, text -> FOUNDATION_PATTERN.matcher(text).replaceAll(""));
+ }
+
+ private void resolveLicenseFiles() throws MojoExecutionException, IOException {
+ resolveArtifactFiles("LICENSE", entry -> entry.getName().matches("(.*/|^)" + "LICENSE" + "(.txt)?"),
+ Project::setLicenseText, UnaryOperator.identity());
+ }
+
+ private void resolveArtifactFiles(final String name, Predicate<JarEntry> filter,
+ BiConsumer<Project, String> consumer, UnaryOperator<String> contentTransformer)
+ throws MojoExecutionException, IOException {
+ for (Project project : getProjects()) {
+ File artifactFile = new File(project.getArtifactPath());
+ if (!artifactFile.exists()) {
+ throw new MojoExecutionException("Artifact file " + artifactFile + " does not exist!");
+ } else if (!artifactFile.getName().endsWith(".jar")) {
+ throw new MojoExecutionException("Unknown artifact file type: " + artifactFile);
+ }
+ try (JarFile jarFile = new JarFile(artifactFile)) {
+ SortedMap<String, JarEntry> matches = gatherMatchingEntries(jarFile,
+ filter);
+ if (matches.isEmpty()) {
+ getLog().warn("No " + name + " file found for " + project.gav());
+ continue;
+ } else if (matches.size() > 1) {
+ getLog().warn("Multiple " + name + " files found for " + project.gav() + ": " + matches.keySet()
+ + "; taking first");
+ } else {
+ getLog().info(project.gav() + " has " + name + " file: " + matches.keySet());
+ }
+ resolveContent(project, jarFile, matches.values().iterator().next(),
+ contentTransformer, consumer, name);
+ }
+ }
+ }
+
+ private void resolveContent(Project project, JarFile jarFile, JarEntry entry, UnaryOperator<String> transformer,
+ BiConsumer<Project, String> contentConsumer, final String name) throws IOException {
+ String text = IOUtils.toString(jarFile.getInputStream(entry), StandardCharsets.UTF_8);
+ text = transformer.apply(text);
+ text = LicenseUtil.trim(text);
+ if (text.length() == 0) {
+ getLog().warn("Ignoring empty " + name + " file ( " + entry + ") for " + project.gav());
+ } else {
+ contentConsumer.accept(project, text);
+ getLog().debug("Resolved " + name + " text for " + project.gav() + ": \n" + text);
+ }
+ }
+
+ private SortedMap<String, JarEntry> gatherMatchingEntries(JarFile jarFile, Predicate<JarEntry> filter) {
+ SortedMap<String, JarEntry> matches = new TreeMap<>();
+ Enumeration<JarEntry> entries = jarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ if (filter.test(entry)) {
+ matches.put(entry.getName(), entry);
+ }
+ }
+ return matches;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GeneratedFile.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GeneratedFile.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GeneratedFile.java
new file mode 100644
index 0000000..b89dc88
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GeneratedFile.java
@@ -0,0 +1,36 @@
+/*
+ * 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.asterix.license;
+
+public class GeneratedFile {
+
+ @SuppressWarnings("unused") // set by Maven plugin configuration
+ private String template;
+
+ @SuppressWarnings("unused") // set by Maven plugin configuration
+ private String outputFile;
+
+ public String getOutputFile() {
+ return outputFile;
+ }
+
+ public String getTemplate() {
+ return template;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
new file mode 100644
index 0000000..846c9b6
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
@@ -0,0 +1,315 @@
+/*
+ * 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.asterix.license;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.asterix.license.project.LicensedProjects;
+import org.apache.asterix.license.project.Project;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.License;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
+
+public abstract class LicenseMojo extends AbstractMojo {
+
+ @Parameter
+ protected List<Override> overrides = new ArrayList<>();
+
+ @Parameter
+ protected String [] models = new String [0];
+
+ @Parameter
+ protected List<LicenseSpec> licenses = new ArrayList<>();
+
+ @Parameter
+ protected Set<String> excludedScopes = new HashSet<>();
+
+ @Parameter
+ protected List<String> excludes = new ArrayList<>();
+
+ @Parameter
+ protected List<DependencySet> dependencySets = new ArrayList<>();
+
+ @Parameter( defaultValue = "${project}", readonly = true )
+ protected MavenProject project;
+
+ @Parameter( property = "localRepository", required = true, readonly = true )
+ private ArtifactRepository localRepository;
+
+ @Parameter( property = "project.remoteArtifactRepositories", required = true, readonly = true )
+ private List<ArtifactRepository> remoteRepositories;
+
+ @Component( role = MavenProjectBuilder.class )
+ protected MavenProjectBuilder projectBuilder;
+
+ @Component
+ private ModelInheritanceAssembler assembler;
+
+ @Parameter ( required = true )
+ private String location;
+
+ @Parameter ( required = true )
+ protected File licenseDirectory;
+
+ private Map<String, MavenProject> projectCache = new HashMap<>();
+
+ private Map<String, Model> supplementModels;
+
+ private List<Pattern> excludePatterns;
+
+ Map<String, LicenseSpec> urlToLicenseMap = new HashMap<>();
+ Map<String, LicensedProjects> licenseMap = new TreeMap<>();
+
+ protected Map<String, LicensedProjects> getLicenseMap() {
+ return licenseMap;
+ }
+
+ protected void init() throws MojoExecutionException, MalformedURLException,
+ ProjectBuildingException {
+ excludedScopes.add("system");
+ excludePatterns = compileExcludePatterns();
+ supplementModels = SupplementalModelHelper.loadSupplements(getLog(), models);
+ buildUrlLicenseMap();
+ }
+
+ protected void addDependenciesToLicenseMap() throws ProjectBuildingException {
+ Map<MavenProject, List<Pair<String, String>>> dependencyLicenseMap = gatherDependencies();
+ for (Map.Entry<MavenProject, List<Pair<String, String>>> dep : dependencyLicenseMap.entrySet()) {
+ final MavenProject depProject = dep.getKey();
+ String depLocation = dependencySets.isEmpty() ? location : getIncludedLocation(depProject.getArtifact());
+ if (isExcluded(depProject.getArtifact())) {
+ getLog().debug("skipping " + depProject + " [excluded]");
+ } else if (depLocation == null) {
+ getLog().debug("skipping " + depProject + " [not included in dependency sets]");
+ } else {
+ addDependencyToLicenseMap(depProject, dep.getValue(), depLocation);
+ }
+ }
+ }
+
+ private void addDependencyToLicenseMap(MavenProject depProject, List<Pair<String, String>> depLicenses,
+ String depLocation) {
+ final String depGav = toGav(depProject);
+ getLog().debug("adding " + depGav + ", location: " + depLocation);
+ if (depLicenses.size() > 1) {
+ Collections.sort(depLicenses, (o1, o2) -> {
+ final LicenseSpec l1 = urlToLicenseMap.get(o1.getLeft());
+ final LicenseSpec l2 = urlToLicenseMap.get(o2.getLeft());
+ return Integer.compare(l1 != null ? l1.getMetric() : LicenseSpec.UNDEFINED_LICENSE_METRIC,
+ l2 != null ? l2.getMetric() : LicenseSpec.UNDEFINED_LICENSE_METRIC);
+ });
+ getLog().warn("Multiple licenses for " + depGav + ": " + depLicenses
+ + "; taking first or lowest metric.");
+ } else if (depLicenses.isEmpty()) {
+ getLog().error("No license defined for " + depGav);
+ depLicenses.add(new ImmutablePair<>("MISSING_LICENSE", "MISSING LICENSE"));
+ }
+ Pair<String, String> key = depLicenses.get(0);
+ String licenseUrl = key.getLeft();
+ final String displayName = key.getRight();
+ if (!urlToLicenseMap.containsKey(licenseUrl)) {
+ // assuming we've not already mapped it, annotate the URL with artifact info, if not an actual URL
+ try {
+ getLog().debug("- URL: " + new URL(licenseUrl));
+ // life is good
+ } catch (MalformedURLException e) {
+ // we encounter this a lot. Log a warning, and use an annotated key
+ final String fakeLicenseUrl = depGav.replaceAll(":", "--") + "_" + licenseUrl;
+ getLog().warn("- URL for " + depGav + " is malformed: " + licenseUrl + "; using: "
+ + fakeLicenseUrl);
+ licenseUrl = fakeLicenseUrl;
+ }
+ }
+ File path = new File(localRepository.getBasedir(), localRepository.pathOf(depProject.getArtifact()));
+ addProject(new Project(depProject, depLocation, path), new LicenseSpec(licenseUrl, displayName));
+ }
+
+ protected void addProject(Project project, LicenseSpec licenseSpecNew) {
+ String licenseUrl = licenseSpecNew.getUrl();
+ LicenseSpec license = urlToLicenseMap.get(licenseUrl);
+ if (license == null) {
+ license = licenseSpecNew;
+ urlToLicenseMap.put(licenseUrl, license);
+ }
+ licenseUrl = license.getUrl();
+ LicensedProjects entry = licenseMap.get(licenseUrl);
+ if (entry == null) {
+ entry = new LicensedProjects(license);
+ licenseMap.put(licenseUrl, entry);
+ }
+ entry.addProject(project);
+ }
+
+ private void buildUrlLicenseMap() throws MojoExecutionException {
+ for (LicenseSpec license : licenses) {
+ if (urlToLicenseMap.put(license.getUrl() ,license) != null) {
+ throw new MojoExecutionException("Duplicate URL mapping: " + license.getUrl());
+ }
+ for (String alias : license.getAliasUrls()) {
+ if (urlToLicenseMap.put(alias ,license) != null) {
+ throw new MojoExecutionException("Duplicate URL mapping: " + alias);
+ }
+
+ }
+ }
+ }
+
+ protected Map<MavenProject, List<Pair<String, String>>> gatherDependencies() throws ProjectBuildingException {
+ Map<MavenProject, List<Pair<String, String>>> dependencyLicenseMap = new HashMap<>();
+ Map<String, MavenProject> dependencyGavMap = new HashMap<>();
+
+ gatherProjectDependencies(project, dependencyLicenseMap, dependencyGavMap);
+ for (Override override : overrides) {
+ String gav = override.getGav();
+ MavenProject dep = dependencyGavMap.get(gav);
+ if (dep == null) {
+ getLog().warn("Unused override dependency " + gav + "; ignoring...");
+ } else {
+ final List<Pair<String, String>> newUrl = Collections.singletonList(
+ new ImmutablePair<>(override.getUrl(), override.getName()));
+ List<Pair<String, String>> prev = dependencyLicenseMap.put(dep, newUrl);
+ if (!prev.isEmpty()) {
+ getLog().warn("NOTICE: replacing license(s) " + prev + " for dependency " + gav + " with "
+ + newUrl);
+ }
+ }
+ }
+ return dependencyLicenseMap;
+ }
+
+ private void gatherProjectDependencies(MavenProject project, Map<MavenProject,
+ List<Pair<String, String>>> dependencyLicenseMap, Map<String, MavenProject> dependencyGavMap)
+ throws ProjectBuildingException {
+ final Set dependencyArtifacts = project.getArtifacts();
+ if (dependencyArtifacts != null) {
+ for (Object depArtifactObj : dependencyArtifacts) {
+ final Artifact depArtifact = (Artifact) depArtifactObj;
+ if (!excludedScopes.contains(depArtifact.getScope())) {
+ MavenProject dep = resolveDependency(depArtifact);
+ dep.setArtifact(depArtifact);
+ dependencyGavMap.put(toGav(dep), dep);
+ List<Pair<String, String>> licenseUrls = new ArrayList<>();
+ for (Object license : dep.getLicenses()) {
+ final License license1 = (License) license;
+ String url = license1.getUrl() != null ? license1.getUrl()
+ : (license1.getName() != null ? license1.getName()
+ : "LICENSE_EMPTY_NAME_URL");
+ licenseUrls.add(new ImmutablePair<>(url, license1.getName()));
+ }
+ dependencyLicenseMap.put(dep, licenseUrls);
+ }
+ }
+ }
+ }
+
+ protected MavenProject resolveDependency(Artifact depObj) throws ProjectBuildingException {
+ String key = depObj.getGroupId() + ":" + depObj.getArtifactId() + ":" + depObj.getVersion();
+
+ MavenProject depProj = projectCache.get(key);
+
+ if (depProj == null) {
+ try {
+ depProj = projectBuilder.buildFromRepository(depObj, remoteRepositories, localRepository, false);
+ } catch (ProjectBuildingException e) {
+ throw new ProjectBuildingException(key, "Error creating dependent artifacts", e);
+ }
+
+ Model supplement = supplementModels.get(
+ SupplementalModelHelper.generateSupplementMapKey(depObj.getGroupId(), depObj.getArtifactId()));
+ if (supplement != null) {
+ Model merged = SupplementalModelHelper.mergeModels(assembler, depProj.getModel(), supplement);
+ Set<String> origLicenses = depProj.getModel().getLicenses().stream().map(License::getUrl)
+ .collect(Collectors.toSet());
+ Set<String> newLicenses = merged.getLicenses().stream().map(License::getUrl)
+ .collect(Collectors.toSet());
+ if (!origLicenses.equals(newLicenses)) {
+ getLog().warn("license list for " + toGav(depProj)
+ + " changed with supplemental model; was: " + origLicenses
+ + ", now: " + newLicenses);
+ }
+ depProj = new MavenProject(merged);
+ depProj.setArtifact( depObj );
+ depProj.setVersion( depObj.getVersion() );
+ }
+ depProj.getArtifact().setScope(depObj.getScope());
+ projectCache.put(key, depProj);
+ }
+ return depProj;
+ }
+
+ private String toGav(MavenProject dep) {
+ return dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion();
+ }
+
+ protected List<Pattern> compileExcludePatterns() {
+ List<Pattern> patterns = new ArrayList<>();
+ for (String exclude : excludes) {
+ patterns.add(compileGAWildcardPattern(exclude));
+ }
+ return patterns;
+ }
+
+ public static Pattern compileGAWildcardPattern(String spec) {
+ return Pattern.compile(spec.replace(".", "\\.").replace("*", "[^:]*"));
+ }
+
+ protected boolean isExcluded(Artifact artifact) {
+ for (Pattern exclude : excludePatterns) {
+ if (exclude.matcher(artifact.getGroupId() + ":" + artifact.getArtifactId()).matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected String getIncludedLocation(Artifact artifact) {
+ for (DependencySet set : dependencySets) {
+ for (Pattern include : set.getPatterns()) {
+ if (include.matcher(artifact.getGroupId() + ":" + artifact.getArtifactId()).matches()) {
+ return set.getLocation();
+ }
+ }
+ }
+ return null;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseSpec.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseSpec.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseSpec.java
new file mode 100644
index 0000000..885a5bc
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseSpec.java
@@ -0,0 +1,115 @@
+/*
+ * 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.asterix.license;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class LicenseSpec {
+
+ public static final int DEFAULT_METRIC = 100;
+ public static final int UNDEFINED_LICENSE_METRIC = 999;
+
+ public static final String BAD_CHARS = "[ \"#$%&'()*+,/:;<=>\\[\\]^`\\{\\|\\}~]";
+ private String url;
+ private String contentFile;
+ private List<String> aliasUrls = new ArrayList<>();
+ private String displayName;
+ private int metric = DEFAULT_METRIC;
+ private String content;
+
+ @SuppressWarnings("unused")
+ public LicenseSpec() {
+ // called by Maven configuration
+ }
+
+ @JsonCreator
+ public LicenseSpec(@JsonProperty("aliasUrls") List<String> aliasUrls, @JsonProperty("content") String content,
+ @JsonProperty("contentFile") String contentFile, @JsonProperty("displayName") String displayName,
+ @JsonProperty("metric") int metric, @JsonProperty("url") String url) {
+ this.aliasUrls = aliasUrls;
+ this.content = content;
+ this.contentFile = contentFile;
+ this.displayName = displayName;
+ this.metric = metric;
+ this.url = url;
+ }
+
+ public LicenseSpec(String url, String displayName) {
+ this.url = url;
+ if (displayName != null) {
+ this.displayName = displayName;
+ }
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public String getContentFile() {
+ return getContentFile(true);
+ }
+
+ @SuppressWarnings("squid:S1166")
+ public String getContentFile(boolean fixupExtension) {
+ if (contentFile == null) {
+ String file;
+ try {
+ URI uri = new URI(url);
+ file = ((uri.getHost() != null ? uri.getHost() : "")
+ + uri.getPath()).replaceAll(BAD_CHARS, "_");
+ } catch (URISyntaxException e) {
+ file = url.replaceAll(BAD_CHARS, "_");
+ }
+ return (!fixupExtension || file.endsWith(".txt")) ? file : file + ".txt";
+ } else {
+ return contentFile;
+ }
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public List<String> getAliasUrls() {
+ return aliasUrls;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public int getMetric() {
+ return metric;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseUtil.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseUtil.java
new file mode 100644
index 0000000..8d09a81
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseUtil.java
@@ -0,0 +1,123 @@
+/*
+ * 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.asterix.license;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+
+public class LicenseUtil {
+
+ private static int wrapLength = 80;
+ private static int wrapThreshold = 100;
+
+ private LicenseUtil() {
+ }
+
+ public static void setWrapLength(int wrapLength) {
+ LicenseUtil.wrapLength = wrapLength;
+ }
+
+ public static void setWrapThreshold(int wrapThreshold) {
+ LicenseUtil.wrapThreshold = wrapThreshold;
+ }
+
+ public static String trim(String input) throws IOException {
+ try (BufferedReader reader = new BufferedReader(new StringReader(input))) {
+ reader.mark(input.length() + 1);
+ StringWriter sw = new StringWriter();
+ trim(sw, reader);
+ return sw.toString();
+ }
+ }
+
+ public static void readAndTrim(Writer out, File file) throws IOException {
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
+ reader.mark((int) file.length() * 2);
+ trim(out, reader);
+ }
+ }
+
+ private static void trim(Writer out, BufferedReader reader) throws IOException {
+ Pair<Integer, Integer> result = analyze(reader);
+ reader.reset();
+ doTrim(out, reader, result.getLeft(), result.getRight() > wrapThreshold ? wrapLength : Integer.MAX_VALUE);
+ }
+
+ private static void doTrim(Writer out, BufferedReader reader, int extraPadding, int wrapLength) throws IOException {
+ boolean head = true;
+ int empty = 0;
+ for (String line = reader.readLine(); line != null; line = reader.readLine() ) {
+ if ("".equals(line.trim())) {
+ if (!head) {
+ empty++;
+ }
+ } else {
+ head = false;
+ for (; empty > 0; empty--) {
+ out.append('\n');
+ }
+ String trimmed = line.substring(extraPadding);
+ int leadingWS = trimmed.length() - trimmed.trim().length();
+ while (trimmed.length() > wrapLength) {
+ int cut = trimmed.lastIndexOf(' ', wrapLength);
+ cut = Math.max(cut, trimmed.lastIndexOf('\t', wrapLength));
+ if (cut != -1) {
+ out.append(trimmed.substring(0, cut));
+ out.append('\n');
+ trimmed = trimmed.substring(cut + 1);
+ } else {
+ out.append(trimmed.substring(0, wrapLength));
+ out.append('\n');
+ trimmed = trimmed.substring(wrapLength);
+ }
+ for (int i = 0; i < leadingWS; i++) {
+ trimmed = ' ' + trimmed;
+ }
+ }
+ out.append(trimmed);
+ empty++;
+ }
+ }
+ }
+
+ private static Pair<Integer, Integer> analyze(BufferedReader reader) throws IOException {
+ int freeSpaces = Integer.MAX_VALUE;
+ int maxLineLength = 0;
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ // trim trailing WS
+ String rightTrimmed = line.replaceFirst("\\s*$", "");
+ if ("".equals(rightTrimmed)) {
+ // ignore empty lines
+ continue;
+ }
+ String fullyTrimmed = line.trim();
+ freeSpaces = Math.min(freeSpaces, rightTrimmed.length() - fullyTrimmed.length());
+ maxLineLength = Math.max(maxLineLength, fullyTrimmed.length());
+ }
+ return new ImmutablePair<>(freeSpaces, maxLineLength);
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/Override.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/Override.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/Override.java
new file mode 100644
index 0000000..4d1bbbe
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/Override.java
@@ -0,0 +1,43 @@
+/*
+ * 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.asterix.license;
+
+public class Override {
+
+ @SuppressWarnings("unused") // set by Maven plugin configuration
+ private String url;
+
+ @SuppressWarnings("unused") // set by Maven plugin configuration
+ private String gav;
+
+ @SuppressWarnings("unused") // set by Maven plugin configuration
+ private String name;
+
+ public String getGav() {
+ return gav;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1355c269/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/SupplementalModelHelper.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/SupplementalModelHelper.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/SupplementalModelHelper.java
new file mode 100644
index 0000000..9059d07
--- /dev/null
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/SupplementalModelHelper.java
@@ -0,0 +1,134 @@
+/*
+ * 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.asterix.license;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.resources.remote.Supplement;
+import org.apache.maven.plugin.resources.remote.SupplementalDataModel;
+import org.apache.maven.plugin.resources.remote.io.xpp3.SupplementalDataModelXpp3Reader;
+import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+public class SupplementalModelHelper {
+
+ private SupplementalModelHelper() {
+ }
+
+ // following code taken from ProcessRemoteResourcesMojo (org.apache.maven.plugins:maven-remote-resources-plugin:1.5)
+
+ static String generateSupplementMapKey(String groupId, String artifactId) {
+ return groupId.trim() + ":" + artifactId.trim();
+ }
+
+ static Map<String, Model> loadSupplements(Log log, String[] models) throws MojoExecutionException {
+ if (models == null) {
+ log.debug("Supplemental data models won't be loaded. " + "No models specified.");
+ return Collections.emptyMap();
+ }
+
+ List<Supplement> supplements = new ArrayList<>();
+ for (String set : models) {
+ log.debug("Preparing ruleset: " + set);
+ try {
+ File f = new File(set);
+
+ if (!f.exists()) {
+ throw new MojoExecutionException("Cold not resolve " + set);
+ }
+ if (!f.canRead()) {
+ throw new MojoExecutionException("Supplemental data models won't be loaded. " + "File "
+ + f.getAbsolutePath() + " cannot be read, check permissions on the file.");
+ }
+
+ log.debug("Loading supplemental models from " + f.getAbsolutePath());
+
+ SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader();
+ SupplementalDataModel supplementalModel = reader.read(new FileReader(f));
+ supplements.addAll(supplementalModel.getSupplement());
+ } catch (Exception e) {
+ String msg = "Error loading supplemental data models: " + e.getMessage();
+ log.error(msg, e);
+ throw new MojoExecutionException(msg, e);
+ }
+ }
+
+ log.debug("Loading supplements complete.");
+
+ Map<String, Model> supplementMap = new HashMap<>();
+ for (Supplement sd : supplements) {
+ Xpp3Dom dom = (Xpp3Dom) sd.getProject();
+
+ Model m = getSupplement(log, dom);
+ supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m);
+ }
+
+ return supplementMap;
+ }
+
+ protected static Model getSupplement(Log log, Xpp3Dom supplementModelXml) throws MojoExecutionException {
+ MavenXpp3Reader modelReader = new MavenXpp3Reader();
+ Model model = null;
+
+ try {
+ model = modelReader.read(new StringReader(supplementModelXml.toString()));
+ String groupId = model.getGroupId();
+ String artifactId = model.getArtifactId();
+
+ if (groupId == null || "".equals(groupId.trim())) {
+ throw new MojoExecutionException(
+ "Supplemental project XML requires that a <groupId> element be present.");
+ }
+
+ if (artifactId == null || "".equals(artifactId.trim())) {
+ throw new MojoExecutionException(
+ "Supplemental project XML requires that a <artifactId> element be present.");
+ }
+ } catch (IOException e) {
+ log.warn("Unable to read supplemental XML: " + e.getMessage(), e);
+ } catch (XmlPullParserException e) {
+ log.warn("Unable to parse supplemental XML: " + e.getMessage(), e);
+ }
+
+ return model;
+ }
+
+ protected static Model mergeModels(ModelInheritanceAssembler assembler, Model parent, Model child) {
+ assembler.assembleModelInheritance(child, parent);
+ // ModelInheritanceAssembler doesn't push the name, do it here
+ if (child.getName() == null) {
+ child.setName(parent.getName());
+ }
+ return child;
+ }
+
+}