Commit Graph

788 Commits (98f14f2ee98595a441d900523dce4c127e8b8559)

Author SHA1 Message Date
Phillip Webb 7709352c2d Tweak timings for Windows build 9 years ago
Phillip Webb 61b7e6f3b3 Merge branch '1.3.x' 9 years ago
Phillip Webb af2483816b Fix JarFileTests to work on Windows
See gh-5287
9 years ago
Andy Wilkinson d1a487333d Merge branch '1.3.x' 9 years ago
Andy Wilkinson 74e27db486 Polish contribution 9 years ago
Vladimir Tsanev a0f76eab47 Update JarURLConnection to support jar:file://… URLs
Previously, JarURLConnection would fail when created with a URL that
began with jar:file:// as the double-slash is not included in jarFile.getUrl().getFile().

This commit updates JarURLConnection to normalise the value return from
url.getFile() to remove a double-slash when present.

Fixes gh-5287
Closes gh-5289
9 years ago
Andy Wilkinson 1d4e52cc2b Merge branch '1.3.x' 9 years ago
Christian Brunotte 677080b8e2 Update launch.script so popd does not print directory name to stdout
Closes gh-5394
9 years ago
Andy Wilkinson 6121d105fc Update JarLauncher to filter BOOT-INF/classes correctly
Previously, JarLauncher considered any entry whose name began with
BOOT-INF/classes/ as being a nested entry. This was incorrect as it
meant that subdirectories of BOOT-INF/classes/ would be added to the
classpath rather than just BOOT-INF/classes/ itself.

This commit updates JarLauncher so that only directory entries with a
name equal to BOOT-INF/classes are used.

Closes gh-5610
9 years ago
Andy Wilkinson 87de7e6382 Return the correct manifest for a JarFile create from a nested directory
Previously, if a JarFile was created from a directory nested inside
another jar file, it would look for the manifest in
pathFromRoot/META-INF/MANIFEST.MF. This is incorrect as, unlike a
JarFile created from a jar file, the archives are one and the same
so the manifests should be too.

This commit updates JarFile so that its aware of how it was created
(direct from a file, from a nested directory, from a nested jar). If
it was created from a file or from a nested jar, it uses its manifest.
If it was created from a nested directory, it uses the manifest of the
root archive.

Closes gh-5609
9 years ago
Andy Wilkinson f55066464d Merge branch '1.3.x' 9 years ago
Phillip Webb 893a6c32f3 Upgrade to checkstyle 6.17
Fixes gh-5547
9 years ago
Andy Wilkinson 4f200a852b Add missing jar file
It should have been in 68b83a8f but was excluded by gitignore.

See gh-3701
9 years ago
Andy Wilkinson 68b83a8f00 Improve handling of loader.path in PropertiesLauncher
Previously, if loader.path directly specified a jar file that contained
nested archives (.zip or .jar), launching would fail unless those
nested archives were uncompressed. However, if loader.path specified a
directory that contained such a jar file the launch would succeed. This
was because the nested archives within the jar were ignored.

This commit updates PropertiesLauncher so that its behaviour in the
scenarios described above is consistent by not looking for archives
nested with a jar that’s be specified on loader.path. The javadoc for
loader.path has also been updated to make it clear that loader.path
can points to directories or jar files, bringing it into line with
the reference guide.

Closes gh-3701
9 years ago
Andy Wilkinson 313b6f6451 Simplify exception handling and reporting in the launcher
Following changes to LaunchedURLClassLoader made in 87fe0b2a, it is
no longer necessary for the launcher to load MainMethodRunner via
reflection as both the app class loader that the launcher URL class
loader share the same MainMethodRunner class.

This commit takes advantage of this by updating Launcher to instantiate
MainMethodRunner directly rather than via reflection, removing one
source of possible exceptions in the launcher.

As the MainMethodRunner is now loaded directly and its class is shared
between the two class loaders, there’s no longer a need for it to
implement Runnable. This allows it to throw Exception from its run
method, rather than having to wrap any Exception in a RuntimeException.

Lastly, rather than catching any exception thrown from the launch,
Launcher and its subclasses have been updated to allow this exception
to be thrown from the main method. This allows the Exception to reach
the JVM, to be processed by our registered uncaught exception handler,
and to trigger the JVM’s standard processing for exiting due to a
failure. This removes the need for the Launcher itself to call
System.exit(1) and ensures that the exception is only output to the
console if it hasn’t been registered as a logged exception.

Closes gh-5358
9 years ago
Phillip Webb 39140945b5 Polish 9 years ago
Andy Wilkinson 7db9280bf3 Rename the default BuildInfo task to bootBuildInfo
Previously, the default BuildInfo task created by the DSL was called
buildInfo. Due to Gradle's lack of namespacing for tasks, this meant
there was a slight risk that it could clash with another task. It
also didn't following the naming used by Boot's run task which is
named bootRun.

