[GRADLE-904] Gradle creates invalid / non-standard conform jars? Created: 12/Apr/10 Updated: 04/Jan/13 Resolved: 24/Nov/10 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.8, 0.9 |
Fix Version/s: | 0.9-rc-1 |
Type: | Bug | ||
Reporter: | Lars Heuer | Assignee: | Adam Murdoch |
Resolution: | Fixed | Votes: | 1 |
Attachments: | gradle-osgi-ds.zip |
Description |
I have problems to use the OSGi Declarative Service (Karaf) together with a Gradle created jar. I have a directory OSGI-INF in main/resources/ and an XML file which describes the OSGi service. I added to build.gradle: jar { } but Apache Karaf is not able to discover the service automatically. Does Gradle create non-standard jars? |
Comments |
Comment by Lars Heuer [ 16/Apr/10 ] |
The attached project creates 2 jars (gradle build). One is created by Gradle, the other one by Ant (core-antgenerated). Drop one after the other into the karaf/deploy directory. You'll see that only the Ant-generated jar is detected by Apache Karaf <http://apache.mirror.clusters.cc/felix/apache-felix-karaf-1.4.0.zip>, and that the Gradle-gernerated jar produces no output at the console. |
Comment by Lars Heuer [ 07/May/10 ] |
This issue is not OSGi Declarative Service specific. |
Comment by Bryan Keller [ 14/Jun/10 ] |
I am encountering the same issue with Apache Felix. I believe the problem is that Gradle is simply zipping the files without paying attention to the order of the file headers. With jar, the first file header in the zip file should be the manifest. I believe this is why Felix is not recognizing the jar file as a bundle, because it doesn't locate the manifest where it thinks it should be. As a work around, in jar.doLast I am unzipping the jar Gradle created, and repackaging it using ant.jar. |
Comment by Bryan Keller [ 14/Jun/10 ] |
FYI, this problem also affects the war task, if you are using something like Pax Web to load wars as bundles. Basically both the Gradle jar and war tasks should use the equivalent Ant tasks, or be changed to behave the same way, rather than just zip the files to create the jar and war file. |
Comment by Lars Heuer [ 14/Jun/10 ] |
Good point, Bryan. Why not use the Ant tasks? Why does Gradle implement its own jar-packing mechanism? |
Comment by Adam Murdoch [ 16/Jun/10 ] |
Gradle uses the same Ant archive classes that the Ant tasks use. We don't use the tasks because they don't offer the flexibility which we want. However, the Ant tasks are just wrappers over the Ant archive classes, which we do use. |
Comment by Adam Murdoch [ 16/Jun/10 ] |
Moved the manifest to be the first entry in the JAR. Thanks for helping hunt this problem down. |