File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
main/java/org/springframework/boot/loader/thin
java/org/springframework/boot/loader/thin
resources/apps/fake.jar/META-INF/maven/com.example/fake Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -140,14 +140,18 @@ public Resource getPom(Archive archive) {
140140 throw new IllegalStateException ("Cannot locate archive" , e );
141141 }
142142 String pattern = "META-INF/maven/**"
143- + (artifactId == null ? "" : "/" + artifactId ) + "/pom.xml" ;
143+ + (artifactId == null || artifactId .length () == 0 ? ""
144+ : "/" + artifactId )
145+ + "/pom.xml" ;
144146 Resource resource = findResource (archive , pattern );
145147 if (resource != null ) {
146148 return resource ;
147149 }
148150 // Spring Boot fat jar
149151 pattern = "BOOT-INF/classes/META-INF/maven/**"
150- + (artifactId == null ? "" : "/" + artifactId ) + "/pom.xml" ;
152+ + (artifactId == null || artifactId .length () == 0 ? ""
153+ : "/" + artifactId )
154+ + "/pom.xml" ;
151155 resource = findResource (archive , pattern );
152156 if (resource != null ) {
153157 return resource ;
@@ -399,6 +403,7 @@ private String extractArtifactId(Archive archive) throws MalformedURLException {
399403 path = path .substring (0 , path .length () - 2 );
400404 }
401405 path = StringUtils .getFilename (path );
406+ path = path .replace (".jar" , "" );
402407 path = path .split ("-[0-9]" )[0 ];
403408 return path ;
404409 }
Original file line number Diff line number Diff line change @@ -135,4 +135,12 @@ public void pomWithMavenArchiveBootInf() throws Exception {
135135 "BOOT-INF/classes/META-INF/maven/org.springframework.boot/spring-boot-cli/pom.xml" );
136136 }
137137
138+ @ Test
139+ public void pomWithUnversionedJar () throws Exception {
140+ Resource resource = resolver .getPom (
141+ new ExplodedArchive (new File ("src/test/resources/apps/fake.jar" )));
142+ assertThat (resource .getURL ().toString ())
143+ .endsWith ("META-INF/maven/com.example/fake/pom.xml" );
144+ }
145+
138146}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
4+ <modelVersion >4.0.0</modelVersion >
5+
6+ <groupId >com.example</groupId >
7+ <artifactId >simple</artifactId >
8+ <version >0.0.1-SNAPSHOT</version >
9+ <packaging >jar</packaging >
10+
11+ <name >simple</name >
12+ <description >Demo project for Spring Boot</description >
13+
14+ </project >
You can’t perform that action at this time.
0 commit comments