This commit renames the default BuildInfo task to bootBuildInfo to
match bootRun and to hopefully avoid clashes with tasks from other
plugins.

Closes gh-5518
9 years ago
Andy Wilkinson fc463afb89 Merge branch '1.3.x' 9 years ago
Andy Wilkinson 1043239de0 Ignore non-JavaExec run task when finding application's main class
Previously, FindMainClassTask would look for a property named main
on any class named run. This was based on the assumption that the
run task would be a JavaExec task (typically provided by the
application plugin). If the run task was not a JavaExec task (more
accurately, if it did not have a main property) this would result in
a build failure due to trying to read a non-existent property.

This commit updates FindMainClassTask to only use the main property
of the run task if the task is a JavaExec task. This guarantees that
the property will exist on the task, and unlike using any property
named main on a task named run, also guarantee that its value will
refer to a Java class with a main method.

Closes gh-5501
9 years ago
Phillip Webb faba7a9514 Rename internal OutputCapture classes
Rename the internal versions of OutputCapture to prevent accidental
import.

See gh-5492
9 years ago
Andy Wilkinson c42f859390 Ensure that ExplodedArchive lists its file in a consistent order
Closes gh-5422
9 years ago
Andy Wilkinson c0b74119e0 Use manifest from class’s jar when defining its package
Previously, when defining a package for a class, LaunchedURLClassLoader
would use the manifest from the first location that contained the
required package. If the package was split across multiple locations,
this could lead to the manifest from a jar other than the one that
contains the class being used.

This commit updates LaunchedURLClassLoader so that it will use the
manifest of the jar file that contains the class which triggered the
definition of the package.

Closes gh-5485
9 years ago
Andy Wilkinson 1d099035b1 Protect against a race condition when defining packages
LaunchedURLClassLoader preemptively defines the package for any
classes that it attempts to load so that the manifest from a nested
jar is correctly associated with the package. This can lead to a race
where the package is defined on two threads in parallel, resulting
in an IllegalArgumentException being thrown.

This problem was manifesting itself as a NoClassDefFoundError.
If the initialization of a class failed due to the above-described
IllegalArgumentException, subsequent attempts to use that class
would then fail with a NoClassDefFoundError.

This commit updates LaunchedURLClassLoader to catch the
IllegalArgumentException and then double-check that the package has
already been defined. This approach, including thrown an
AssertionError when the second check fails, is modelled on the
approach taken by URLClassLoader.

Closes gh-5464
9 years ago
Andy Wilkinson 58ca9a1c5d Add a BuildInfo task for generating build.properties with Gradle
The commit adds a new BuildInfo task that can be used to generate
a build.properties file, intended for inclusion in the Actuator's
info endpoint.

A default instance of the task can be configure using the plugin's
DSL:

springBoot {
	buildInfo()
}

Additional properties can also be configured using the DSL:

springBoot {
	buildInfo {
		additionalProperties = [
			'foo': 'bar'
		]
	}
}

When configured via the DSL, the Java plugin's classes task is
configured to depend on the build info task. Alternatively, if more
control is required, the task can be declared and configured manually:

task buildInfo(type: org.springframework.boot.gradle.buildinfo.BuildInfo) {
	additionalProperties = [
		'foo': 'bar'
	]
}

classes {
	dependsOn buildInfo
}

See gh-2559
9 years ago
Phillip Webb 7942d9f787 Polish 9 years ago
Stephane Nicoll 10012cfddc Rename Maven plugin mojo
Rename the goal from `generate-build-info` to `build-info` for consistency.

See gh-2559
9 years ago
Stephane Nicoll dddea70985 Collect and display build information
This commit updates the Maven plugin to generate a
`META-INF/boot/build.properties` file with various build-specific
settings (group, artifact, name, version and build time). Additionally,
the plugin can be configured to write an arbitrary number of additional
properties.

A new `BuildProperties` bean is automatically exposed when such a file is
present. If that bean is present, an `InfoContributor` is automatically
created to expose that information under the `build` key.

As for the git contributor, it is possible to only display the core
settings or everything using the `management.info.build.mode` property.

See gh-2559
9 years ago
Andy Wilkinson 427d3140b3 Remove unwanted printing of stack trace from the Launcher
Previously, the Launcher would call ex.printStackTrace for any
exception that was thrown when launching the application. This was
unnecessary as the stack trace should already have been logged by
the application when it failed to start.

This commit removes the call to ex.printStackTrace, thereby allowing
an exception to be logged only once or not at all after successful
failure analysis.

