Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
59b8fc63
Commit
59b8fc63
authored
Jul 31, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scan for a valid MANIFEST.MF instead of taking the first one
Fixes gh-1321
parent
bacbff1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
PackagedSpringApplicationLauncher.java
...ework/boot/cli/jar/PackagedSpringApplicationLauncher.java
+16
-4
No files found.
spring-boot-cli/src/main/java/org/springframework/boot/cli/jar/PackagedSpringApplicationLauncher.java
View file @
59b8fc63
...
@@ -19,6 +19,7 @@ package org.springframework.boot.cli.jar;
...
@@ -19,6 +19,7 @@ package org.springframework.boot.cli.jar;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.net.URLClassLoader
;
import
java.util.Enumeration
;
import
java.util.jar.Manifest
;
import
java.util.jar.Manifest
;
/**
/**
...
@@ -31,6 +32,8 @@ public class PackagedSpringApplicationLauncher {
...
@@ -31,6 +32,8 @@ public class PackagedSpringApplicationLauncher {
public
static
final
String
SOURCE_MANIFEST_ENTRY
=
"Spring-Application-Source-Classes"
;
public
static
final
String
SOURCE_MANIFEST_ENTRY
=
"Spring-Application-Source-Classes"
;
public
static
final
String
MAIN_CLASS_MANIFEST_ENTRY
=
"Start-Class"
;
private
static
final
String
SPRING_APPLICATION_CLASS
=
"org.springframework.boot.SpringApplication"
;
private
static
final
String
SPRING_APPLICATION_CLASS
=
"org.springframework.boot.SpringApplication"
;
private
void
run
(
String
[]
args
)
throws
Exception
{
private
void
run
(
String
[]
args
)
throws
Exception
{
...
@@ -42,10 +45,19 @@ public class PackagedSpringApplicationLauncher {
...
@@ -42,10 +45,19 @@ public class PackagedSpringApplicationLauncher {
}
}
private
Object
[]
getSources
(
URLClassLoader
classLoader
)
throws
Exception
{
private
Object
[]
getSources
(
URLClassLoader
classLoader
)
throws
Exception
{
URL
url
=
classLoader
.
findResource
(
"META-INF/MANIFEST.MF"
);
for
(
Enumeration
<
URL
>
urls
=
classLoader
.
findResources
(
"META-INF/MANIFEST.MF"
);
urls
Manifest
manifest
=
new
Manifest
(
url
.
openStream
());
.
hasMoreElements
();)
{
String
attribute
=
manifest
.
getMainAttributes
().
getValue
(
SOURCE_MANIFEST_ENTRY
);
URL
url
=
urls
.
nextElement
();
return
loadClasses
(
classLoader
,
attribute
.
split
(
","
));
Manifest
manifest
=
new
Manifest
(
url
.
openStream
());
if
(
getClass
().
getName
().
equals
(
manifest
.
getMainAttributes
().
getValue
(
MAIN_CLASS_MANIFEST_ENTRY
)))
{
String
attribute
=
manifest
.
getMainAttributes
().
getValue
(
SOURCE_MANIFEST_ENTRY
);
return
loadClasses
(
classLoader
,
attribute
.
split
(
","
));
}
}
throw
new
IllegalStateException
(
"Cannot locate "
+
SOURCE_MANIFEST_ENTRY
+
" in MANIFEST.MF"
);
}
}
private
Class
<?>[]
loadClasses
(
ClassLoader
classLoader
,
String
[]
names
)
private
Class
<?>[]
loadClasses
(
ClassLoader
classLoader
,
String
[]
names
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment