From 9d3180b03e69db598eb5ace6669f6c6855dc4429 Mon Sep 17 00:00:00 2001 From: John Allberg Date: Sat, 5 Dec 2020 15:01:16 +0100 Subject: [PATCH] #19 Declare ourselves as thread safe. --- src/it/multithreaded/invoker.properties | 20 +++++++++ src/it/multithreaded/licenses.xml | 26 ++++++++++++ src/it/multithreaded/pom.xml | 41 +++++++++++++++++++ src/it/multithreaded/verify.bsh | 41 +++++++++++++++++++ .../licenseverifier/LicenseVerifierMojo.java | 3 +- 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/it/multithreaded/invoker.properties create mode 100644 src/it/multithreaded/licenses.xml create mode 100644 src/it/multithreaded/pom.xml create mode 100644 src/it/multithreaded/verify.bsh diff --git a/src/it/multithreaded/invoker.properties b/src/it/multithreaded/invoker.properties new file mode 100644 index 0000000..42731af --- /dev/null +++ b/src/it/multithreaded/invoker.properties @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +invoker.buildResult=success +invoker.goals = -T2 clean verify diff --git a/src/it/multithreaded/licenses.xml b/src/it/multithreaded/licenses.xml new file mode 100644 index 0000000..5b80bce --- /dev/null +++ b/src/it/multithreaded/licenses.xml @@ -0,0 +1,26 @@ + + + + + Parent POM license name + + Parent POM license name + + + + The Apache Software License, Version 2.0 + + The Apache Software License, Version 2.0 + + + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + New BSD License + + http://www.opensource.org/licenses/bsd-license.php + + + + diff --git a/src/it/multithreaded/pom.xml b/src/it/multithreaded/pom.xml new file mode 100644 index 0000000..cac4fe6 --- /dev/null +++ b/src/it/multithreaded/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + se.ayoy.maven-plugins.its + multithreaded + 1.0 + + + + Parent POM license name + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + license-check + initialize + + verify + + + + + true + true + true + true + ${pom.basedir}/licenses.xml + + + + + diff --git a/src/it/multithreaded/verify.bsh b/src/it/multithreaded/verify.bsh new file mode 100644 index 0000000..04253b1 --- /dev/null +++ b/src/it/multithreaded/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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. + */ + +import java.io.*; +import java.util.*; +import java.nio.file.Files; + +try { + File file = new File(basedir, "build.log"); + if (!file.exists() || file.isDirectory()) { + System.err.println("Could not find 'build.log': " + file); + return false; + } + + String log = new String(Files.readAllBytes(file.toPath())); + + if (log.contains("The following plugins are not marked @threadSafe in multithreaded:")) { + return false; + } +} catch (IOException e) { + e.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/se/ayoy/maven/plugins/licenseverifier/LicenseVerifierMojo.java b/src/main/java/se/ayoy/maven/plugins/licenseverifier/LicenseVerifierMojo.java index 3cff250..f3b5b21 100644 --- a/src/main/java/se/ayoy/maven/plugins/licenseverifier/LicenseVerifierMojo.java +++ b/src/main/java/se/ayoy/maven/plugins/licenseverifier/LicenseVerifierMojo.java @@ -3,6 +3,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.License; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.InstantiationStrategy; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.DefaultProjectBuildingRequest; @@ -25,7 +26,7 @@ * Validate the licenses against a list of known good. * */ -@Mojo(name = "verify") +@Mojo(name = "verify", instantiationStrategy = InstantiationStrategy.PER_LOOKUP, threadSafe = true) public class LicenseVerifierMojo extends LicenseAbstractMojo { /**