You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2011/04/20 19:06:58 UTC

DO NOT REPLY [Bug 51096] New: jar task, nested element "service" not merged

https://issues.apache.org/bugzilla/show_bug.cgi?id=51096

           Summary: jar task, nested element "service" not merged
           Product: Ant
           Version: 1.8.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: nam3l3ssa@freemail.hu


Using multiple services in different jar files, then using a single jar file,
eg.

Let there be a service "X", and let there be providers Alpha,Beta,Gamma.

A.jar contains provider Alpha
B.jar contains provider Beta

C.jar provides provides Gamma, and includes A.jar and B.jar as zipfilesets.

I would except it to be possible to create C.jar in a way that the service
descriptor files are merged, but this does not seem to be the case. With either
of the jar task's manifest affecting options, the result is separate files in
the archive, with the same filename.

>From what I have seen so far, only the "duplicate" property affects the
resulting descrpitor files, but it does not have the option to merge, so it's
of no use.

When creating the jar file C.jar, there are (in case duplicate is not on
"preserve") multiple entries of the same descriptor file, as the format allows
this; however, the ServiceLoader only parses the first such file, causing
failures in some of my applications.

My current workaround is simply to extract the jar files, manually rearrange
the service descriptors, then repackage them.

Am I doing someting wrong? Is it possible to alter the build file so the
service descriptors are merged?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51096] jar task, nested element "service" not merged

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51096

Jesse Glick <jg...@netbeans.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jglick@netbeans.org

--- Comment #3 from Jesse Glick <jg...@netbeans.org> 2011-04-21 18:02:18 EDT ---
(In reply to comment #1)
> Since the zip format does permit same-named entries, are you sure that C.jar
> isn't still capable of providing multiple service provider implementations
> despite these actually being represented in different jar entries?

sun.misc.URLClassPath.JarLoader.getResource can only return one resource, since
it is using JarFile.getJarEntry. Iterating all entries would be inefficient,
and there is no method in JarFile to get multiple entries with the same name.

Probably there is some way to write the script to concatenate
META-INF/services/* entries from its inputs, but it does not sound easy. Maybe
use a custom task - either a subclass of Zip which overrides zipFile and knows
how to merge these entries, or set duplicate=add and then run a separate task
to merge entries in the result.

In general it would be nice to have a helper type ResourceMerger, which you
could pass to <zip>, <copy>, etc.; one impl could simply concatenate the
incoming resources, but custom impls could perform more complex merges.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51096] jar task, nested element "service" not merged

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51096

--- Comment #1 from Matt Benson <mb...@apache.org> 2011-04-20 13:32:08 EDT ---
Since the zip format does permit same-named entries, are you sure that C.jar
isn't still capable of providing multiple service provider implementations
despite these actually being represented in different jar entries?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51096] jar task, nested element "service" not merged

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51096

--- Comment #2 from Nam3l3ss <na...@freemail.hu> 2011-04-21 17:47:10 EDT ---
I'm practically sure, but I'll create a presentable test case as soon as I have
some time.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.