From d4d9ebcabd2be691d4a839d7b3797f88745e478e Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 15 Oct 2013 09:56:52 -0400 Subject: [PATCH] Small re-org of PropertiesLauncher --- .../org/springframework/boot/git.properties | 14 +++--- .../org/springframework/boot/git.properties | 14 +++--- .../boot/loader/PropertiesLauncher.java | 46 +++++++++++-------- .../org/springframework/boot/git.properties | 14 +++--- .../org/springframework/boot/git.properties | 14 +++--- 5 files changed, 55 insertions(+), 47 deletions(-) diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties index b86db7116b..b1d21be0ec 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties @@ -1,13 +1,13 @@ #Generated by Git-Commit-Id-Plugin -#Mon Oct 14 16:04:34 EDT 2013 -git.commit.id.abbrev=b0c54a6 +#Tue Oct 15 09:46:33 EDT 2013 +git.commit.id.abbrev=be12635 git.commit.user.email=dsyer@gopivotal.com -git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n -git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc -git.commit.message.short=Add parent class loader entries if possible +git.commit.message.full=Ensure env vars are consulted for PATH\n +git.commit.id=be1263500df0c363ad45c0ccf387e4c06e6f5c7d +git.commit.message.short=Ensure env vars are consulted for PATH git.commit.user.name=Dave Syer git.build.user.name=Dave Syer git.build.user.email=dsyer@gopivotal.com git.branch=master -git.commit.time=2013-10-14T16\:02\:04-0400 -git.build.time=2013-10-14T16\:04\:34-0400 +git.commit.time=2013-10-14T16\:07\:50-0400 +git.build.time=2013-10-15T09\:46\:33-0400 diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties index 24bd75bd16..020deee2b2 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties @@ -1,13 +1,13 @@ #Generated by Git-Commit-Id-Plugin -#Mon Oct 14 16:04:26 EDT 2013 -git.commit.id.abbrev=b0c54a6 +#Tue Oct 15 09:46:12 EDT 2013 +git.commit.id.abbrev=be12635 git.commit.user.email=dsyer@gopivotal.com -git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n -git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc -git.commit.message.short=Add parent class loader entries if possible +git.commit.message.full=Ensure env vars are consulted for PATH\n +git.commit.id=be1263500df0c363ad45c0ccf387e4c06e6f5c7d +git.commit.message.short=Ensure env vars are consulted for PATH git.commit.user.name=Dave Syer git.build.user.name=Dave Syer git.build.user.email=dsyer@gopivotal.com git.branch=master -git.commit.time=2013-10-14T16\:02\:04-0400 -git.build.time=2013-10-14T16\:04\:26-0400 +git.commit.time=2013-10-14T16\:07\:50-0400 +git.build.time=2013-10-15T09\:46\:12-0400 diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 26b66ef008..2d0fb8154d 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -300,31 +300,39 @@ public class PropertiesLauncher extends Launcher { protected List getClassPathArchives() throws Exception { List lib = new ArrayList(); for (String path : this.paths) { - String root = cleanupPath(stripFileUrlPrefix(path)); - File file = new File(root); - if (!root.startsWith("/")) { - file = new File(this.home, root); - } - if (file.isDirectory()) { - this.logger.info("Adding classpath entries from " + path); - Archive archive = new ExplodedArchive(file); - lib.addAll(archive.getNestedArchives(new EntryFilter() { - @Override - public boolean matches(Entry entry) { - return entry.isDirectory() || entry.getName().endsWith(".jar") - || entry.getName().endsWith(".zip"); - } - })); - lib.add(0, archive); - } - else { - this.logger.info("No directory found at " + path); + for (Archive archive : getClassPathArchives(path)) { + List nested = new ArrayList( + archive.getNestedArchives(new EntryFilter() { + @Override + public boolean matches(Entry entry) { + return entry.isDirectory() + || entry.getName().endsWith(".jar") + || entry.getName().endsWith(".zip"); + } + })); + nested.add(0, archive); + lib.addAll(nested); } } addParentClassLoaderEntries(lib); return lib; } + private List getClassPathArchives(String path) { + String root = cleanupPath(stripFileUrlPrefix(path)); + List lib = new ArrayList(); + File file = new File(root); + if (!root.startsWith("/")) { + file = new File(this.home, root); + } + if (file.isDirectory()) { + this.logger.info("Adding classpath entries from " + file); + Archive archive = new ExplodedArchive(file); + lib.add(archive); + } + return lib; + } + private void addParentClassLoaderEntries(List lib) throws IOException, URISyntaxException { ClassLoader parentClassLoader = getClass().getClassLoader(); diff --git a/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties index 04887cb5de..a2c6cdffe3 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties +++ b/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties @@ -1,13 +1,13 @@ #Generated by Git-Commit-Id-Plugin -#Mon Oct 14 16:04:25 EDT 2013 -git.commit.id.abbrev=b0c54a6 +#Tue Oct 15 09:45:47 EDT 2013 +git.commit.id.abbrev=be12635 git.commit.user.email=dsyer@gopivotal.com -git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n -git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc -git.commit.message.short=Add parent class loader entries if possible +git.commit.message.full=Ensure env vars are consulted for PATH\n +git.commit.id=be1263500df0c363ad45c0ccf387e4c06e6f5c7d +git.commit.message.short=Ensure env vars are consulted for PATH git.commit.user.name=Dave Syer git.build.user.name=Dave Syer git.build.user.email=dsyer@gopivotal.com git.branch=master -git.commit.time=2013-10-14T16\:02\:04-0400 -git.build.time=2013-10-14T16\:04\:25-0400 +git.commit.time=2013-10-14T16\:07\:50-0400 +git.build.time=2013-10-15T09\:45\:47-0400 diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties index 9e7ac3ecbe..501bb10374 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties @@ -1,13 +1,13 @@ #Generated by Git-Commit-Id-Plugin -#Mon Oct 14 16:04:29 EDT 2013 -git.commit.id.abbrev=b0c54a6 +#Tue Oct 15 09:46:13 EDT 2013 +git.commit.id.abbrev=be12635 git.commit.user.email=dsyer@gopivotal.com -git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n -git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc -git.commit.message.short=Add parent class loader entries if possible +git.commit.message.full=Ensure env vars are consulted for PATH\n +git.commit.id=be1263500df0c363ad45c0ccf387e4c06e6f5c7d +git.commit.message.short=Ensure env vars are consulted for PATH git.commit.user.name=Dave Syer git.build.user.name=Dave Syer git.build.user.email=dsyer@gopivotal.com git.branch=master -git.commit.time=2013-10-14T16\:02\:04-0400 -git.build.time=2013-10-14T16\:04\:29-0400 +git.commit.time=2013-10-14T16\:07\:50-0400 +git.build.time=2013-10-15T09\:46\:13-0400