Class JarHelper


  • public class JarHelper
    extends java.lang.Object
    Provides jar-related support to JarExecPlugin and its related tests.
    • Constructor Summary

      Constructors 
      Constructor Description
      JarHelper()
      Create an instance with default state.
      JarHelper​(org.gradle.api.Project project)
      Create an instance that will be used within a task of a Gradle build script.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkExecutable​(java.io.File aJar)
      Determine whether the given file refers to an executable jar.
      JarCreationResult createExecutable​(java.nio.file.Path mainClassRootDir, java.util.Optional<java.lang.String> packageOfMainClass, java.lang.String nameOfMainClass)
      Produce an executable jar.
      java.util.Optional<java.io.File> fetch​(java.lang.String coordinates)
      Retrieve a previously-resolved jar dependency from the file system cache of a locally-installed dependency management system.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JarHelper

        public JarHelper()
        Create an instance with default state.
      • JarHelper

        public JarHelper​(org.gradle.api.Project project)
        Create an instance that will be used within a task of a Gradle build script.
        Parameters:
        project - The Gradle Project within which this instance will be used.
    • Method Detail

      • checkExecutable

        public boolean checkExecutable​(java.io.File aJar)
        Determine whether the given file refers to an executable jar.
        Parameters:
        aJar - A File that refers to a jar file.
        Returns:
        true if the aJar param refers to an executable jar; Otherwise, false.
      • createExecutable

        public JarCreationResult createExecutable​(java.nio.file.Path mainClassRootDir,
                                                  java.util.Optional<java.lang.String> packageOfMainClass,
                                                  java.lang.String nameOfMainClass)
        Produce an executable jar.
        Parameters:
        mainClassRootDir - The location of the Main-Class intended to be the entry point of the resulting jar.
        packageOfMainClass - An Optional package the Main-Class MAY be a member of.
        nameOfMainClass - The name of the Main-Class. The name can be given either with or without the .class extension.
        Returns:
        A composite result that contains — among other things — the location of the executable jar.
      • fetch

        public java.util.Optional<java.io.File> fetch​(java.lang.String coordinates)

        Retrieve a previously-resolved jar dependency from the file system cache of a locally-installed dependency management system. Maven or Gradle, for example.

        The prerequisite of „previously-resolved“ means this operation's guaranteed success in returning the requested dependency requires the module to have been configured as a dependency in the consumer project's build script.

        Parameters:
        coordinates - A non-empty, colon-delimited string of the form: „group:artifact:version[:classifier]“. The :classifier is optional.
        Returns:
        If found, the artifact specified by the given coordinates; wrapped in an Optional. Otherwise, Optional.empty().