1
1
package io .cucumber .core .resource ;
2
2
3
+ import io .cucumber .core .exception .CucumberException ;
3
4
import io .cucumber .core .logging .Logger ;
4
5
import io .cucumber .core .logging .LoggerFactory ;
5
6
@@ -118,7 +119,7 @@ static class JarUriFileSystemService {
118
119
private static final String FILE_URI_SCHEME = "file" ;
119
120
private static final String JAR_URI_SCHEME = "jar" ;
120
121
private static final String JAR_URI_SCHEME_PREFIX = JAR_URI_SCHEME + ":" ;
121
- private static final String JAR_FILE_EXTENSION = ".jar" ;
122
+ private static final String JAR_FILE_SUFFIX = ".jar" ;
122
123
private static final String JAR_URI_SEPARATOR = "!" ;
123
124
124
125
private static CloseablePath createForJarFileSystem (URI jarUri , Function <FileSystem , Path > pathProvider )
@@ -135,6 +136,9 @@ static boolean supports(URI uri) {
135
136
static CloseablePath create (URI uri ) throws URISyntaxException , IOException {
136
137
if (hasJarUriScheme (uri )) {
137
138
String [] parts = uri .toString ().split (JAR_URI_SEPARATOR );
139
+ if (parts .length > 2 ) {
140
+ throw nestedJarEntriesAreUnsupported (uri );
141
+ }
138
142
String jarUri = parts [0 ];
139
143
String jarEntry = parts [1 ];
140
144
return createForJarFileSystem (new URI (jarUri ), fileSystem -> fileSystem .getPath (jarEntry ));
@@ -147,8 +151,20 @@ static CloseablePath create(URI uri) throws URISyntaxException, IOException {
147
151
return null ;
148
152
}
149
153
154
+ private static CucumberException nestedJarEntriesAreUnsupported (URI uri ) {
155
+ return new CucumberException ("" +
156
+ "The resource " + uri + " is located in a nested jar.\n " +
157
+ "\n " +
158
+ "This typically happens when trying to run Cucumber inside a Spring Boot Executable Jar.\n " +
159
+ "Cucumber currently doesn't support classpath scanning in nested jars.\n " +
160
+ "Feel free to send a pull request to make this possible!\n " +
161
+ "\n " +
162
+ "You can avoid this error by unpacking your application or glue code before executing."
163
+ );
164
+ }
165
+
150
166
private static boolean hasFileUriSchemeWithJarExtension (URI uri ) {
151
- return FILE_URI_SCHEME .equals (uri .getScheme ()) && uri .getPath ().endsWith (JAR_FILE_EXTENSION );
167
+ return FILE_URI_SCHEME .equals (uri .getScheme ()) && uri .getPath ().endsWith (JAR_FILE_SUFFIX );
152
168
}
153
169
154
170
private static boolean hasJarUriScheme (URI uri ) {
0 commit comments