Closes gh-5358
9 years ago
Phillip Webb 644ae2c21a Merge branch '1.3.x' 9 years ago
Phillip Webb 5e722dae6a Polish 9 years ago
Stephane Nicoll cc2f6f4b9c Merge branch '1.3.x' 9 years ago
Stephane Nicoll a83dae0e10 Polish contribution
Closes gh-5335
9 years ago
Eric Bottard 79cd01eb7a Fix configuration property name when group is empty
See gh-5335
9 years ago
Phillip Webb 73cbb2f40a Polish 9 years ago
Stephane Nicoll c6c001457a Fix description of classifier attribute
See gh-5258
9 years ago
Stephane Nicoll 7f3ee2e405 Disable attach of repackaged artifact
This commit allows to generate the packaged artifact only locally by
adding a new `attach` property. If `attach` is set to `false` explicitly,
only the main artifact is installed/deployed.

Closes gh-5258
9 years ago
Andy Wilkinson ad7cf48497 Update Repackager to use Java 8 APIs safely
Previously, Repackager used Java 8 APIs without protecting against the
possibility of a NoSuchMethodError on earlier versions of Java.
This commit wraps the Java 8 APIs in try-catch blocks to ensure
that they do not cause a failure on Java versions before 8, while
still making full use of Java 8's capabilities when available.

Closes gh-5280
9 years ago
Andy Wilkinson 779649bfdb Merge branch '1.3.x' 9 years ago
Andy Wilkinson bb473c32e2 Enable Animal Sniffer checking of spring-boot-loader-tools
Previously, Animal Sniffer checking of spring-boot-loader-tools
was disabled as it failed with an NPE. This has been fixed in
Animal Sniffer 1.15.

This commit upgrades Animal Sniffer to 1.15 and adds the necessary
annotations to suppress failures for safe usage of sun.* and Java 7
APIs.

Note that UsesUnsafeJava has been copied from spring-boot and made
package-private. This retains the clearer intent of the custom
annotation (versus @IgnoreJRERequirement) while avoiding the change
in the build order that would be necessary for
spring-boot-loader-tools to use the annotation from spring-boot.

Closes gh-5284
9 years ago
Uwe Schaefer 9c3003071b Add CONF_FOLDER property
Closes gh-5203
9 years ago
Spring Buildmaster 225d877ab9 Next Development Version 9 years ago
Andy Wilkinson af32d6e8ee Allow LOG_FOLDER and PID_FOLDER defaults to be set at build time
This commit enhances the default launch script to allow the default
values for LOG_FOLDER and PID_FOLDER to be set at build time. They
can now be set using the logFolder and pidFolder properties
respectively.

Closes gh-4787
9 years ago
Andy Wilkinson 44ddfcc7fa Upgrade copyright headers of all files changed in 2016 9 years ago
Andy Wilkinson d9382244d8 Handle mixture of encoded and unencoded chars in JarURLConnection
Previously, JarURLConnection would corrupt a URL that contained a
mixture of encoded and unencoded double-byte characters. URLs that
only contained unencoded double-byte characters were not affected as
they are passed through as-is.

This commit updates JarURLConnection.JarEntryName to correctly handle
characters with a value that won't fit in a single signed byte (a
value greater than 127). Such characters are now URL encoded and then
written to the output stream as multiple bytes.

Closes gh-5194
9 years ago
Phillip Webb 89b7704977 Extract spring-boot-test.jar
Relocate the `org.springframework.boot.test` package from the
`spring-boot.jar` to `spring-boot-test.jar`.

Fixes gh-5184
9 years ago
Phillip Webb 4b55144d80 Polish 9 years ago
Andy Wilkinson 5ed4ef1272 Add manifest entries for location of lib and classes in executable archives
Closes gh-5183
9 years ago
Andy Wilkinson fcbf15aea3 Update Ant support following changes the executable jar layout
Closes gh-4897
9 years ago
Andy Wilkinson 87fe0b2ade Use a conventional delegation model in LaunchedURLClassLoader
When an application is run as an executable archive with nested jars,
the application's own classes need to be able to load classes from
within the nested jars. This means that the application's classes need
to be loaded by the same class loader as is used for the nested jars.
When an application is launched with java -jar the contents of the
jar are on the class path of the app class loader, which is the
parent of the LaunchedURLClassLoader that is used to load classes
from within the nested jars. If the root of the jar includes the
application's classes, they would be loaded by the app class loader
and, therefore, would not be able to load classes from within the
nested jars.

Previously, this problem was resolved by LaunchedURLClassLoader being
created with a copy of all of the app class laoder's URLs and by
using an unconventional delegation model that caused it to skip its
parent (the app class loader) and jump straight to its root class
loader. This ensured that the LaunchedURLClassLoader would load both
the application's own classes and those from within any nested jars.
Unfortunately, this unusual delegation model has proved to be
problematic. We have seen and worked around some problems with Java
Agents (see gh-4911 and gh-863), but there are others (see gh-4868)
that cannot be made to work with the current delegation model.

This commit reworks LaunchedURLClassLoader to use a conventional
delegate model with the app class loader as its parent. With this
change in place, the application's own classes need to be hidden
from the app class loader via some other means. This is now achieved
by packaging application classes in BOOT-INF/classes (and, for
symmetry, nested jars are now packaged in BOOT-INF/lib). Both the
JarLauncher and the PropertiesLauncher (which supports the executable
jar layout) have been updated to look for classes and nested jars in
these new locations.

