Class JarGenerator
java.lang.Object
org.jdrupes.builder.core.AbstractProvider
org.jdrupes.builder.core.AbstractGenerator
org.jdrupes.builder.java.JarGenerator
- All Implemented Interfaces:
Generator, ResourceProvider
- Direct Known Subclasses:
JavadocJarGenerator, LibraryGenerator, SourcesJarGenerator
A general purpose generator for jars. All contents must be added
explicitly using
add(Entry...) or add(FileTree...).-
Field Summary
Fields inherited from class AbstractProvider
log -
Constructor Summary
ConstructorsConstructorDescriptionJarGenerator(Project project, ResourceType<? extends JarFile> jarType) Instantiates a new library generator. -
Method Summary
Modifier and TypeMethodDescriptionadd(Map.Entry<Path, ? extends IOResource>... entries) Convenience method for adding a single entry, seeaddEntries(Stream).Convenience method for adding entries, seeaddTrees(Stream).addEntries(Stream<? extends Map.Entry<Path, ? extends IOResource>> entries) Adds single resources to the jar.Adds the givenFileTrees.final JarGeneratorattributes(Map.Entry<Attributes.Name, String>... attributes) Add the given attributes to the manifest.attributes(Stream<Map.Entry<Attributes.Name, String>> attributes) Add the given attributes to the manifest.protected voidBuilds the jar.protected voidAdds the resources from the given file tree to the given contents.protected voidcollectContents(Map<Path, Resources<IOResource>> contents) Add the contents from the added streams as preliminary jar entries.Returns the destination directory.destination(Path destination) Sets the destination directory.destination(Supplier<Path> destination) Sets the destination directory.doProvide(ResourceRequest<T> requested) Invoked byAbstractProvider.provide(ResourceRequest)after checking if the invocation is allowed.jarName()Returns the name of the generated jar file.Sets the name of the generated jar file.Sets the supplier for obtaining the name of the generated jar file inAbstractProvider.provide(ResourceRequest).protected voidresolveDuplicates(Map<Path, Resources<IOResource>> entries) Resolve duplicates.Methods inherited from class AbstractGenerator
cleanup, name, name, newResource, project, toStringMethods inherited from class AbstractProvider
provideMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
provide
-
Constructor Details
-
JarGenerator
Instantiates a new library generator.- Parameters:
project- the projectjarType- the type of jar that the generator generates
-
-
Method Details
-
destination
Returns the destination directory. Defaults to sub directorylibsin the project's build directory (seeProject.buildDirectory()).- Returns:
- the destination
-
destination
Sets the destination directory. ThePathis resolved against the project's build directory (seeProject.buildDirectory()).- Parameters:
destination- the new destination- Returns:
- the jar generator
-
destination
Sets the destination directory.- Parameters:
destination- the new destination- Returns:
- the jar generator
-
jarName
-
jarName
Sets the supplier for obtaining the name of the generated jar file inAbstractProvider.provide(ResourceRequest).- Parameters:
jarName- the jar name- Returns:
- the jar generator
-
jarName
Sets the name of the generated jar file.- Parameters:
jarName- the jar name- Returns:
- the jar generator
-
attributes
Add the given attributes to the manifest.- Parameters:
attributes- the attributes- Returns:
- the library generator
-
attributes
Add the given attributes to the manifest.- Parameters:
attributes- the attributes- Returns:
- the library generator
-
addEntries
Adds single resources to the jar. Each entry is added to the jar as entry with the name passed in the key attribute of theMap.Entrywith the content from theIOResourcein the value attribute.- Parameters:
entries- the entries- Returns:
- the jar generator
-
addTrees
Adds the givenFileTrees. Each file in the tree will be added as an entry using its relative path in the tree as name.- Parameters:
trees- the trees- Returns:
- the jar generator
-
add
Convenience method for adding entries, seeaddTrees(Stream).- Parameters:
trees- the trees- Returns:
- the jar generator
-
add
Convenience method for adding a single entry, seeaddEntries(Stream).- Parameters:
entries- the entry- Returns:
- the jar generator
-
buildJar
-
collectContents
Add the contents from the added streams as preliminary jar entries. Must be overridden by derived classes that define additional ways to provide contents. The overriding method must invokesuper.collectEntries(...).- Parameters:
contents- the preliminary contents
-
collect
-
resolveDuplicates
Resolve duplicates. The default implementation outputs a warning and skips the duplicate entry.- Parameters:
entries- the entries
-
doProvide
Description copied from class:AbstractProviderInvoked byAbstractProvider.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the requested- Returns:
- the stream
-