Class VersionUtil

java.lang.Object
com.thirtysevenaudits.util.VersionUtil

public final class VersionUtil extends Object
Resolves the Maven project version for a class's artifact. Tries, in order:
  1. Implementation-Version from the main section of META-INF/MANIFEST.MF for the JAR or directory that contains the anchor class
  2. Package.getImplementationVersion() for the anchor class's package
  3. META-INF/maven/.../pom.properties (version key) on the classpath
Typical Maven JARs include both manifest entries (when configured) and pom.properties.
  • Method Details

    • resolveVersion

      public static String resolveVersion(Class<?> anchor)
      Same as resolveVersion(Class, String, String) using this module's Maven coordinates.
    • resolveVersion

      public static String resolveVersion(Class<?> anchor, String groupId, String artifactId)
      Parameters:
      groupId - Maven groupId (used to locate pom.properties)
      artifactId - Maven artifactId
      Returns:
      the resolved version, or "unknown" if nothing could be read