Closes gh-4897
Fixes gh-4868
9 years ago
Stephane Nicoll b60e9e5cb9 Expose hints for Maps
This commit fixes the json parser so that hints for maps is also made
available.

Closes gh-5152
9 years ago
Phillip Webb 00cfe1d054 Use AssertJ in spring-boot-tools
See gh-5083
9 years ago
Phillip Webb 516afcd2ca Polish 9 years ago
Andy Wilkinson 9dbef5d9b0 Remove use a separate runner thread from the Launcher
Previously, the Launcher was creating a new runner thread that would
call the application's main method. An exception thrown by this thread
is handled differently to one thrown by the JVM's main thread leading
to different exit behaviour. Furthermore, the separate thread isn't
actually necessary.

This commit removew the use of a separate runner thread from the
Launcher. This means that the JVM's exit behaviour will be consistent
and also removes the overhead of createing a starting an extra thread.

Closes gh-5006
9 years ago
Johnny Lim 46540de694 Fix typos
Closes gh-5067
9 years ago
Phillip Webb acbb4e63f2 Clear caches on ApplicationContext load
Ensure that JarFile caches are cleared once the ApplicationContext has
loaded. Caches are cleared manually with the assumption that no
further class loading is likely.

Closes gh-4882
9 years ago
Phillip Webb e2368b909b Reduce memory consumption of fat/exploded jars
Refactor `spring-boot-loader` to reduce the amount of memory required
to load fat & exploded jars. Jar files now no longer store a full list
of entry data records, but instead use an array of entry name hashes.

Since ClassLoaders often ask each JAR if they contain a particular
entry (and mostly they do not), the hash array provides a quick way to
deal with misses. Only when a hash does exist is data actually loaded
from the underlying file.

In addition to the JarFile changes, the Archive abstraction has also
been updated to reduce memory consumption.

See gh-4882
9 years ago
Phillip Webb 858a854ce1 Drop use of loggers in Launchers
Remove the use of JDK loggers in Launcher and PropertiesLauncher to
ensure allow the custom Log4j2 `LogManager` to be used with Spring Boot
applications.

Fixes gh-3815
9 years ago
Stephane Nicoll 11d8515594 Add failsafe default configuration
Provides better default for integration tests. Also expand the
documentation of the maven plugin in that area.

Closes gh-4223
9 years ago
Stephane Nicoll bead239448 Remove support for Log4j
Apache Log4j 1.x is EOL and has now been replaced by log4j 2. This commit
removes the deprecated support for Log4j 1.x

See gh-4905
9 years ago
Phillip Webb fbaf209240 Move master to 1.4.0.BUILD-SNAPSHOT 9 years ago
Spring Buildmaster 504d3e97ba Next development version 9 years ago
Phillip Webb 93c3b22bb4 Merge branch '1.2.x' 9 years ago
Phillip Webb c71aa32fbb Polish 9 years ago
Andy Wilkinson 9dc858cdf5 Add missing properties to RepackageTask and improve test coverage
Closes gh-4978
9 years ago
Andy Wilkinson 854cacdb4f Fix useStartStopDaemon in launch script and allow config via conf file
Commit 5a1ee6eb added support for disabling use of start-stop-daemon
via a placeholder in the default launch script. Unfortunately, that
placeholder was subsequently broken in 81a47639.

This commit reinstates the placeholder and adds tests to verify that all
of the placeholders in the launch script can be replaced and that they
have the required default values. Furthermore, it also allows the use of
start-stop-daemon to be configured via USE_START_STOP_DAEMON in an
app’s .conf file. This allows the configuration to be changed after the
app has been built.

Closes gh-4985
9 years ago
Andy Wilkinson 2dc3660a32 Align launcher exception handling with direct invocation of main method
Previously, if an application’s main method threw an exception,
MainMethodRunner would catch the exception and call System.exit(1).
This meant that the JVM would exit, irrespective of whether or not
any non-daemon threads were running. In contrast, when an application’s
main method was invoked directly (in an IDE, for example) the JVM
would not exit if one or more non-daemon threads were running. This
is standard JVM behaviour that we should be consistent with in the
launcher.

This commit updates MainMethodRunner to wrap any exception thrown by an
application’s main method in a RuntimeException and rethrow it. This
alllows the JVM to handle the exception and use its normal rules for
deciding whether or not it should exit.

Closes gh-4984
9 years ago
Stephane Nicoll 7842f50e30 Add property to skip integration tests
Generalize the `skip` property to start and stop goals so that one
can control if the Spring Boot app is starting via a configuration
property.

Note that this only controls the Spring Boot Maven plugin and the
failsafe maven plugin should be updated accordingly.

