[java-mvn-enforcer] 03/05: JPAR-190 Investigate an enforcer to check all jars and poms ~/.m2/.... towards the end of a build
Rod Widdowson
rdw at steadingsoftware.com
Sun Oct 10 13:34:37 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-mvn-enforcer.
View the commit online:
http://git.shibboleth.net/view/?p=java-mvn-enforcer.git;a=commit;h=f75fd189db3887e5ab5f7d140680b39379f170a0
commit f75fd189db3887e5ab5f7d140680b39379f170a0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Oct 7 16:07:29 2021 +0100
JPAR-190 Investigate an enforcer to check all jars and poms ~/.m2/.... towards the end of a build
https://shibboleth.atlassian.net/browse/JPAR-190
Handle the three artifacts which have stanged name garnishes ("no aop").
---
.../shibboleth/mvn/enforcer/impl/JarEnforcer.java | 13 ++++++++--
.../shibboleth/mvn/enforcer/impl/M2SigChecker.java | 29 ++++++++++++++++++----
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java b/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
index 8991eb3..5ab80df 100644
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
+++ b/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
@@ -134,9 +134,18 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
pool.initialize();
try (final ProjectPomContext pomContext = new ProjectPomContext(this,
- EnforcerLogger.getLogger(ProjectPomContext.class), pool, Path.of(enforcerData), tmp, map)) {
+ EnforcerLogger.getLogger(ProjectPomContext.class), pool, Path.of(enforcerData), tmp, map)) {
pomContext.initialize(pom);
+
+ final File out2 = target.resolve("m2SignatureReport.txt").toFile();
+ try (final PrintWriter report2 =
+ new PrintWriter(new BufferedOutputStream(new FileOutputStream(out2)))) {
+ report2.format("M2 Signature Testing started at %s\n\n", Instant.now().toString());
+ final M2SigChecker chk = new M2SigChecker(pomContext, report2);
+ chk.testSignatures(Path.of("c:/users/rdw/.m2/repository"));
+ }
+
boolean depdendencyResult = true;
if (checkDependencies) {
final File out = target.resolve("dependencyReport.txt").toFile();
@@ -155,7 +164,7 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
boolean signatureResult = true;
if (checkSignatures) {
- final File out = target.resolve("signatureReport.txt").toFile();
+ final File out = target.resolve("signatureReport.txt").toFile();
try (final PrintWriter report =
new PrintWriter(new BufferedOutputStream(new FileOutputStream(out)))) {
report.format("Signature Testing started at %s\n\n", Instant.now().toString());
diff --git a/src/main/java/net/shibboleth/mvn/enforcer/impl/M2SigChecker.java b/src/main/java/net/shibboleth/mvn/enforcer/impl/M2SigChecker.java
index 9cd535f..5e48374 100644
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/M2SigChecker.java
+++ b/src/main/java/net/shibboleth/mvn/enforcer/impl/M2SigChecker.java
@@ -30,6 +30,8 @@ import javax.annotation.Nonnull;
import org.slf4j.Logger;
+import net.shibboleth.mvn.enforcer.impl.ParsedPom.PomArtifact;
+
/**
* A class to traverse over the provided ~/.m2 directory looking for jar files
* and testing their signatures.
@@ -76,17 +78,34 @@ public class M2SigChecker extends BaseSigChecker {
fileName.endsWith("-javadoc.jar") ) {
return result;
}
- final String rootName = fileName.substring(0, fileName.length() - ".jar".length());
- final Path pomPath = file.getParent().resolve(rootName + ".pom");
+ String rootName = fileName.substring(0, fileName.length() - ".jar".length());
+ Path pomPath = file.getParent().resolve(rootName + ".pom");
+ // hack for sisu-guice
+ String versionExtra = "";
+ if (!Files.exists(pomPath)) {
+ if (rootName.endsWith("-no_aop")) {
+ rootName = rootName.substring(0, rootName.length() - "-no_aop".length());
+ versionExtra = "-no_aop";
+ } else if (rootName.endsWith("-noaop")) {
+ rootName = rootName.substring(0, rootName.length() - "-noaop".length());
+ versionExtra = "-noaop";
+ }
+ pomPath = file.getParent().resolve(rootName + ".pom");
+ }
final ParsedPom pom ;
try {
pom = new ParsedPom(getProjectContext().getParserPool(), getMavenLoader(), pomPath, "rootName", null, Collections.emptyMap());
- } catch (Exception e) {
- log.error("Could not parse pom for {} ", pomPath, e);
+ } catch (final Exception e) {
+ log.error("Could not parse pom for " + pomPath.toString(), e);
failCount ++;
return result;
}
- if (!checkSignature(file, pom.getOurInfo())) {
+ PomArtifact info = pom.getOurInfo();
+ if (!"".equals(versionExtra)) {
+ info = pom.new PomArtifact(info.getGroupId(), info.getArtifactId(), info.getVersion() + versionExtra);
+ }
+
+ if (!checkSignature(file, info)) {
failCount ++;
}
return result;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list