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
be2803a7
Commit
be2803a7
authored
Jul 30, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
642224fe
6f8d4778
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
Repackager.java
...ava/org/springframework/boot/loader/tools/Repackager.java
+19
-1
RepackagerTests.java
...rg/springframework/boot/loader/tools/RepackagerTests.java
+16
-0
No files found.
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java
View file @
be2803a7
...
...
@@ -107,6 +107,11 @@ public class Repackager {
if
(
libraries
==
null
)
{
throw
new
IllegalArgumentException
(
"Libraries must not be null"
);
}
if
(
alreadyRepackaged
())
{
return
;
}
destination
=
destination
.
getAbsoluteFile
();
File
workingSource
=
this
.
source
;
if
(
this
.
source
.
equals
(
destination
))
{
...
...
@@ -132,6 +137,19 @@ public class Repackager {
}
}
private
boolean
alreadyRepackaged
()
throws
IOException
{
JarFile
jarFile
=
new
JarFile
(
this
.
source
);
try
{
Manifest
manifest
=
jarFile
.
getManifest
();
return
manifest
!=
null
&&
manifest
.
getMainAttributes
().
getValue
(
BOOT_VERSION_ATTRIBUTE
)
!=
null
;
}
finally
{
jarFile
.
close
();
}
}
private
void
repackage
(
JarFile
sourceJar
,
File
destination
,
Libraries
libraries
)
throws
IOException
{
final
JarWriter
writer
=
new
JarWriter
(
destination
);
...
...
@@ -208,7 +226,7 @@ public class Repackager {
String
launcherClassName
=
this
.
layout
.
getLauncherClassName
();
if
(
launcherClassName
!=
null
)
{
manifest
.
getMainAttributes
()
.
putValue
(
MAIN_CLASS_ATTRIBUTE
,
launcherClassName
);
.
putValue
(
MAIN_CLASS_ATTRIBUTE
,
launcherClassName
);
if
(
startClass
==
null
)
{
throw
new
IllegalStateException
(
"Unable to find main class"
);
}
...
...
spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java
View file @
be2803a7
...
...
@@ -134,6 +134,22 @@ public class RepackagerTests {
assertThat
(
hasLauncherClasses
(
file
),
equalTo
(
true
));
}
@Test
public
void
jarIsOnlyRepackagedOnce
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithMainMethod
.
class
);
File
file
=
this
.
testJarFile
.
getFile
();
Repackager
repackager
=
new
Repackager
(
file
);
repackager
.
repackage
(
NO_LIBRARIES
);
repackager
.
repackage
(
NO_LIBRARIES
);
Manifest
actualManifest
=
getManifest
(
file
);
assertThat
(
actualManifest
.
getMainAttributes
().
getValue
(
"Main-Class"
),
equalTo
(
"org.springframework.boot.loader.JarLauncher"
));
assertThat
(
actualManifest
.
getMainAttributes
().
getValue
(
"Start-Class"
),
equalTo
(
"a.b.C"
));
assertThat
(
hasLauncherClasses
(
file
),
equalTo
(
true
));
}
@Test
public
void
multipleMainClassFound
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithMainMethod
.
class
);
...
...
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