Merge pull request #12754 from clintongormley/license_checker_in_parent
Enable the license checker over distribution/* and plugins/*
This commit is contained in:
commit
8218a7185e
11
core/pom.xml
11
core/pom.xml
|
@ -320,6 +320,17 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<!-- Don't run the license checker in core -->
|
||||||
|
<id>check-license</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use v5.10;
|
||||||
|
|
||||||
use FindBin qw($RealBin);
|
use FindBin qw($RealBin);
|
||||||
use lib "$RealBin/lib";
|
use lib "$RealBin/lib";
|
||||||
|
@ -10,20 +11,9 @@ use File::Temp();
|
||||||
use File::Find();
|
use File::Find();
|
||||||
use File::Basename qw(basename);
|
use File::Basename qw(basename);
|
||||||
use Archive::Extract();
|
use Archive::Extract();
|
||||||
|
use Digest::SHA();
|
||||||
$Archive::Extract::PREFER_BIN = 1;
|
$Archive::Extract::PREFER_BIN = 1;
|
||||||
|
|
||||||
our $SHA_CLASS = 'Digest::SHA';
|
|
||||||
if ( eval { require Digest::SHA } ) {
|
|
||||||
$SHA_CLASS = 'Digest::SHA';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
print STDERR "Digest::SHA not available. "
|
|
||||||
. "Falling back to Digest::SHA::PurePerl\n";
|
|
||||||
require Digest::SHA::PurePerl;
|
|
||||||
$SHA_CLASS = 'Digest::SHA::PurePerl';
|
|
||||||
}
|
|
||||||
|
|
||||||
my $mode = shift(@ARGV) || "";
|
my $mode = shift(@ARGV) || "";
|
||||||
die usage() unless $mode =~ /^--(check|update)$/;
|
die usage() unless $mode =~ /^--(check|update)$/;
|
||||||
|
|
||||||
|
@ -32,6 +22,9 @@ my $Source = shift(@ARGV) || die usage();
|
||||||
$License_Dir = File::Spec->rel2abs($License_Dir) . '/';
|
$License_Dir = File::Spec->rel2abs($License_Dir) . '/';
|
||||||
$Source = File::Spec->rel2abs($Source);
|
$Source = File::Spec->rel2abs($Source);
|
||||||
|
|
||||||
|
say "LICENSE DIR: $License_Dir";
|
||||||
|
say "SOURCE: $Source";
|
||||||
|
|
||||||
die "License dir is not a directory: $License_Dir\n" . usage()
|
die "License dir is not a directory: $License_Dir\n" . usage()
|
||||||
unless -d $License_Dir;
|
unless -d $License_Dir;
|
||||||
|
|
||||||
|
@ -59,15 +52,15 @@ sub check_shas_and_licenses {
|
||||||
for my $jar ( sort keys %new ) {
|
for my $jar ( sort keys %new ) {
|
||||||
my $old_sha = delete $old{$jar};
|
my $old_sha = delete $old{$jar};
|
||||||
unless ($old_sha) {
|
unless ($old_sha) {
|
||||||
print STDERR "$jar: SHA is missing\n";
|
say STDERR "$jar: SHA is missing";
|
||||||
$error++;
|
$error++;
|
||||||
$sha_error++;
|
$sha_error++;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ( $old_sha eq $new{$jar} ) {
|
unless ( $old_sha eq $new{$jar} ) {
|
||||||
print STDERR
|
say STDERR
|
||||||
"$jar: SHA has changed, expected $old_sha but found $new{$jar}\n";
|
"$jar: SHA has changed, expected $old_sha but found $new{$jar}";
|
||||||
$error++;
|
$error++;
|
||||||
$sha_error++;
|
$sha_error++;
|
||||||
next;
|
next;
|
||||||
|
@ -95,41 +88,37 @@ sub check_shas_and_licenses {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless ($license_found) {
|
unless ($license_found) {
|
||||||
print STDERR "$jar: LICENSE is missing\n";
|
say STDERR "$jar: LICENSE is missing";
|
||||||
$error++;
|
$error++;
|
||||||
$sha_error++;
|
$sha_error++;
|
||||||
}
|
}
|
||||||
unless ($notice_found) {
|
unless ($notice_found) {
|
||||||
print STDERR "$jar: NOTICE is missing\n";
|
say STDERR "$jar: NOTICE is missing";
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( keys %old ) {
|
if ( keys %old ) {
|
||||||
print STDERR "Extra SHA files present for: " . join ", ",
|
say STDERR "Extra SHA files present for: " . join ", ", sort keys %old;
|
||||||
sort keys %old;
|
|
||||||
print "\n";
|
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @unused_licenses = grep { !$licenses{$_} } keys %licenses;
|
my @unused_licenses = grep { !$licenses{$_} } keys %licenses;
|
||||||
if (@unused_licenses) {
|
if (@unused_licenses) {
|
||||||
$error++;
|
$error++;
|
||||||
print STDERR "Extra LICENCE file present: " . join ", ",
|
say STDERR "Extra LICENCE file present: " . join ", ",
|
||||||
sort @unused_licenses;
|
sort @unused_licenses;
|
||||||
print "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my @unused_notices = grep { !$notices{$_} } keys %notices;
|
my @unused_notices = grep { !$notices{$_} } keys %notices;
|
||||||
if (@unused_notices) {
|
if (@unused_notices) {
|
||||||
$error++;
|
$error++;
|
||||||
print STDERR "Extra NOTICE file present: " . join ", ",
|
say STDERR "Extra NOTICE file present: " . join ", ",
|
||||||
sort @unused_notices;
|
sort @unused_notices;
|
||||||
print "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sha_error) {
|
if ($sha_error) {
|
||||||
print STDERR <<"SHAS"
|
say STDERR <<"SHAS"
|
||||||
|
|
||||||
You can update the SHA files by running:
|
You can update the SHA files by running:
|
||||||
|
|
||||||
|
@ -137,7 +126,7 @@ $0 --update $License_Dir $Source
|
||||||
|
|
||||||
SHAS
|
SHAS
|
||||||
}
|
}
|
||||||
print("All SHAs and licenses OK\n") unless $error;
|
say("All SHAs and licenses OK") unless $error;
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,13 +139,13 @@ sub write_shas {
|
||||||
for my $jar ( sort keys %new ) {
|
for my $jar ( sort keys %new ) {
|
||||||
if ( $old{$jar} ) {
|
if ( $old{$jar} ) {
|
||||||
next if $old{$jar} eq $new{$jar};
|
next if $old{$jar} eq $new{$jar};
|
||||||
print "Updating $jar\n";
|
say "Updating $jar";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Adding $jar\n";
|
say "Adding $jar";
|
||||||
}
|
}
|
||||||
open my $fh, '>', $License_Dir . $jar or die $!;
|
open my $fh, '>', $License_Dir . $jar or die $!;
|
||||||
print $fh $new{$jar} . "\n" or die $!;
|
say $fh $new{$jar} or die $!;
|
||||||
close $fh or die $!;
|
close $fh or die $!;
|
||||||
}
|
}
|
||||||
continue {
|
continue {
|
||||||
|
@ -164,10 +153,10 @@ sub write_shas {
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $jar ( sort keys %old ) {
|
for my $jar ( sort keys %old ) {
|
||||||
print "Deleting $jar\n";
|
say "Deleting $jar";
|
||||||
unlink $License_Dir . $jar or die $!;
|
unlink $License_Dir . $jar or die $!;
|
||||||
}
|
}
|
||||||
print "SHAs updated\n";
|
say "SHAs updated";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +201,6 @@ sub jars_from_zip {
|
||||||
$archive->extract( to => $dir_name ) || die $archive->error;
|
$archive->extract( to => $dir_name ) || die $archive->error;
|
||||||
my @jars = map { File::Spec->rel2abs( $_, $dir_name ) }
|
my @jars = map { File::Spec->rel2abs( $_, $dir_name ) }
|
||||||
grep { /\.jar$/ && !/elasticsearch[^\/]*$/ } @{ $archive->files };
|
grep { /\.jar$/ && !/elasticsearch[^\/]*$/ } @{ $archive->files };
|
||||||
die "No JARS found in: $source\n"
|
|
||||||
unless @jars;
|
|
||||||
return calculate_shas(@jars);
|
return calculate_shas(@jars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +218,6 @@ sub jars_from_dir {
|
||||||
},
|
},
|
||||||
$source
|
$source
|
||||||
);
|
);
|
||||||
die "No JARS found in: $source\n"
|
|
||||||
unless @jars;
|
|
||||||
return calculate_shas(@jars);
|
return calculate_shas(@jars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +226,7 @@ sub calculate_shas {
|
||||||
#===================================
|
#===================================
|
||||||
my %shas;
|
my %shas;
|
||||||
while ( my $file = shift() ) {
|
while ( my $file = shift() ) {
|
||||||
my $digest = eval { $SHA_CLASS->new(1)->addfile($file) }
|
my $digest = eval { Digest::SHA->new(1)->addfile($file) }
|
||||||
or die "Error calculating SHA1 for <$file>: $!\n";
|
or die "Error calculating SHA1 for <$file>: $!\n";
|
||||||
$shas{ basename($file) . ".sha1" } = $digest->hexdigest;
|
$shas{ basename($file) . ".sha1" } = $digest->hexdigest;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
<packaging.elasticsearch.systemd.sysctl.dir>/usr/lib/sysctl.d</packaging.elasticsearch.systemd.sysctl.dir>
|
<packaging.elasticsearch.systemd.sysctl.dir>/usr/lib/sysctl.d</packaging.elasticsearch.systemd.sysctl.dir>
|
||||||
<packaging.elasticsearch.tmpfilesd.dir>/usr/lib/tmpfiles.d</packaging.elasticsearch.tmpfilesd.dir>
|
<packaging.elasticsearch.tmpfilesd.dir>/usr/lib/tmpfiles.d</packaging.elasticsearch.tmpfilesd.dir>
|
||||||
|
|
||||||
|
<!-- Properties for the license checker -->
|
||||||
|
<project.licenses.dir>${project.basedir}/../licenses</project.licenses.dir>
|
||||||
|
<project.licenses.check_target>${integ.scratch}</project.licenses.check_target>
|
||||||
|
|
||||||
<!-- rpmbuild location : default to /usr/bin/rpmbuild -->
|
<!-- rpmbuild location : default to /usr/bin/rpmbuild -->
|
||||||
<packaging.rpm.rpmbuild>/usr/bin/rpmbuild</packaging.rpm.rpmbuild>
|
<packaging.rpm.rpmbuild>/usr/bin/rpmbuild</packaging.rpm.rpmbuild>
|
||||||
|
|
||||||
|
@ -97,32 +101,6 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<!-- checks integration test scratch area (where we extract the distribution) -->
|
<!-- checks integration test scratch area (where we extract the distribution) -->
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>check-license</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<skip>${skip.integ.tests}</skip>
|
|
||||||
<target>
|
|
||||||
<condition property="licenses.exists">
|
|
||||||
<available file="${basedir}/../licenses" type="dir"/>
|
|
||||||
</condition>
|
|
||||||
<echo taskName="license check">Running license check</echo>
|
|
||||||
<!-- don't run on windows, because everyone hates it -->
|
|
||||||
<exec failonerror="${licenses.exists}" executable="perl" osfamily="unix"
|
|
||||||
dir="${elasticsearch.tools.directory}/license-check">
|
|
||||||
<arg value="check_license_and_sha.pl"/>
|
|
||||||
<arg value="--check"/>
|
|
||||||
<arg value="${basedir}/../licenses"/>
|
|
||||||
<arg value="${integ.scratch}"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
This plugin has no third party dependencies
|
|
@ -0,0 +1 @@
|
||||||
|
This plugin has no third party dependencies
|
|
@ -0,0 +1 @@
|
||||||
|
This plugin has no third party dependencies
|
25
pom.xml
25
pom.xml
|
@ -57,6 +57,10 @@
|
||||||
<elasticsearch.integ.antfile.default>${elasticsearch.tools.directory}/ant/integration-tests.xml</elasticsearch.integ.antfile.default>
|
<elasticsearch.integ.antfile.default>${elasticsearch.tools.directory}/ant/integration-tests.xml</elasticsearch.integ.antfile.default>
|
||||||
<elasticsearch.integ.antfile>${elasticsearch.integ.antfile.default}</elasticsearch.integ.antfile>
|
<elasticsearch.integ.antfile>${elasticsearch.integ.antfile.default}</elasticsearch.integ.antfile>
|
||||||
|
|
||||||
|
<!-- Properties for the license checker -->
|
||||||
|
<project.licenses.dir>${project.basedir}/licenses</project.licenses.dir>
|
||||||
|
<project.licenses.check_target>${basedir}/target/releases/${project.build.finalName}.zip</project.licenses.check_target>
|
||||||
|
|
||||||
<!-- Test properties -->
|
<!-- Test properties -->
|
||||||
<tests.jvms>auto</tests.jvms>
|
<tests.jvms>auto</tests.jvms>
|
||||||
<tests.shuffle>true</tests.shuffle>
|
<tests.shuffle>true</tests.shuffle>
|
||||||
|
@ -1191,6 +1195,27 @@ org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UT
|
||||||
<goal>run</goal>
|
<goal>run</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check-license</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<skip>${skip.integ.tests}</skip>
|
||||||
|
<target>
|
||||||
|
<echo taskName="license check">Running license check</echo>
|
||||||
|
<!-- don't run on windows, because everyone hates it -->
|
||||||
|
<exec failonerror="true" executable="perl" osfamily="unix"
|
||||||
|
dir="${elasticsearch.tools.directory}/license-check">
|
||||||
|
<arg value="check_license_and_sha.pl"/>
|
||||||
|
<arg value="--check"/>
|
||||||
|
<arg value="${project.licenses.dir}"/>
|
||||||
|
<arg value="${project.licenses.check_target}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
11
qa/pom.xml
11
qa/pom.xml
|
@ -129,6 +129,17 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<!-- Don't run the license checker in qa -->
|
||||||
|
<id>check-license</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
Loading…
Reference in New Issue