diff --git a/search-services/packaging/pom.xml b/search-services/packaging/pom.xml index 12a3ee3f4..e02570701 100644 --- a/search-services/packaging/pom.xml +++ b/search-services/packaging/pom.xml @@ -28,6 +28,20 @@ ${project.version} libs + + + + org.reflections + reflections + 0.9.11 + test + + + junit + junit + 4.12 + test + alfresco-search-services-${project.version} diff --git a/search-services/packaging/src/main/resources/licenses/notice.txt b/search-services/packaging/src/main/resources/licenses/notice.txt index e1bd6bdd8..f74036e8d 100644 --- a/search-services/packaging/src/main/resources/licenses/notice.txt +++ b/search-services/packaging/src/main/resources/licenses/notice.txt @@ -95,10 +95,9 @@ lucene-memory-6.6.5.jar https://lucene.apache.org/ lucene-codecs-6.6.5.jar https://lucene.apache.org/ lucene-join-6.6.5.jar https://lucene.apache.org/ guessencoding-1.4.jar http://docs.codehaus.org/display/GUESSENC/ -xml-apis-2.10.0.jar https://github.com/FasterXML/jackson -jetty-start-9.3.14.v20161028.jar https://www.eclipse.org/jetty/licenses.html +xml-apis-1.4.01.jar https://github.com/FasterXML/jackson resolver-20050927.jar http://xml.apache.org/commons/ -jug-2.0.0.jar http://jug.safehaus.org/ +jug-2.0.0-asl.jar http://jug.safehaus.org/ acegi-security-0.8.2_patched.jar http://sourceforge.net/projects/acegisecurity/ @@ -125,3 +124,122 @@ javax.activation-api-1.2.0.jar https://github.com/javaee/activation/blob/master === BSD === jibx-run-1.2.6.jar http://jibx.sourceforge.net/ + + +=== Part of Apache Solr (Licenses listed separately) === +antlr4-runtime-4.5.1-1.jar +apache-mime4j-core-0.7.2.jar +apache-mime4j-dom-0.7.2.jar +asm-5.1.jar +asm-commons-5.1.jar +aspectjrt-1.8.0.jar +attributes-binder-1.3.1.jar +avatica-core-1.9.0.jar +bcmail-jdk15-1.45.jar +bcprov-jdk15-1.45.jar +boilerpipe-1.1.0.jar +caffeine-2.4.0.jar +calcite-core-1.11.0.jar +calcite-linq4j-1.11.0.jar +carrot2-guava-18.0.jar +carrot2-mini-3.15.0.jar +commons-cli-1.2.jar +commons-codec-1.10.jar +commons-collections-3.2.2.jar +commons-collections4-4.1.jar +commons-compiler-2.7.6.jar +commons-compress-1.14.jar +commons-configuration-1.6.jar +commons-exec-1.3.jar +commons-fileupload-1.3.2.jar +commons-io-2.5.jar +commons-lang-2.6.jar +commons-math3-3.4.1.jar +curator-client-2.8.0.jar +curator-framework-2.8.0.jar +curator-recipes-2.8.0.jar +curvesapi-1.04.jar +dom4j-1.6.1.jar +eigenbase-properties-1.1.5.jar +fontbox-2.0.6.jar +gmetric4j-1.0.7.jar +guava-14.0.1.jar +hadoop-annotations-2.7.4.jar +hadoop-auth-2.7.4.jar +hadoop-common-2.7.4.jar +hadoop-hdfs-2.7.4.jar +hppc-0.7.1.jar +htrace-core-3.2.0-incubating.jar +httpclient-4.4.1.jar +httpcore-4.4.1.jar +httpmime-4.4.1.jar +icu4j-56.1.jar +isoparser-1.1.18.jar +jackcess-2.1.8.jar +jackson-core-asl-1.9.13.jar +jackson-databind-2.5.4.jar +jackson-dataformat-smile-2.5.4.jar +jackson-mapper-asl-1.9.13.jar +janino-2.7.6.jar +java-libpst-0.8.1.jar +javax.servlet-api-3.1.0.jar +jcl-over-slf4j-1.7.7.jar +jdom-1.0.jar +jempbox-1.8.13.jar +jetty-continuation-9.3.14.v20161028.jar +jetty-deploy-9.3.14.v20161028.jar +jetty-http-9.3.14.v20161028.jar +jetty-io-9.3.14.v20161028.jar +jetty-jmx-9.3.14.v20161028.jar +jetty-rewrite-9.3.14.v20161028.jar +jetty-security-9.3.14.v20161028.jar +jetty-server-9.3.14.v20161028.jar +jetty-servlet-9.3.14.v20161028.jar +jetty-servlets-9.3.14.v20161028.jar +jetty-util-9.3.14.v20161028.jar +jetty-webapp-9.3.14.v20161028.jar +jetty-xml-9.3.14.v20161028.jar +jmatio-1.2.jar +joda-time-2.2.jar +jsonic-1.2.7.jar +juniversalchardet-1.0.3.jar +langdetect-1.1-20120112.jar +log4j-1.2.17.jar +metadata-extractor-2.9.1.jar +metrics-core-3.2.2.jar +metrics-ganglia-3.2.2.jar +metrics-graphite-3.2.2.jar +metrics-jetty9-3.2.2.jar +metrics-jvm-3.2.2.jar +morfologik-fsa-2.1.1.jar +morfologik-polish-2.1.1.jar +morfologik-stemming-2.1.1.jar +noggit-0.6.jar +org.restlet-2.3.0.jar +org.restlet.ext.servlet-2.3.0.jar +pdfbox-2.0.6.jar +pdfbox-tools-2.0.6.jar +poi-3.17-beta1.jar +poi-ooxml-3.17-beta1.jar +poi-ooxml-schemas-3.17-beta1.jar +poi-scratchpad-3.17-beta1.jar +protobuf-java-3.1.0.jar +rome-1.5.1.jar +simple-xml-2.7.1.jar +slf4j-api-1.7.12.jar +slf4j-log4j12-1.7.12.jar +spatial4j-0.6.jar +stax2-api-3.1.4.jar +tagsoup-1.2.1.jar +t-digest-3.1.jar +tika-core-1.16.jar +tika-java7-1.16.jar +tika-parsers-1.16.jar +tika-xmp-1.16.jar +vorbis-java-core-0.8.jar +vorbis-java-tika-0.8.jar +woodstox-core-asl-4.4.1.jar +xmlbeans-2.6.0.jar +xmpcore-5.1.2.jar +xz-1.6.jar +zookeeper-3.4.10.jar diff --git a/search-services/packaging/src/test/java/org/alfresco/ThirdPartyLicensesTest.java b/search-services/packaging/src/test/java/org/alfresco/ThirdPartyLicensesTest.java new file mode 100644 index 000000000..e53496bf0 --- /dev/null +++ b/search-services/packaging/src/test/java/org/alfresco/ThirdPartyLicensesTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.reflections.Reflections; +import org.reflections.scanners.ResourcesScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; + +/** + * Tests of the declared third party licenses. + */ +public class ThirdPartyLicensesTest +{ + /** A list of jars that should be ignored as they will be excluded from the released artifacts. */ + private static final List IGNORED = Arrays.asList("net/sf/ehcache/pool/sizeof/sizeof-agent.jar"); + /** Libraries produced by Alfresco will start with "alfresco-". */ + private static final String ALFRESCO_PREFIX = "alfresco-"; + /** Spring Surf is also produced by Alfresco (it lives at https://github.com/Alfresco/surf). */ + private static final String SPRING_SURF_PREFIX = "spring-surf-"; + + /** + * Test that the dependencies in notice.txt match the actual dependencies, to ensure we've included third party + * licenses for all dependencies. + * + * @throws Exception Unexpected + */ + @Test + public void testLicensesDeclared() throws Exception + { + // Get the jar files found on the classpath. + Reflections reflections = new Reflections(new ConfigurationBuilder() + .setUrls(ClasspathHelper.forClassLoader()) + .setScanners(new ResourcesScanner())); + + List jars = reflections.getResources(Pattern.compile(".*\\.jar")).stream() + .map(path -> path.replace("libs/", "")) + .filter(name -> !name.startsWith(ALFRESCO_PREFIX)) // We don't need a declaration for alfresco libraries. + .filter(name -> !name.startsWith(SPRING_SURF_PREFIX)) + .filter(name -> !IGNORED.contains(name)) + .sorted() + .collect(Collectors.toList()); + + // Get the dependencies referenced in notice.txt. + List lines = Files.readAllLines( + new File(this.getClass().getClassLoader().getResource("licenses/notice.txt").getFile()) + .toPath()); + // Skip the header, which is all lines before the first "=== License Type ===" line. + int headerSize = 0; + for (String line : lines) + { + if (line.startsWith("===")) + { + break; + } + headerSize++; + } + List declared = lines.stream() + .skip(headerSize) + .filter(line -> !line.isEmpty() && !line.startsWith("===")) + .map(line -> line.split(" ")[0]) + .sorted() + .collect(Collectors.toList()); + + assertEquals("Jar files on classpath do not match those declared in notice.txt file.", jars, declared); + } +}