From b003c67ae55918ed4711d4a4093e80f690c72caa Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Thu, 2 Jun 2016 11:09:06 -0400 Subject: [PATCH 1/2] zip: Use original ZipException as cause of thrown ZipException Signed-off-by: BJ Hargrave --- biz.aQute.bndlib/src/aQute/bnd/osgi/ZipResource.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/ZipResource.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/ZipResource.java index 1abcdf3c31..ca1a799ba8 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/osgi/ZipResource.java +++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/ZipResource.java @@ -60,9 +60,11 @@ public static ZipFile build(Jar jar, File file, Pattern pattern) throws ZipExcep } } return zip; - } catch (ZipException ze) { - throw new ZipException( - "The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + ze.getMessage()); + } catch (ZipException e) { + ZipException ze = new ZipException( + "The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + e.getMessage()); + ze.initCause(e); + throw ze; } catch (FileNotFoundException e) { throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath()); } From eca20f5da819d23ce9ad8b3318f85e3dc12fdf4e Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Thu, 2 Jun 2016 11:29:56 -0400 Subject: [PATCH 2/2] gradle: bundle task type did not handle plain files in configuration With a configuration set up using files: dependencies { compile files('lib/foo.jar') } The jar is not in the resolvedConfiguration. See we now use the getFiles method on Configuration and then probe each file to make sure it is a zip file before sending adding to the builder class path. Closes https://github.com/bndtools/bnd/issues/1484 Signed-off-by: BJ Hargrave --- .../aQute/bnd/gradle/BundleTaskConvention.groovy | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy index 82675de26e..636c0a8013 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy @@ -21,6 +21,8 @@ package aQute.bnd.gradle import java.util.Properties import java.util.jar.Manifest +import java.util.zip.ZipException +import java.util.zip.ZipFile import aQute.bnd.osgi.Builder import aQute.bnd.osgi.Constants @@ -144,7 +146,16 @@ class BundleTaskConvention { builder.setJar(archiveCopyJar) // set builder classpath - def buildpath = project.files(configuration.resolvedConfiguration.resolvedArtifacts.findAll{it.type == 'jar'}*.file) + def buildpath = project.files(configuration.files.findAll { file -> + try { + new ZipFile(file).withCloseable { zip -> + zip.entries() // make sure it is a valid zip file and not a pom + } + } catch (ZipException e) { + return false + } + return true + }) builder.setProperty('project.buildpath', buildpath.asPath) builder.setClasspath(buildpath as File[]) logger.debug 'builder classpath: {}', builder.getClasspath()*.getSource()