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
c0bcb5e8
Commit
c0bcb5e8
authored
Nov 20, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add layout=NONE to packaging tools
parent
06c16ae4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
9 deletions
+53
-9
SpringBootPluginExtension.groovy
...ingframework/boot/gradle/SpringBootPluginExtension.groovy
+1
-1
Layouts.java
...n/java/org/springframework/boot/loader/tools/Layouts.java
+12
-0
Repackager.java
...ava/org/springframework/boot/loader/tools/Repackager.java
+11
-5
RepackagerTests.java
...rg/springframework/boot/loader/tools/RepackagerTests.java
+24
-0
RepackageMojo.java
...in/java/org/springframework/boot/maven/RepackageMojo.java
+5
-3
No files found.
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy
View file @
c0bcb5e8
...
@@ -38,7 +38,7 @@ import org.springframework.boot.loader.tools.Layouts
...
@@ -38,7 +38,7 @@ import org.springframework.boot.loader.tools.Layouts
public
class
SpringBootPluginExtension
{
public
class
SpringBootPluginExtension
{
static
enum
LayoutType
{
static
enum
LayoutType
{
JAR
(
new
Layouts
.
Jar
()),
WAR
(
new
Layouts
.
War
()),
ZIP
(
new
Layouts
.
Expanded
()),
DIR
(
new
Layouts
.
Expanded
());
JAR
(
new
Layouts
.
Jar
()),
WAR
(
new
Layouts
.
War
()),
ZIP
(
new
Layouts
.
Expanded
()),
DIR
(
new
Layouts
.
Expanded
())
,
NONE
(
new
Layouts
.
None
())
;
Layout
layout
;
Layout
layout
;
private
LayoutType
(
Layout
layout
)
{
private
LayoutType
(
Layout
layout
)
{
this
.
layout
=
layout
;
this
.
layout
=
layout
;
...
...
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java
View file @
c0bcb5e8
...
@@ -25,6 +25,7 @@ import java.util.Map;
...
@@ -25,6 +25,7 @@ import java.util.Map;
* Common {@link Layout}s.
* Common {@link Layout}s.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
*/
*/
public
class
Layouts
{
public
class
Layouts
{
...
@@ -82,6 +83,17 @@ public class Layouts {
...
@@ -82,6 +83,17 @@ public class Layouts {
}
}
/**
* Executable expanded archive layout.
*/
public
static
class
None
extends
Jar
{
@Override
public
String
getLauncherClassName
()
{
return
null
;
}
}
/**
/**
* Executable WAR layout.
* Executable WAR layout.
*/
*/
...
...
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java
View file @
c0bcb5e8
...
@@ -172,12 +172,18 @@ public class Repackager {
...
@@ -172,12 +172,18 @@ public class Repackager {
startClass
=
MainClassFinder
.
findMainClass
(
source
,
startClass
=
MainClassFinder
.
findMainClass
(
source
,
this
.
layout
.
getClassesLocation
());
this
.
layout
.
getClassesLocation
());
}
}
String
launcherClassName
=
this
.
layout
.
getLauncherClassName
();
if
(
launcherClassName
!=
null
)
{
manifest
.
getMainAttributes
()
.
putValue
(
MAIN_CLASS_ATTRIBUTE
,
launcherClassName
);
if
(
startClass
==
null
)
{
if
(
startClass
==
null
)
{
throw
new
IllegalStateException
(
"Unable to find main class"
);
throw
new
IllegalStateException
(
"Unable to find main class"
);
}
}
manifest
.
getMainAttributes
().
putValue
(
MAIN_CLASS_ATTRIBUTE
,
this
.
layout
.
getLauncherClassName
());
manifest
.
getMainAttributes
().
putValue
(
START_CLASS_ATTRIBUTE
,
startClass
);
manifest
.
getMainAttributes
().
putValue
(
START_CLASS_ATTRIBUTE
,
startClass
);
}
else
if
(
startClass
!=
null
)
{
manifest
.
getMainAttributes
().
putValue
(
MAIN_CLASS_ATTRIBUTE
,
startClass
);
}
String
bootVersion
=
getClass
().
getPackage
().
getImplementationVersion
();
String
bootVersion
=
getClass
().
getPackage
().
getImplementationVersion
();
manifest
.
getMainAttributes
().
putValue
(
BOOT_VERSION_ATTRIBUTE
,
bootVersion
);
manifest
.
getMainAttributes
().
putValue
(
BOOT_VERSION_ATTRIBUTE
,
bootVersion
);
...
...
spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java
View file @
c0bcb5e8
...
@@ -138,6 +138,30 @@ public class RepackagerTests {
...
@@ -138,6 +138,30 @@ public class RepackagerTests {
new
Repackager
(
this
.
testJarFile
.
getFile
()).
repackage
(
NO_LIBRARIES
);
new
Repackager
(
this
.
testJarFile
.
getFile
()).
repackage
(
NO_LIBRARIES
);
}
}
@Test
public
void
noMainClassAndLayoutIsNone
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithMainMethod
.
class
);
File
file
=
this
.
testJarFile
.
getFile
();
Repackager
repackager
=
new
Repackager
(
file
);
repackager
.
setLayout
(
new
Layouts
.
None
());
repackager
.
repackage
(
file
,
NO_LIBRARIES
);
Manifest
actualManifest
=
getManifest
(
file
);
assertThat
(
actualManifest
.
getMainAttributes
().
getValue
(
"Main-Class"
),
equalTo
(
"a.b.C"
));
}
@Test
public
void
noMainClassAndLayoutIsNoneWithNoMain
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithoutMainMethod
.
class
);
File
file
=
this
.
testJarFile
.
getFile
();
Repackager
repackager
=
new
Repackager
(
file
);
repackager
.
setLayout
(
new
Layouts
.
None
());
repackager
.
repackage
(
file
,
NO_LIBRARIES
);
Manifest
actualManifest
=
getManifest
(
file
);
assertThat
(
actualManifest
.
getMainAttributes
().
getValue
(
"Main-Class"
),
equalTo
(
null
));
}
@Test
@Test
public
void
sameSourceAndDestinationWithBackup
()
throws
Exception
{
public
void
sameSourceAndDestinationWithBackup
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithMainMethod
.
class
);
this
.
testJarFile
.
addClass
(
"a/b/C.class"
,
ClassWithMainMethod
.
class
);
...
...
spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java
View file @
c0bcb5e8
...
@@ -36,7 +36,9 @@ import org.springframework.boot.loader.tools.Repackager;
...
@@ -36,7 +36,9 @@ import org.springframework.boot.loader.tools.Repackager;
/**
/**
* MOJO that can can be used to repackage existing JAR and WAR archives so that they can
* MOJO that can can be used to repackage existing JAR and WAR archives so that they can
* be executed from the command line using {@literal java -jar}.
* be executed from the command line using {@literal java -jar}. With
* <code>layout=NONE</code> can also be used simply to package a JAR with nested
* dependencies (and no main class, so not executable).
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
* @author Dave Syer
...
@@ -84,7 +86,7 @@ public class RepackageMojo extends AbstractMojo {
...
@@ -84,7 +86,7 @@ public class RepackageMojo extends AbstractMojo {
private
String
mainClass
;
private
String
mainClass
;
/**
/**
* The layout to use (JAR, WAR, ZIP, DIR) in case it cannot be inferred.
* The layout to use (JAR, WAR, ZIP, DIR
, NONE
) in case it cannot be inferred.
*/
*/
@Parameter
@Parameter
private
LayoutType
layout
;
private
LayoutType
layout
;
...
@@ -126,7 +128,7 @@ public class RepackageMojo extends AbstractMojo {
...
@@ -126,7 +128,7 @@ public class RepackageMojo extends AbstractMojo {
public
static
enum
LayoutType
{
public
static
enum
LayoutType
{
JAR
(
new
Layouts
.
Jar
()),
WAR
(
new
Layouts
.
War
()),
ZIP
(
new
Layouts
.
Expanded
()),
DIR
(
JAR
(
new
Layouts
.
Jar
()),
WAR
(
new
Layouts
.
War
()),
ZIP
(
new
Layouts
.
Expanded
()),
DIR
(
new
Layouts
.
Expanded
());
new
Layouts
.
Expanded
())
,
NONE
(
new
Layouts
.
None
())
;
private
Layout
layout
;
private
Layout
layout
;
public
Layout
layout
()
{
public
Layout
layout
()
{
...
...
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