Skip to content

Help with combining stuff in META-INF/ for use in an uber .jar#18

Merged
hinerm merged 9 commits into
masterfrom
combine-annotations
Dec 20, 2013
Merged

Help with combining stuff in META-INF/ for use in an uber .jar#18
hinerm merged 9 commits into
masterfrom
combine-annotations

Conversation

@dscho

@dscho dscho commented Dec 18, 2013

Copy link
Copy Markdown
Contributor

When making one single uber .jar from a multitude of dependencies, we need not only take care of annotation indexes (including legacy ones), but also of the entries in META-INF/services/.

It is much more robust to use ClassLoader's getResources() method than
trying to iterate the class path elements extracted from the
java.class.path property, especially when running via exec-maven-plugin
(which does not have the relevant .jar files in the system class path).

While at it, look for both modern and legacy annotations, but return only
file names prefixed with the modern prefix in getAnnotationFiles().

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Instead of reading all the JSON-formatted indexes ourselves, we can simply
ask the Index class to get all of them for us, including the legacy
annotation indexes, and then write them out using the existing
infrastructure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho and others added 5 commits December 20, 2013 14:52
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This trick was performed by:

	mvn license:update-file-header

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Created a new interface: Combiner - and extracted the service combining
logic from MetaInfCombiner to a new ServiceCombiner (which implements
Combiner).

The purpose of MetaInfCombiner is now purely to run both the
ServiceCombiner and CombineAnnotations classes.
The org.scijava.annotations CombineAnnotations class now
implements the Combiner interface.

It was refactored to remove state, allowing its combine method to now
take any output directory (instead of requiring constructing a new
instance for each output dir).

The class was renamed to AnnotationCombiner to fit the naming scheme of
MetaInfCombiner and ServiceCombiner.

The org.scijava.util.CombineAnnotations class was updated to use the
refactored AnnotationCombiner API.
hinerm added a commit that referenced this pull request Dec 20, 2013
When making one single uber .jar from a multitude of dependencies, we need not only take care of annotation indexes (including legacy ones), but also of the entries in META-INF/services/.
@hinerm hinerm merged commit 19cbedc into master Dec 20, 2013
@hinerm hinerm deleted the combine-annotations branch December 20, 2013 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants