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
5ed4ef12
Commit
5ed4ef12
authored
Feb 19, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add manifest entries for location of lib and classes in executable archives
Closes gh-5183
parent
59e119eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
2 deletions
+46
-2
antlib.xml
...rc/main/resources/org/springframework/boot/ant/antlib.xml
+2
-0
Repackager.java
...ava/org/springframework/boot/loader/tools/Repackager.java
+10
-0
RepackagerTests.java
...rg/springframework/boot/loader/tools/RepackagerTests.java
+27
-0
TestJarFile.java
...va/org/springframework/boot/loader/tools/TestJarFile.java
+7
-2
No files found.
spring-boot-tools/spring-boot-antlib/src/main/resources/org/springframework/boot/ant/antlib.xml
View file @
5ed4ef12
...
@@ -74,6 +74,8 @@
...
@@ -74,6 +74,8 @@
<attribute
name=
"Main-Class"
<attribute
name=
"Main-Class"
value=
"org.springframework.boot.loader.JarLauncher"
/>
value=
"org.springframework.boot.loader.JarLauncher"
/>
<attribute
name=
"Start-Class"
value=
"${start-class}"
/>
<attribute
name=
"Start-Class"
value=
"${start-class}"
/>
<attribute
name=
"Spring-Boot-Classes"
value=
"BOOT-INF/classes/"
/>
<attribute
name=
"Spring-Boot-Lib"
value=
"BOOT-INF/lib/"
/>
</manifest>
</manifest>
</jar>
</jar>
</sequential>
</sequential>
...
...
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java
View file @
5ed4ef12
...
@@ -45,6 +45,10 @@ public class Repackager {
...
@@ -45,6 +45,10 @@ public class Repackager {
private
static
final
String
BOOT_VERSION_ATTRIBUTE
=
"Spring-Boot-Version"
;
private
static
final
String
BOOT_VERSION_ATTRIBUTE
=
"Spring-Boot-Version"
;
private
static
final
String
BOOT_LIB_ATTRIBUTE
=
"Spring-Boot-Lib"
;
private
static
final
String
BOOT_CLASSES_ATTRIBUTE
=
"Spring-Boot-Classes"
;
private
static
final
byte
[]
ZIP_FILE_HEADER
=
new
byte
[]
{
'P'
,
'K'
,
3
,
4
};
private
static
final
byte
[]
ZIP_FILE_HEADER
=
new
byte
[]
{
'P'
,
'K'
,
3
,
4
};
private
String
mainClass
;
private
String
mainClass
;
...
@@ -282,6 +286,12 @@ public class Repackager {
...
@@ -282,6 +286,12 @@ public class Repackager {
}
}
String
bootVersion
=
getClass
().
getPackage
().
getImplementationVersion
();
String
bootVersion
=
getClass
().
getPackage
().
getImplementationVersion
();
manifest
.
getMainAttributes
().
putValue
(
BOOT_VERSION_ATTRIBUTE
,
bootVersion
);
manifest
.
getMainAttributes
().
putValue
(
BOOT_VERSION_ATTRIBUTE
,
bootVersion
);
manifest
.
getMainAttributes
().
putValue
(
BOOT_CLASSES_ATTRIBUTE
,
(
this
.
layout
instanceof
RepackagingLayout
)
?
((
RepackagingLayout
)
this
.
layout
).
getRepackagedClassesLocation
()
:
this
.
layout
.
getClassesLocation
());
manifest
.
getMainAttributes
().
putValue
(
BOOT_LIB_ATTRIBUTE
,
this
.
layout
.
getLibraryDestination
(
""
,
LibraryScope
.
COMPILE
));
return
manifest
;
return
manifest
;
}
}
...
...
spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java
View file @
5ed4ef12
...
@@ -370,6 +370,33 @@ public class RepackagerTests {
...
@@ -370,6 +370,33 @@ public class RepackagerTests {
.
containsKey
(
new
Attributes
.
Name
(
"Spring-Boot-Version"
));
.
containsKey
(
new
Attributes
.
Name
(
"Spring-Boot-Version"
));
}
}
@Test
public
void
executableJarLayoutAttributes
()
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
);
Manifest
actualManifest
=
getManifest
(
file
);
assertThat
(
actualManifest
.
getMainAttributes
())
.
containsEntry
(
new
Attributes
.
Name
(
"Spring-Boot-Lib"
),
"BOOT-INF/lib/"
);
assertThat
(
actualManifest
.
getMainAttributes
()).
containsEntry
(
new
Attributes
.
Name
(
"Spring-Boot-Classes"
),
"BOOT-INF/classes/"
);
}
@Test
public
void
executableWarLayoutAttributes
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"WEB-INF/classes/a/b/C.class"
,
ClassWithMainMethod
.
class
);
File
file
=
this
.
testJarFile
.
getFile
(
"war"
);
Repackager
repackager
=
new
Repackager
(
file
);
repackager
.
repackage
(
NO_LIBRARIES
);
Manifest
actualManifest
=
getManifest
(
file
);
assertThat
(
actualManifest
.
getMainAttributes
())
.
containsEntry
(
new
Attributes
.
Name
(
"Spring-Boot-Lib"
),
"WEB-INF/lib/"
);
assertThat
(
actualManifest
.
getMainAttributes
()).
containsEntry
(
new
Attributes
.
Name
(
"Spring-Boot-Classes"
),
"WEB-INF/classes/"
);
}
@Test
@Test
public
void
nullCustomLayout
()
throws
Exception
{
public
void
nullCustomLayout
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithoutMainMethod
.
class
);
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithoutMainMethod
.
class
);
...
...
spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java
View file @
5ed4ef12
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -31,6 +31,7 @@ import org.zeroturnaround.zip.ZipUtil;
...
@@ -31,6 +31,7 @@ import org.zeroturnaround.zip.ZipUtil;
/**
/**
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
*/
*/
public
class
TestJarFile
{
public
class
TestJarFile
{
...
@@ -121,8 +122,12 @@ public class TestJarFile {
...
@@ -121,8 +122,12 @@ public class TestJarFile {
}
}
public
File
getFile
()
throws
IOException
{
public
File
getFile
()
throws
IOException
{
return
getFile
(
"jar"
);
}
public
File
getFile
(
String
extension
)
throws
IOException
{
File
file
=
this
.
temporaryFolder
.
newFile
();
File
file
=
this
.
temporaryFolder
.
newFile
();
file
=
new
File
(
file
.
getParent
(),
file
.
getName
()
+
".
jar"
);
file
=
new
File
(
file
.
getParent
(),
file
.
getName
()
+
".
"
+
extension
);
ZipUtil
.
pack
(
this
.
jarSource
,
file
);
ZipUtil
.
pack
(
this
.
jarSource
,
file
);
return
file
;
return
file
;
}
}
...
...
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