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
342bced1
Commit
342bced1
authored
Feb 01, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
parents
b4e890c3
2650a07d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
7 deletions
+51
-7
BootJar.java
...g/springframework/boot/gradle/tasks/bundling/BootJar.java
+4
-2
BootWar.java
...g/springframework/boot/gradle/tasks/bundling/BootWar.java
+4
-1
AbstractBootArchiveTests.java
.../boot/gradle/tasks/bundling/AbstractBootArchiveTests.java
+25
-1
Repackager.java
...ava/org/springframework/boot/loader/tools/Repackager.java
+3
-2
RepackagerTests.java
...rg/springframework/boot/loader/tools/RepackagerTests.java
+15
-1
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java
View file @
342bced1
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -55,13 +55,15 @@ public class BootJar extends Jar implements BootArchive {
getMainSpec
().
with
(
this
.
bootInf
);
this
.
bootInf
.
into
(
"classes"
,
classpathFiles
(
File:
:
isDirectory
));
this
.
bootInf
.
into
(
"lib"
,
classpathFiles
(
File:
:
isFile
));
this
.
bootInf
.
filesMatching
(
"module-info.class"
,
(
details
)
->
{
details
.
setRelativePath
(
details
.
getRelativeSourcePath
());
});
}
private
Action
<
CopySpec
>
classpathFiles
(
Spec
<
File
>
filter
)
{
return
(
copySpec
)
->
copySpec
.
from
((
Callable
<
Iterable
<
File
>>)
()
->
(
this
.
classpath
!=
null
)
?
this
.
classpath
.
filter
(
filter
)
:
Collections
.
emptyList
());
}
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java
View file @
342bced1
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -54,6 +54,9 @@ public class BootWar extends War implements BootArchive {
(
copySpec
)
->
copySpec
.
from
(
(
Callable
<
Iterable
<
File
>>)
()
->
(
this
.
providedClasspath
!=
null
)
?
this
.
providedClasspath
:
Collections
.
emptyList
()));
getRootSpec
().
filesMatching
(
"module-info.class"
,
(
details
)
->
{
details
.
setRelativePath
(
details
.
getRelativeSourcePath
());
});
}
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java
View file @
342bced1
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -133,6 +133,30 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
}
}
@Test
public
void
moduleInfoClassIsPackagedInTheRootOfTheArchive
()
throws
IOException
{
this
.
task
.
setMainClassName
(
"com.example.Main"
);
File
classpathFolder
=
this
.
temp
.
newFolder
();
File
moduleInfoClass
=
new
File
(
classpathFolder
,
"module-info.class"
);
moduleInfoClass
.
getParentFile
().
mkdirs
();
moduleInfoClass
.
createNewFile
();
File
applicationClass
=
new
File
(
classpathFolder
,
"com/example/Application.class"
);
applicationClass
.
getParentFile
().
mkdirs
();
applicationClass
.
createNewFile
();
this
.
task
.
classpath
(
classpathFolder
);
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
classesPath
+
"/com/example/Application.class"
))
.
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
"com/example/Application.class"
)).
isNull
();
assertThat
(
jarFile
.
getEntry
(
"module-info.class"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
classesPath
+
"/module-info.class"
))
.
isNull
();
}
}
@Test
public
void
classpathCanBeSetUsingAFileCollection
()
throws
IOException
{
this
.
task
.
setMainClassName
(
"com.example.Main"
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java
View file @
342bced1
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -381,7 +381,8 @@ public class Repackager {
}
if
((
entry
.
getName
().
startsWith
(
"META-INF/"
)
&&
!
entry
.
getName
().
equals
(
"META-INF/aop.xml"
))
||
entry
.
getName
().
startsWith
(
"BOOT-INF/"
))
{
||
entry
.
getName
().
startsWith
(
"BOOT-INF/"
)
||
entry
.
getName
().
equals
(
"module-info.class"
))
{
return
entry
;
}
JarArchiveEntry
renamedEntry
=
new
JarArchiveEntry
(
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java
View file @
342bced1
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -661,6 +661,20 @@ public class RepackagerTests {
repackager
.
repackage
(
dest
,
NO_LIBRARIES
);
}
@Test
public
void
moduleInfoClassRemainsInRootOfJarWhenRepackaged
()
throws
Exception
{
this
.
testJarFile
.
addClass
(
"A.class"
,
ClassWithMainMethod
.
class
);
this
.
testJarFile
.
addClass
(
"module-info.class"
,
ClassWithoutMainMethod
.
class
);
File
source
=
this
.
testJarFile
.
getFile
();
File
dest
=
this
.
temporaryFolder
.
newFile
(
"dest.jar"
);
Repackager
repackager
=
new
Repackager
(
source
);
repackager
.
repackage
(
dest
,
NO_LIBRARIES
);
try
(
JarFile
jarFile
=
new
JarFile
(
dest
))
{
assertThat
(
jarFile
.
getEntry
(
"module-info.class"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
"BOOT-INF/classes/module-info.class"
)).
isNull
();
}
}
private
File
createLibrary
()
throws
IOException
{
TestJarFile
library
=
new
TestJarFile
(
this
.
temporaryFolder
);
library
.
addClass
(
"com/example/library/Library.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