188 Commits

Author SHA1 Message Date
Phillip Webb
951d0b0fdf Fix exploded jar classloader issues
Fix a bug in `ExplodedURLClassLoader` and merge the code into the
existing `LaunchedURLClassLoader` class. Also polish a few method
names relating to layer support.

See gh-19848
See gh-19767
2020-01-22 12:56:14 -08:00
Phillip Webb
73a42050d6 Add jarmode support to the loader code
Update the `Launcher` class to allow a packaged jar to be  launched in
a different mode. The launcher now checks for a `jarmode` property and
attempts to find a `JarMode` implementation using the standard
`spring.factories` mechanism.

Closes gh-19848
2020-01-22 01:23:11 -08:00
Madhura Bhave
e9d61bac75 Support generation and loading of layered jars
Support an alternative fat jar format that is more amenable to Docker
image layers.

The new format arranges files in the following structure:

	BOOT-INF/
	  layers/
	    <layer-name #1>
	      /classes
	      /lib
	    <layer-name #2>
	      /classes
	      /lib

The `BOOT-INF/layers.idx` file provides the names of the layers and the
order in which they should be added (starting with the least changed).

The `JarLauncher` class can load layered jars in both fat and exploded
forms.

Closes gh-19767

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-01-15 23:32:58 -08:00
Madhura Bhave
45b1ab46c3 Add classpath index support for exploded archives
Update the `Repackager` class so that an additional `classpath.idx` file
is written into the jar that provides the original order of the
classpath. The `JarLauncher` class now uses this file when running as
an exploded archive to ensure that the classpath order is the same as
when running from the far jar.

Closes gh-9128

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-01-15 23:31:17 -08:00
Phillip Webb
ad72f86bdb Polish loader and loader-tools
Polish and refactor `spring-boot-loader` and `spring-boot-loader-tools`
to make it easier to add indexing and layering support.

Closes gh-19766
2020-01-15 23:29:11 -08:00
Andy Wilkinson
56e30258fb Merge branch '2.2.x' 2020-01-15 20:45:42 +00:00
Andy Wilkinson
b7e250eb04 Merge branch '2.1.x' into 2.2.x 2020-01-15 20:45:24 +00:00
Andy Wilkinson
ebebe09a9d Fix file handle leak in JarFileTests
The JarFile was not being closed which linked a file handle and caused
a test failure on Windows.

The local variable has been renamed as, when declared in a
try-with-resources, Checkstyle was confused by the shadowing of the
jarFile field and required references to jarFile within the try-block
the be prefixed with this.

See gh-19595
2020-01-15 20:43:54 +00:00
Andy Wilkinson
714a187d8f Rework dep mgmt again to avoid consumers picking up strict constraints
This paves the way for publishing Gradle module metadata once the
problem caused by snapshot versions and our two-step publication
process has been addressed.

See gh-19609
2020-01-15 12:33:18 +00:00
Madhura Bhave
aae1151f12 Merge branch '2.2.x'
Closes gh-19714
2020-01-14 18:52:35 -08:00
Madhura Bhave
3bf943d597 Merge branch '2.1.x' into 2.2.x
Closes gh-19713
2020-01-14 18:51:50 -08:00
Madhura Bhave
91e459a5d4 Polish "Limit ChronoField values to their range"
See gh-19595
2020-01-14 18:26:01 -08:00
Dmytro Nosan
9bc68b9877 Limit ChronoField values to their range
See gh-19595
2020-01-14 18:25:28 -08:00
Andy Wilkinson
244b5391bc Fix file handle leak in JarFileArchiveTests
Closes gh-19655
2020-01-14 17:20:29 +00:00
Andy Wilkinson
aefe52e4d0 Revert "Rework dep management to avoid consumers picking up strict constraints"
This reverts commit b34a311d02fe60ac267493ccc7f2c6b816f3a15c as,
having disabled the publishing of Gradle's module metadata (4f75ab5),
the changes are no longer needed.

See gh-19609
2020-01-14 12:15:53 +00:00
Phillip Webb
862462b791 Update copyright year of changed files 2020-01-13 17:04:19 -08:00
Andy Wilkinson
b34a311d02 Rework dep management to avoid consumers picking up strict constraints
Previously, enforcedPlatform dependencies were using to pull in the
constraints defined in spring-boot-dependencies and
spring-boot-parent and applied them strictly so that the constrained
version had to be used. This worked as intended in Spring Boot's own
build but incorrectly enforced those same strict version requirements
on external consumers of Spring Boot's modules.

This commit reworks how Spring Boot defines its internal dependency
management so that platform dependencies are exposed to external
consumers while enforced platform dependencies are using internally.

See gh-19609
2020-01-13 19:59:56 +00:00
Andy Wilkinson
ce99db1902 Port the build to Gradle
Closes gh-19609
Closes gh-19608
2020-01-10 14:15:35 +00:00
Stephane Nicoll
2c1e81adf0 Polish 2019-12-26 10:42:40 +01:00
Phillip Webb
93d9147864 Add deprecation documentation to Archive.iterator
See gh-16655
2019-12-19 16:52:47 -08:00
Andy Wilkinson
ef2eb2f652 Remove accidental usage of Plexus's CollectionUtils
See gh-16655 and 8f5777cf
2019-12-14 17:42:26 +00:00
dreis2211
3be05f61e1 Fix unknown tag in javadoc
See gh-19364
2019-12-12 17:04:25 -08:00
Madhura Bhave
8f5777cf9e Optimize JarLauncher when used with exploded jar
- Previously, we would create a JarFileArchive for all nested jars.
This was an additional overhead. We only need to create a JarFileArchive
for jars that can have nested jars in them. For all other jars we only need
the URL to build the classpath.
- While iterating over nested entries in the exploded jar, we only need to
look at BOOT-INF and we can skip any entry that does not match that.