Closes gh-4922
9 years ago
Andy Wilkinson 93ef795159 More use entrySet() rather than using keySet() and get(key)
This commit replaces some more occurrances of keySet() and get(key)
with more efficient usage of the map's entry set.

See gh-4813
9 years ago
Andy Wilkinson 89beef4099 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 681a866cce Exclude Java agents from class loader created by PropertiesLauncher
PropertiesLauncher creates a ClassLoader that is used by the Launcher
to load an application’s classes. During the creation of this
ClassLoader URLs from its ClassLoader. This resulted resulting in Java
agents that are added to the system class loader via the -javaagent
launch option being available on both the system class loader and the
created class loader. Java agents are intended to always be loaded by
the system class loader. Making them available on another class loader
breaks this model.

This is the same problem that was in ExecutableArchiveLauncher and
that was fixed in ee08667e (see gh-863).

This commit updates PropertiesLauncher so that it skips the URLs of
any Java agents (found by examining the JVM’s input arguments) when
copying URLs over to the new ClassLoader, thereby ensuring that Java
agents are only ever loaded by the system class loader.

Closes gh-4911
9 years ago
Andy Wilkinson 487a66a75f Resend SIGTERM if app is still running 30 seconds after first attempt
Previously, the default launch script would send SIGTERM once and then
wait for up to 60 seconds for the app to have stopped. If the service
was stopped immediately after being started the first SIGTERM would
occasionally be ignored (presumably because the JVM was not yet in a
state to handle it) causing the service stop request to fail.

This commit updates the launch script to resend SIGTERM to the process
if it's still running 30 seconds after the first SIGTERM was sent.

Closes gh-4941
9 years ago
Andy Wilkinson 3afd0c7b3b Address Shellcheck warning (SC2086) for $arguments in launch script
$arguments needs to be split on spaces so it can’t just be wrapped
in quotes. This commit updates arguments to be an array that is then
expanded ("{arguments[@]}"). The use of @ and double quotes means that
it is expanded into all elements individually quoted.

See gh-4866
9 years ago
Andy Wilkinson 27a81e1463 Complete static final logger changes that were started in ec2f33f9
This commit completes the changes to consistently used static final
fields for Log instances that were started in ec2f33f9. Specifically it:

 - Removes this. when accessing logger fields that are now static
 - Renames some fields from log to logger
 - Makes some logger fields static

See gh-4784
9 years ago
Andy Wilkinson c39a55a270 Fix quoting of start-stop-daemon RUN_ARGS and JAVA_OPTS in launch script
81a4763 introduced a regression when multiple RUN_ARGS or JAVA_OPTS were
configured. Rather than the JVM being launched with multiple arguments
all of the RUN_ARGS or JAVA_OPTS were passed as a single argument. This
caused unexpected behaviour and typically caused the application to fail
to start.

This commit updates the quoting of the arguments the are supplied when
launching the app using start-stop-daemon so that space-separated
entries in RUN_ARGS and JAVA_OPTS remain separate.

Closes gh-4866
9 years ago
Andy Wilkinson 04fe55a2ab Improve portability by using type instead of which in the launch script
Previously, the launch script used which to determine the availability
of start-stop-daemon. which isn’t available by default on all OSs.
For example, it’s not available by default on CentOS 5.

This commit updates the launch script to use type when determining if
start-stop-daemon is available. This improves the portability of the
script and makes the use of type consistent throughout the script.

Closes gh-4925
9 years ago
Andy Wilkinson a1e0f2f5f0 Update launch script to wait for pid to be written to pid file
Previously, the launch script would wait for the pid file to exist
before continuing. This didn’t work 100% of the time as it left a 
window where the file had been created but the PID had not been written
to it that could result in an incorrect report of the app failing to
start.

This commit updates the script to wait for the file to have a size
greater than zero before continuing. This ensures that the pid has
been written to the file before the pid is read from the file and used
to check that the process is running.

Closes gh-4923
9 years ago
Phillip Webb 7397dbaf57 Allow ExitCodeGenerator to be used on Exceptions
Update exit code support to allow the ExitCodeGenerator interface to
be placed on an Exception. Any uncaught exception implementing the
interface and returning a non `0` status will now trigger a System.exit
with the code.

Fixes gh-4803
9 years ago
Andy Wilkinson 2aff82bb64 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 6117b6c5c8 Consistent use of tabs for indentation in pom files 9 years ago
Johannes Edmeier 832ad2fe85 Change redirect in initscript to support old bash
`&>>` syntax is bash version 4. This fix allows to support older
versions.

Fixes gh-4820
Closes gh-4829
9 years ago
Spring Buildmaster 8db59059a5 Next Development Version 9 years ago
Stephane Nicoll bb736e255b Fix SNAPSHOT version 9 years ago
Kirill Vlasov ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
9 years ago
Kirill Vlasov 786aacf2e9 Use Collections.isEmpty() instead of .size() == 0
Ensure that Collections.isEmpty() is used to check if there are no
elements in a collections. This is more explicit and can be faster than
calling .size().

