[maven-android-developers] Adding files to META-INF

300 views
Skip to first unread message

Marc Dugger

unread,
Apr 29, 2010, 9:58:10 AM4/29/10
to Maven Android Developers
I'm attempting to use Jersey within Android. Jersey requires service
provider files in META-INF/services. The following does not work:

<resource>
<directory>src/main/resources</directory>
<targetPath>META-INF/services</targetPath>
<includes>
<include>javax.ws.rs.ext.MessageBodyReader</include>
<include>javax.ws.rs.ext.MessageBodyWriter</include>
<include>com.sun.jersey.spi.HeaderDelegateProvider</include>
<include>com.sun.jersey.spi.inject.InjectableProvider</
include>
</includes>
</resource>

Can it be done?

--
You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
To post to this group, send email to maven-androi...@googlegroups.com.
To unsubscribe from this group, send email to maven-android-deve...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/maven-android-developers?hl=en.

Manfred Moser (simpligility)

unread,
Apr 30, 2010, 11:54:25 PM4/30/10
to Maven Android Developers
I dont know anything about Jersey but does it really need that on the
client side? In any case you are going to have trouble adding javax
classes to an Android app. This will not work unless you repackge them
into a different package.

Fabrizio Giudici

unread,
May 1, 2010, 3:57:38 AM5/1/10
to maven-androi...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 5/1/10 05:54 , Manfred Moser (simpligility) wrote:
> I dont know anything about Jersey but does it really need that on
> the client side? In any case you are going to have trouble adding
> javax classes to an Android app. This will not work unless you
> repackge them into a different package.
Yes, but repackaging (e.g. with Shade) seems to work, at least in my
case (not using Jersey, but other javax.* stuff). The most serious
problem, if I understand well - also answering to my own question - is
that ClassLoader.gerResource() seems not to work in Android -
confirmed? This is the facility that Java relies on for reading
META-INF stuff.

- --
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio...@tidalwave.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvb3vAACgkQeDweFqgUGxeAnwCfWuiGnPyljO1fzLtVSI0KMmu5
/bgAn0IVlZFxmY5YGmATO9pI9LBPd7T9
=1DA2
-----END PGP SIGNATURE-----

Fabrizio Giudici

unread,
May 1, 2010, 3:57:39 AM5/1/10
to maven-androi...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 5/1/10 05:54 , Manfred Moser (simpligility) wrote:

Yes, but repackaging (e.g. with Shade) seems to work, at least in my
case (not using Jersey, but other javax.* stuff). The most serious
problem, if I understand well - also answering to my own question - is
that ClassLoader.gerResource() seems not to work in Android -
confirmed? This is the facility that Java relies on for reading
META-INF stuff.

- --
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio...@tidalwave.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvb0sQACgkQeDweFqgUGxewLQCfSeOydfqKXnCsxQcPR7VBaaDp
ZDkAoKkhwRfwk8hHbVnVdElh1mvAeqjJ
=JE0d
-----END PGP SIGNATURE-----

Marc Dugger

unread,
May 2, 2010, 1:02:49 PM5/2/10
to maven-androi...@googlegroups.com
Fabrizio,

Can you share how you configured the Shade plugin in your pom.xml?  Jersey relies on javax.* interfaces.  Thanks in advance.


On Sat, May 1, 2010 at 2:57 AM, Fabrizio Giudici <fabrizio...@tidalwave.it> wrote:

Yes, but repackaging (e.g. with Shade) seems to work
 
--
Marc Dugger
mdu...@gmail.com
Twitter: realtybaron

Fabrizio Giudici

unread,
May 2, 2010, 2:09:48 PM5/2/10
to maven-androi...@googlegroups.com, Marc Dugger
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 5/2/10 19:02 , Marc Dugger wrote:
> Fabrizio,
>
> Can you share how you configured the Shade plugin in your pom.xml?
> Jersey relies on javax.* interfaces. Thanks in advance.
>
>
> On Sat, May 1, 2010 at 2:57 AM, Fabrizio Giudici
> <fabrizio...@tidalwave.it
> <mailto:fabrizio...@tidalwave.it>> wrote:
>
>
> Yes, but repackaging (e.g. with Shade) seems to work
>
>
>
Yep, the project is open sourced. Clonable with Mercurial (or browsable
online) at https://kenai.com/hg/bluebill-mobile~android-src - look at
the module modules/LookupForAndroid.

I'm including here the pom of that module. It's doing two things:

+ relocating all references to javax.swing.* to
it.tidalwave.javax.swing.* where I copy-pasted the single javax.swing
class that I need (at the moment).
+ excluding the class org.netbeans.modules.openide.util.ActiveQueue
from the original artifact (org-openide-util), relocating all the
references to it.tidalwave.netbeans.modules.openide.util.ActiveQueue
where I put a patched version.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>it.tidalwave.thesefoolishthings</groupId>
<artifactId>superpom</artifactId>
<version>1.0.7</version>
</parent>

<groupId>it.tidalwave.bluebill.android</groupId>
<artifactId>it-tidalwave-android-org-openide-util</artifactId>
<version>RELEASE68</version>
<packaging>jar</packaging>
<name>Lookup for Android</name>

<dependencies>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>RELEASE68</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>

<artifact>org.netbeans.api:org-openide-util</artifact>
<excludes>

<exclude>org/netbeans/modules/openide/util/ActiveQueue.class</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>javax.swing</pattern>

<shadedPattern>it.tidalwave.javax.swing</shadedPattern>
</relocation>
<relocation>

<pattern>org.netbeans.modules.openide.util.ActiveQueue</pattern>

<shadedPattern>it.tidalwave.netbeans.modules.openide.util.ActiveQueue</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>




- --
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio...@tidalwave.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvdv+kACgkQeDweFqgUGxewggCgq/XM8p650MIGykiupNAjTab7
L4cAoLOGlP8KEA5BSYJoIqdNTu6yBcmp
=P2+1
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages