diff options
Diffstat (limited to 'version-manifest/src/main')
-rw-r--r-- | version-manifest/src/main/java/org/onap/integration/versionmanifest/VersionCheckMojo.java | 45 | ||||
-rw-r--r-- | version-manifest/src/main/resources/java-manifest.csv | 2 |
2 files changed, 34 insertions, 13 deletions
diff --git a/version-manifest/src/main/java/org/onap/integration/versionmanifest/VersionCheckMojo.java b/version-manifest/src/main/java/org/onap/integration/versionmanifest/VersionCheckMojo.java index 5d4e9a8fa..d6e5d4ca6 100644 --- a/version-manifest/src/main/java/org/onap/integration/versionmanifest/VersionCheckMojo.java +++ b/version-manifest/src/main/java/org/onap/integration/versionmanifest/VersionCheckMojo.java @@ -17,6 +17,7 @@ package org.onap.integration.versionmanifest; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.nio.charset.StandardCharsets; @@ -25,12 +26,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Properties; import java.util.Set; import java.util.TreeSet; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; -import org.apache.maven.model.Dependency; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; @@ -59,7 +61,17 @@ public class VersionCheckMojo extends AbstractMojo { public void execute() throws MojoExecutionException { final Log log = getLog(); - log.info("Checking version manifest " + manifest); + final Properties gitProps = new Properties(); + try (InputStream in = getClass().getResourceAsStream("/git.properties")) { + gitProps.load(in); + } catch (IOException e) { + log.error(e); + throw new MojoExecutionException(e.getMessage()); + } + + log.info("Manifest version: " + gitProps.getProperty("git.build.time") + " " + + gitProps.getProperty("git.commit.id") + " " + gitProps.getProperty("git.remote.origin.url")); + log.info(""); final List<String> groupIdPrefixes = Arrays.asList("org.onap", "org.openecomp", "org.openo"); @@ -88,24 +100,31 @@ public class VersionCheckMojo extends AbstractMojo { final MavenProject parent = project.getParent(); if (parent != null) { log.debug("Parent: " + parent); - actualVersions.put(parent.getGroupId() + ":" + parent.getArtifactId(), parent.getVersion()); + // don't warn within the same groupId + if (!project.getGroupId().equals(parent.getGroupId())) { + actualVersions.put(parent.getGroupId() + ":" + parent.getArtifactId(), parent.getVersion()); + } } else { log.debug("No parent"); } - for (Dependency dep : project.getDependencies()) { - log.debug("Dependency: " + dep.toString()); - actualVersions.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); + for (Artifact dep : project.getDependencyArtifacts()) { + log.debug("DependencyArtifact: " + dep.toString()); + // don't warn within the same groupId + if (!project.getGroupId().equals(dep.getGroupId())) { + actualVersions.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); + } } final Set<String> mismatches = new TreeSet<>(); final Set<String> missingArtifacts = new TreeSet<>(); - for (Entry<String, String> actualVersion : actualVersions.entrySet()) { - String artifact = actualVersion.getKey(); + for (Entry<String, String> actualVersionEntry : actualVersions.entrySet()) { + String artifact = actualVersionEntry.getKey(); + String actualVersion = actualVersionEntry.getValue(); String expectedVersion = expectedVersions.get(artifact); if (expectedVersion == null) { - if (artifact.startsWith("org.onap") || artifact.startsWith("org.openecomp")) { + if (groupIdPrefixes.stream().anyMatch(prefix -> artifact.startsWith(prefix))) { missingArtifacts.add(artifact); } } else if (!expectedVersion.equals(actualVersion)) { @@ -132,17 +151,19 @@ public class VersionCheckMojo extends AbstractMojo { log.warn(String.format(format, artifact, actualVersion, expectedVersion)); } } + log.warn(""); } - log.info(""); - if (!missingArtifacts.isEmpty()) { + if (missingArtifacts.isEmpty()) { + log.debug("No artifacts found missing in the version manifest"); + } else { log.warn("The following dependencies are missing in the version manifest:"); for (String artifact : missingArtifacts) { String actualVersion = actualVersions.get(artifact); log.warn(String.format(format, artifact, actualVersion, "?")); } + log.warn(""); } - log.info(""); } } diff --git a/version-manifest/src/main/resources/java-manifest.csv b/version-manifest/src/main/resources/java-manifest.csv index 8baa86884..f6bb6ec29 100644 --- a/version-manifest/src/main/resources/java-manifest.csv +++ b/version-manifest/src/main/resources/java-manifest.csv @@ -1,2 +1,2 @@ groupId,artifactId,version -org.onap.oparent,oparent,0.1.0 +org.onap.oparent,oparent,0.1.1 |