From b855ab6cae280aa5c46323beb798975cdcbb3542 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 10 Oct 2013 14:28:42 +0100 Subject: [PATCH] Treat Maven artifacts with bundle packaging as jars Previously, LocalM2Resource used the pom's packaging configuration to determine the suffix of the file that it should look for, e.g. if the pom's packaging was jar, it would look for a file with a .jar suffix in artifactExists(). This logic fails for artifacts with bundle packaging as it would look for a .bundle file rather than a .jar file, fail to find the file, and incorrectly report that the artifact does not exist. This commit updates LocalM2Resource to look for a file with a .jar suffix when the packaging configuration in the pom is bundle. --- .../boot/cli/compiler/GrapeEngineCustomizer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineCustomizer.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineCustomizer.java index 7f20562bad..e736b88a0e 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineCustomizer.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineCustomizer.java @@ -50,6 +50,7 @@ import org.apache.ivy.plugins.resolver.IBiblioResolver; import org.apache.ivy.util.AbstractMessageLogger; import org.apache.ivy.util.MessageLogger; import org.springframework.boot.cli.Log; +import org.xml.sax.SAXException; /** * Customizes the groovy grape engine to enhance and patch the behavior of ivy. Can add @@ -258,8 +259,7 @@ class GrapeEngineCustomizer { private boolean artifactExists() { if (this.artifactExists == null) { try { - PomReader reader = new PomReader(getURL(), this); - final String packaging = reader.getPackaging(); + final String packaging = getPackaging(); if ("pom".equals(packaging)) { this.artifactExists = true; } @@ -280,6 +280,15 @@ class GrapeEngineCustomizer { } return this.artifactExists; } + + private String getPackaging() throws IOException, SAXException { + PomReader reader = new PomReader(getURL(), this); + String packaging = reader.getPackaging(); + if ("bundle".equals(packaging)) { + packaging = "jar"; + } + return packaging; + } } }