Closes gh-4783
9 years ago
Michitomo Nakahara 2b5b7cd81e Update launch.script to append to $log_file rather than overwriting it
Closes gh-4506
9 years ago
Andy Wilkinson 02e1d669df Exit with a value of 1 when cd fails in the init script
Exiting with 0 when cd fails is likely to be incorrectly interpreted
as success so we should exit with a non-zero value. Ideally, the init
script status action would exit with 4 but, at the point when
the cd is performed, we don’t even know if we’re running as an init
script. Exiting with 1 seems to be a reasonable compromise as it’s
fine for the non init-script case as well as being correct for all
init script actions other than status.

See gh-4653
9 years ago
Andy Wilkinson 81a4763940 Address problems in launch.script reported by Shellcheck 0.4.1
Closes gh-4653
9 years ago
Phillip Webb 5a1ee6ebe8 Allow easy opt-out of using start-stop-daemon
Allow users to easily opt-opt of using the start-stop-daemon in the
launch script. This may be required on distros that include older
versions.

Fixes gh-4732
9 years ago
Phillip Webb 34b31f1abc Protect against null description
Update `removeLineBreaks` to also work with `null`.

See gh-4703
9 years ago
Robert Thornton 8e0b8750c0 Cleanup description new-lines for launch script
Replace all new-line characters in multi-line pom descriptions before
inserting into the launcher script. Prior to this commit the shell would
attempt to execut the extra lines, for example:

	<description>
		A multi-line pom description that could do something terrible:
		rm -r foo
	</description>

Closes gh-4703
9 years ago
Phillip Webb 2d2e4eea82 Merge branch '1.2.x' 9 years ago
Phillip Webb 2694605a4d Polish 9 years ago
mnhock 7348ef5ef1 Remove double instantiation of Manifest
Closes gh-4701
9 years ago
Johnny Lim ec7fed1ecc Polish
Closes gh-4677
9 years ago
Andy Wilkinson 46edee2e45 Only make bootRun depend on findMainClass and not all java exec tasks
Closes gh-4639
9 years ago
Vladimir Tsanev 939b66f4ee Use fast exceptions in findResource(s)
Some libraries like aspectj are using findResource to see the raw
bytecode of a class. It will even call findResource for every method of
every class of beans that are post processed. This can be significant
performance hit on startup when LaunchedURLClassLoader and there are a
lot of nested jars.

See gh-3640
Fixes gh-4557
9 years ago
吉田 尚弘 02363b38eb Make launch script's chkconfig configurable via a property
Closes gh-4564
9 years ago
Andy Wilkinson 0f032eeb8a Address warnings reported by shellcheck for changes made in 7011944
Closes gh-4524
9 years ago
Andy Wilkinson 70119449ce Add workaround for race condition in start-stop-daemon
There’s a race condition in start-stop-daemon when --make-pidfile and
--background are used together [1]. This race condition can lead to the
command returning before the PID file has been created. The missing PID
file then causes the launch script to incorrectly report that the
service failed to start.

This commit updates the launch script to wait for up to 10 seconds for
the PID file to be created when start-stop-daemon is used to launch the
app.

Closes gh-4524

[1] https://bugs.launchpad.net/ubuntu/+source/dpkg/+bug/1036899
9 years ago
Vladimir Tsanev 1e2f133892 Use fast exceptions in findResource(s)
Some libraries like aspectj are using findResource to see the raw
bytecode of a class. It will even call findResource for every method of
every class of beans that are post processed. This can be significant
performance hit on startup when LaunchedURLClassLoader and there are a
lot of nested jars.

See gh-3640
Fixes gh-4557
9 years ago
Stephane Nicoll 141907c65f Merge branch '1.2.x'
# Conflicts:
#	spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java
#	spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java
9 years ago
Stephane Nicoll ae13082e0d Generate meta-data for nested Lombok types
Closes gh-4397
9 years ago
Johnny Lim 8ec00c35bf Polish
Closes gh-4572
9 years ago
Johnny Lim 36ed0f5c20 Polish
Closes gh-4537
9 years ago
Spring Buildmaster 3f6f57a80e Next Development Version 9 years ago
Johnny Lim 0a85281a66 Fix typos
Closes gh-4463
9 years ago
Pedro Vilaca 98be051cfa Don't remove PID file before stopping the service
Update the launch script so that the PID file is not longer removed at
the beginning of the stop method. Prior to this commit if a service
wasn't able to stop on the first run, it wasn't possible to use the
launch script anymore.

Fixes gh-4369
Closes gh-4371
9 years ago
Pedro Vilaca b190cfdd6a Don't use `kill -hup` in the launch script
The HUP signal was being used to stop the service and for some reason,
sometimes it was being ignored. This commit change forces the use of the
TERM signal (the default signal of kill).

