Package com.lingocoder.jar
Class JarHelper
- java.lang.Object
-
- com.lingocoder.jar.JarHelper
-
public class JarHelper extends java.lang.ObjectProvidesjar-related support toJarExecPluginand its related tests.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckExecutable(java.io.File aJar)Determine whether the given file refers to an executablejar.JarCreationResultcreateExecutable(java.nio.file.Path mainClassRootDir, java.util.Optional<java.lang.String> packageOfMainClass, java.lang.String nameOfMainClass)Produce an executablejar.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.
-
-
-
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 GradleProjectwithin which this instance will be used.
-
-
Method Detail
-
checkExecutable
public boolean checkExecutable(java.io.File aJar)
Determine whether the given file refers to an executablejar.- Parameters:
aJar- AFilethat refers to ajarfile.- Returns:
trueif theaJarparam refers to an executablejar; Otherwise,false.
-
createExecutable
public JarCreationResult createExecutable(java.nio.file.Path mainClassRootDir, java.util.Optional<java.lang.String> packageOfMainClass, java.lang.String nameOfMainClass)
Produce an executablejar.- Parameters:
mainClassRootDir- The location of theMain-Classintended to be the entry point of the resultingjar.packageOfMainClass- AnOptionalpackage theMain-ClassMAY be a member of.nameOfMainClass- The name of theMain-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:classifieris optional.- Returns:
- If found, the artifact specified by the given
coordinates; wrapped in anOptional. Otherwise,Optional.empty().
-
-