From 65acaf885ba8015705e3e478ec11ec293ad5134c Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Thu, 15 Jan 2015 15:38:24 -0800 Subject: [PATCH] Remove incorrect assumption that output will be in folder named classes When running in Eclipse, by default Gradle builds its output into a folder named bin. This commit update the annotation processor to remove the failure assumption that the output will always be located beneath a folder named classes. Closes gh-2369 See gh-2361 --- .../ConfigurationMetadataAnnotationProcessor.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 304f87fd19b..cd8812c02b6 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -393,9 +393,11 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor // Gradle keeps things separate String path = file.getPath(); int index = path.lastIndexOf(CLASSES_FOLDER); - path = path.substring(0, index) + RESOURCES_FOLDER - + path.substring(index + CLASSES_FOLDER.length()); - file = new File(path); + if (index >= 0) { + path = path.substring(0, index) + RESOURCES_FOLDER + + path.substring(index + CLASSES_FOLDER.length()); + file = new File(path); + } } return (file.exists() ? new FileInputStream(file) : fileObject.toUri().toURL() .openStream());