Class CacheUtils

java.lang.Object
org.apache.maven.buildcache.CacheUtils

public class CacheUtils extends Object
Cache Utils
  • Constructor Details

    • CacheUtils

      public CacheUtils()
  • Method Details

    • isPom

      public static boolean isPom(org.apache.maven.project.MavenProject project)
    • isPom

      public static boolean isPom(org.apache.maven.model.Dependency dependency)
    • isSnapshot

      public static boolean isSnapshot(String version)
    • normalizedName

      public static String normalizedName(org.apache.maven.artifact.Artifact artifact)
    • mojoExecutionKey

      public static String mojoExecutionKey(org.apache.maven.plugin.MojoExecution mojo)
    • getMultimoduleRoot

      public static Path getMultimoduleRoot(org.apache.maven.execution.MavenSession session)
    • readGitInfo

      public static Scm readGitInfo(org.apache.maven.execution.MavenSession session) throws IOException
      Throws:
      IOException
    • getLast

      public static <T> T getLast(List<T> list)
    • isArchive

      public static boolean isArchive(File file)
    • zip

      public static boolean zip(Path dir, Path zip, String glob, boolean preservePermissions) throws IOException
      Put every matching files of a directory in a zip.
      Parameters:
      dir - directory to zip
      zip - zip to populate
      glob - glob to apply to filenames
      preservePermissions - whether to preserve Unix file permissions in the zip.

      Important: When true, permissions are stored in ZIP entry headers, which means they become part of the ZIP file's binary content. As a result, hashing the ZIP file (e.g., for cache keys) will include permission information, ensuring cache invalidation when file permissions change. This behavior is similar to how Git includes file mode in tree hashes.

      Returns:
      true if at least one file has been included in the zip.
      Throws:
      IOException
    • unzip

      public static void unzip(Path zip, Path out, boolean preservePermissions) throws IOException
      Throws:
      IOException
    • debugPrintCollection

      public static <T> void debugPrintCollection(org.slf4j.Logger logger, Collection<T> values, String heading, String elementCaption)