Skip to content

Commit

Permalink
#19 Declare ourselves as thread safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
smuda committed Dec 5, 2020
1 parent fb9d40c commit 9d3180b
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/it/multithreaded/invoker.properties
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions src/it/multithreaded/licenses.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<licenses>
<valid>
<license>
<name>Parent POM license name</name>
<names>
<name>Parent POM license name</name>
</names>
</license>
<license>
<name>The Apache Software License, Version 2.0</name>
<names>
<name>The Apache Software License, Version 2.0</name>
</names>
<urls>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</urls>
</license>
<license>
<name>New BSD License</name>
<urls>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
</urls>
</license>
</valid>
</licenses>
41 changes: 41 additions & 0 deletions src/it/multithreaded/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>se.ayoy.maven-plugins.its</groupId>
<artifactId>multithreaded</artifactId>
<version>1.0</version>

<licenses>
<license>
<name>Parent POM license name</name>
</license>
</licenses>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>license-check</id>
<phase>initialize</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<requireAllValid>true</requireAllValid>
<failOnMissing>true</failOnMissing>
<failOnWarning>true</failOnWarning>
<licenseFile>${pom.basedir}/licenses.xml</licenseFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
41 changes: 41 additions & 0 deletions src/it/multithreaded/verify.bsh
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

/**
Expand Down

0 comments on commit 9d3180b

Please sign in to comment.