Fixes gh-4378
Closes gh-4414
9 years ago
Phillip Webb 6c2ea4648f Polish 9 years ago
Dave Syer fa9724becb Revert "Add or avoid proxy configurations for integration tests"
This reverts commit 251f2805a8.
9 years ago
mrumpf 251f2805a8 Add or avoid proxy configurations for integration tests
The Maven POM does all the dependency resolutions for the
spring-boot-antlib project. Delegating this task to Ivy, which is
buried deep in the Antrun/Antunit part of the build, makes any kind
of proxy configuration much more complex.
The ivysettings.xml already has the local M2 repository configured,
but because the folder "repository" is missing, the artifacts, already
downloaded by Maven cannot be resolved from this location.
The Spring and Maven Central repositories should be removed from the
ivysettings.xml files in order to force all resolves to be done through
the local M2 repository. The POM of joda-time version 2.8.1 has an
optional dependency to joda-convert 1.2, which lets the Ivy resolve
process fail, because this version of the joda-convert library was
not resolved by any of the Maven POMs. It seems as if Ivy does not
respect the optional scope, defined in the joda-time POM.

Pass proxy settings to the forked process to make the Gradle distribution download work

Create a gradle.properties file for each Gradle integration test and writes the forking
process' proxy settings as systemProp.http(s).Host/Port to the properties file.
This configures the external process with the right proxy settings to let it download
the Gradle distribution via the HTTP proxy server.

Added a hint for Windows users to get the core.autocrlf setting right

When the core.autocrlf setting under Windows is set to false for example
All files are not converted regarding their EOL characters to the
Windows format with CRLF at a line's end. There is a checkstyle
validation that checks that all files have the system's line endings
and in some test-cases the value from the system property "line.ending"
is used to check test output. So without the conversion, those checks
are going to fail, resulting in build errors.

Fixes gh-4367, fixes gh-3816
9 years ago
ZakarFin efa7303507 Fix linux service script command syntax
Closes gh-4359
9 years ago
Stephane Nicoll 0b326035b0 Fix detection of property setter
Previously, the meta-data annotation processor was taking the first
setter that match the property name it has to handle. Contrary to
getters that are enforced by a return type (no argument), multiple
setter candidates may exist.

If a property's type got narrowed over time, the original setter may
have been marked as Deprecated. As the annotation processor takes the
first setter that matches based on the name only, it may pick up the
deprecated one and therefore mark the property as being (wrongly)
deprecatede in the meta-data.

It turns out that checking for the actual type of the setter parameter
brought a side effect: some primitive properties may use the primitive
or the Wrapper counter part. This commit not only look at the proper
setter based on the type but also fallback on the wrapper (or) primitive
if necessary.

Closes gh-4338
9 years ago
Andy Wilkinson 826acf5d67 Set the working directory to that of the jar when using start-stop-daemon
By default, start-stop-daemon will chdir to the root directory before
starting the process. This prevents an application.properties file that
sits alongside the jar from being found.

This commit updates the call to start-stop-daemon to use --chdir to
set the working directory to that of the jar that’s being launched.

Closes gh-4281
9 years ago
Andy Wilkinson 1ef68ef231 Correct the reference to jarfolder in the init script
Closes gh-4287
9 years ago
Andy Wilkinson 17f61c1dad Update javadoc of LaunchedURLClassLoader to describe delegation model
Closes gh-3864
9 years ago
Phillip Webb a7a2aa0461 Add "INIT INFO" property substitutions
Update the "INIT INFO section" of `launch.script` to include
`initInfoProvides`, `initInfoShortDescription` and `initInfoDescription`
property substitutions.

The Maven plugin has been updated to populate substitutions with
`${project.artifactId}`, `${project.name}` and `${project.description}`.

Fixes gh-4245
9 years ago
Stephane Nicoll 168fc2f61f Disable addResources by default
Flip the default value of `addResources` for both the Maven and Gradle
plugins. This effectively turns off static resources reloading and, more
importantly, the pruning of duplicate resources from the target
directory.

As devetools is our mainstram solution for such feature, the documantion
has been updated to reflect that.

Closes gh-4227
9 years ago
Andy Wilkinson d071db8cc9 Align launch.script with the init script spec
The init script spec [1] describes a number of requirements with which
our launch.script did not comply. This commit makes the following
corrections:

 - Add support for force-reload which should be implemented by all
   init scripts
 - Don't fail restart if the service is already stopped or not running
 - Consider stop to be successful if the service is already stopped
 - Exit with 1 if stop fails (indicating a generic or unspecified error)
   rather than 3 (unimplemented feature)
 - Report a status of 1 if app is not running but the pid file exists
 - Report a status of 3 if the app is not running (no pid file)

Closes gh-4231

[1] http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
9 years ago
Stephane Nicoll 1d3386ba3f Remove spring-boot-dependency-tools
A merge from 1.2.x brought back this module that was deleted on master.