Closes gh-16655

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2019-12-12 14:33:48 -08:00
Johnny Lim
ea51947741 Use try-with-resources blocks in JarFileArchiveTests
See gh-18883
2019-11-06 08:01:50 +01:00
Stephane Nicoll
8108b556ad Fix resource cleanup in test
Closes gh-18569
2019-10-13 13:41:50 +02:00
Andy Wilkinson
46c30d6bb0 Merge branch '2.1.x'
Closes gh-18476
2019-10-02 10:48:57 +01:00
Andy Wilkinson
3d4157ad6d Correct SCM URLs in published poms
Previously, Maven's default behaviour was relied up which resulted
in the artifact ID being appended to each URL as it was inherited.
This behaviour can only be disabled in Maven 3.6 and later, a version
that we cannot use due to an incompatibility with the Flatten Plugin.

This commit works around Maven's default behaviour by defining
properties for the SCM URL, connection, and developer connection and
then explicitly defining the settings in each pom using these
properties. The explicit definition of the properties in each pom
prevents them being inherited from the parent, thereby disabling the
unwanted appending of the artifact ID to the URL.

Fixes gh-18328
2019-10-02 10:48:30 +01:00
Andy Wilkinson
02ac089767 Polish "Support zip64 jars"
See gh-16091
2019-09-20 14:35:19 +01:00
Camille Vienot
1917e1eac5 Support zip64 jars
See gh-16091
2019-09-20 12:44:04 +01:00
Andy Wilkinson
1b237de5f5 Use Awaitility in our own tests
Closes gh-18227
2019-09-13 20:50:14 +01:00
Andy Wilkinson
ff1983c9ae Merge branch '2.1.x'
Closes gh-18168
2019-09-06 14:38:45 +01:00
Andy Wilkinson
795c2f225f Support getComment() on a nested JarFile
Previously, calling getComment() on a nested jar file would result
in the outer jar file's comment being returned.

This commit updates the loader's JarFile to read the file's comment
from the central directory end record and return it from getComment().

Fixes gh-18128
2019-09-06 14:29:48 +01:00
thelproad
9c1f503e46 Simplify if statements
See gh-17884
2019-08-17 06:50:32 +02:00
dreis2211
b605cddb10 Polish some Collections API calls
See gh-17825
2019-08-11 10:36:10 +02:00
Madhura Bhave
8a9c60a29a Merge branch '2.1.x' 2019-08-08 11:52:50 -07:00
Madhura Bhave
541d3c4853 Fix typo 2019-08-08 11:52:05 -07:00
Phillip Webb
8bc780762a Merge branch '2.1.x' 2019-07-24 11:42:48 +01:00
Phillip Webb
fb1dd8fe93 Merge branch '2.0.x' into 2.1.x 2019-07-24 11:41:32 +01:00
Phillip Webb
913e831f4e Merge '1.5.x' into 2.0.x 2019-07-24 11:39:58 +01:00
Stephane Nicoll
19eaf86efa Update multi release test jar to include Java 12
See gh-16970
2019-07-24 08:06:22 +02:00
Phillip Webb
a9ba7080ce Merge branch '2.1.x' 2019-07-17 21:48:42 +01:00
Phillip Webb
01933f9b06 Merge previously split strings
Merge some string lines that were previously split because of the
90 chars wide formatting.
2019-07-15 00:24:19 +01:00
Phillip Webb
c3816bfe7b Polish output capture names 2019-07-15 00:24:18 +01:00
Andy Wilkinson
bd22ca0268 Polish 2019-07-04 19:36:32 +01:00
Andy Wilkinson
2816635418 Polish 2019-07-04 17:51:20 +01:00
Andy Wilkinson
4b2a116fa7 Use String indexOf(char) and lastIndexOf(char) where possible
Closes gh-11416
2019-07-04 17:44:40 +01:00
Phillip Webb
a66c4d3096 Unify method visibility of private classes
Apply checkstyle rule to ensure that private and package private
classes do not have unnecessary public methods. Test classes have
also been unified as much as possible to use default scoped
inner-classes.

Closes gh-7316
2019-07-03 11:39:47 -07:00
Andy Wilkinson
6791dbb786 Merge branch '2.1.x'
Closes gh-17381
2019-07-01 15:47:48 +01:00
Andy Wilkinson
4083c721f2 Fix URL normalization when replacing /./ with /
Previously, a regular expression of /./ was used to replace /./ with
/.  The '.'' in the expression matches any single character so the
replacement was more broadly applicable than it should have been. For
example, /a/ would be replaced with /.

This commit uses Pattern.LITERAL to compile the regular expression
from the CURRENT_DIR (/./) contant. This allows the constant to be
used to check for occurances of /./ in the string before attempting
replacement, while also ensuring that the '.' is treated literally.

Closes gh-17341
2019-07-01 15:42:54 +01:00
Phillip Webb
605599138e Merge branch '2.1.x' 2019-06-28 23:56:02 -07:00