Package com.lingocoder.jar
Class JarHelper
- java.lang.Object
-
- com.lingocoder.jar.JarHelper
-
public class JarHelper extends java.lang.Object
Providesjar
-related support toJarExecPlugin
and its related tests.
-
-
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 executablejar
.JarCreationResult
createExecutable(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 GradleProject
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 executablejar
.- Parameters:
aJar
- AFile
that refers to ajar
file.- Returns:
true
if theaJar
param 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-Class
intended to be the entry point of the resultingjar
.packageOfMainClass
- AnOptional
package theMain-Class
MAY 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:classifier
is optional.- Returns:
- If found, the artifact specified by the given
coordinates
; wrapped in anOptional
. Otherwise,Optional.empty()
.
-
-