Closes gh-4246
9 years ago
Phillip Webb 90f7bc0321 Polish 9 years ago
Phillip Webb 634bb770b2 Organize imports with new settings
See gh-4234
9 years ago
Phillip Webb 1e4d974ec0 Merge remote-tracking branch 'local12x/1.2.x' 9 years ago
Phillip Webb a79131f8d2 Organize imports with new settings
See gh-4234
9 years ago
Tommy Ludwig e4230e61d7 Make the name of the log file produced by launch script configurable
Previously, the launch script would always use a file named
<appname>.log to capture the application's console output. This commit
adds a variable, LOG_FILENAME, for specifying the file name defaulting
to <appname>.log.

Fixes gh-4194
9 years ago
Spring Buildmaster 2b38a861e3 Next Development Version 9 years ago
Phillip Webb 03d54fa1d0 Polish 9 years ago
Stephane Nicoll 4eefd92e82 Customize active profiles via a dedicated property
This commit adds a dedicated property to specify the active profiles to
use when running an application via the Maven plugin. This works also
on the command line using the `run.profiles` system property and is
consistently applied whether the process is forked or not.

Closes gh-4199
9 years ago
Bruce Edge df07151f10 Use start-stop-daemon if present in launch.script
Update `launch.script` to use `start-stop-daemon` when possible to
manage daemon processes. When `start-stop-daemon` is not available `su`
is used.

Closes gh-4137
9 years ago
Andy Wilkinson 30f24eac0a Merge branch '1.2.x' 9 years ago
Andy Wilkinson 7e718cda26 Remove redundant hash from path of unpacked nested library
Closes gh-4124
9 years ago
Stephane Nicoll e79ef9b73b Add option to exclude devtools from fat jar
Add an `excludeDevtools` property to both the Maven and Gradle plugin
that removes `org.springframework.boot:spring-boot-devtools` (if
necessary) when repackaging the application.

Closes gh-3171
9 years ago
Andy Wilkinson 6c4e4520d4 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 050a4fed17 Restore compatibility with Gradle 2.0
Gradle 2.0, and only 2.0, requires a Plugin implementation to be
public. The changes made in gh-4113 (9c14ed3) made the class
package-private.

Closes gh-4139
9 years ago
Andy Wilkinson 9c14ed3502 Remove stale Java source from src/main/groovy in the Gradle plugin
Closes gh-4113
9 years ago
Phillip Webb 6333426cbf Reformat package-info.java files with Eclipse Mars 9 years ago
Phillip Webb 04074fece1 Merge branch '1.2.x' 9 years ago
Phillip Webb 94736719f1 Reformat package-info.java files with Eclipse Mars 9 years ago
Andy Wilkinson 2afb641603 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 04c2bd9c89 Update tests to expect additional entry in test jar
Closes gh-4124
9 years ago
Andy Wilkinson 8948322d7a Merge branch '1.2.x' 9 years ago
Andy Wilkinson 888fa90265 Ensure that JarFileArchive unpacks entries to unique location
Previously, JarFileArchive would always unpack any entries marked for
unpacking to ${java.io.tmpdir}/spring-boot-libs. This could cause
problems if multiple Spring Boot applications were running on the same
host:

- If the apps are run as different users the first application would
  create the spring-boot-libs directory and the second and subsequent
  applications may not have write permissions to that directory
- Multiple apps may overwrite each others unpacked libs. At best this
  will mean one copy of a jar is overwritten with another identical
  copy. At worst the jars may have different contents so that some of
  the contents of the original jar disappear unexpectedly.

This commit updates JarFileArchive to use an application-specific
location when unpacking libs. A directory beneath ${java.io.tmpdir} is
still used but it's now named <jar-file-name>-spring-boot-libs-<uuid>.
A loop, limited to 1000 attempts, is used to avoid problems caused by
the uuid clashing.

Closes gh-4124
9 years ago
Phillip Webb aae38db9af Fix compiler warnings only shown in Eclipse Mars 9 years ago
Phillip Webb c9fb9916b8 Reformat code using Eclipse Mars 9 years ago
Phillip Webb e473364e4e Merge branch '1.2.x' 9 years ago
Phillip Webb 6ab376e2e8 Reformat code use Eclipse Mars 9 years ago
Phillip Webb 47576354f7 Merge branch '1.2.x' 9 years ago
Phillip Webb ba7c1fda72 Convert Gradle plugin from Groovy to Java
Replace existing Groovy code with Java since the Groovy Eclipse tooling
currently forces the use of an old jdt plugin which has formatter bugs.

Fixes gh-4113
9 years ago
Thomas Raehalme 3865f3b303 Allow launch script to be used by accounts that use /sbin/nologin
Closes gh-3852
Closes gh-3906
9 years ago
Andy Wilkinson 051ebf3fac Polishing: fix a number of compiler warnings reported by Eclipse 9 years ago