Commit Graph

1070 Commits

Author SHA1 Message Date
Stephane Nicoll
cf07d19ed4 Polish
See gh-6792
2016-08-31 09:27:50 +02:00
Phillip Webb
850141c405 Merge branch '1.3.x' 2016-08-29 15:30:30 +01:00
Phillip Webb
69e96c6211 Polish 2016-08-29 15:29:54 +01:00
Stephane Nicoll
afadac27bd Merge branch '1.3.x' 2016-08-27 12:34:05 +02:00
Stephane Nicoll
97f15d606d Auto-detect fork value in stop goal
So far, one has to set the "fork" value to both the start and stop
goals. Since they have the same name, sharing them in a global
configuration element does the trick. However, the plugin also supports
auto-detection of the fork value according to other parameters:
typically if an agent or jvm arguments are set, forking will be
automatically enabled. This is a problem since the stop goal is not aware
of that.

This commit transmits the value in a property attached to the
`MavenProject`. That way, the stop goal can retrieve that value and
apply the same defaults. This has the side effect that specifying the
fork value isn't necessary anymore.

Closes gh-6747
2016-08-27 12:33:44 +02:00
Andy Wilkinson
742657983b Improve the error message when additional build-info prop has null value
Closes gh-6724
2016-08-23 11:30:23 +01:00
Andy Wilkinson
f41e629760 Provide M2E lifecycle mapping metadata for Maven plugin’s build-info goal
Previously, configuring the build-info goal in a pom would result in 
Eclipse reporting an error for the pom as it didn’t know if/when to
execute the build-info goal.

This commit adds lifecycle mapping metadata so that the goal is executed
on incremental builds. This ensures that the contents of the generated
file are kept up-to-date, reflecting the latest build time, etc.

Closes gh-6723
2016-08-23 11:30:23 +01:00
Andy Wilkinson
984a6da262 Polising
Fix botched merge
2016-08-18 13:44:36 +01:00
Andy Wilkinson
e2ceece525 Merge branch '1.3.x' 2016-08-18 13:30:56 +01:00
Andy Wilkinson
85c0b44dcb Test that LaunchedURLClassLoader works when thread is interrupted
Previously, RandomAccessDataFile used a semaphore and acquired it
interruptibly. This meant that an interrupted thread was unable to
access the file. Notably, this would prevent LaunchedURLClassLoader from
loading classes or resources on an interrupted thread.

The previous commit (937f857) updates RandomAccessDataFile to acquire
the semaphore uninterruptibly. This commit adds a test to
LaunchedURLClassLoader to verify that it can now load a resource from
an interrupted thread.

Closes gh-6683
2016-08-18 12:03:05 +01:00
hengyunabc
937f85765c Ensure that LaunchedURLClassLoader works when thread is interrupted
See gh-6683
2016-08-18 11:59:45 +01:00
Andy Wilkinson
b3e0b3a542 Consider mvn spring-boot:run that exits with 130 (SIGINT) to be successful
Previously, if mvn spring-boot:run with a forked JVM was killed with 
CTRL+C, the run would be considered unsuccessful. This commits updates
the run mojo to consider a forked JVM that exists with 130 (the exit
code produced when exiting due to SIGINT which is what CTRL+C sends) to
be successful.

Closes gh-6498
2016-08-15 11:23:49 +01:00
Andy Wilkinson
11ccc5785c Merge branch '1.3.x' 2016-08-12 12:08:25 +01:00
Andy Wilkinson
ae6182a964 Update requiresUnpack documentation of unpack location
The unpack location is (largely) an implementation detail and the
Repackage Mojo was the only place where it was explicity documented.
Rather than updating the outdated location, this commit removes it
entirely to avoid encouraging people to rely on the location.

Closes gh-6624
2016-08-12 12:07:47 +01:00
Andy Wilkinson
b47da0d265 Fix spellcheck warning introduced in 6bbd50e0
Closes gh-6628
2016-08-11 20:35:47 +01:00
Andy Wilkinson
8c106af384 Allow default value for CONF_FOLDER to be set at build time
Closes gh-6549
2016-08-11 20:25:59 +01:00
Andy Wilkinson
899b851c6f Remove META-INF/INDEX.LIST when repackaging a jar file
META-INF/INDEX.LIST files are pointless in an executable jar and
moving application classes from the root of the jar to
BOOT-INF/classes breaks the index, resulting in an
InvalidJarIndexException being thrown.

This commit updates the Repackager to automatically remove a
META-INF/INDEX.LIST file from a jar file that is being repackaged.

Closes gh-6601
2016-08-10 13:23:49 +01:00
Spring Buildmaster
334baaeffd Next development version 2016-07-28 19:54:01 +00:00
Spring Buildmaster
a89ef5df6e Next Development Version 2016-07-28 09:18:40 +00:00
Andy Wilkinson
8b987e29c1 Fix spring-boot-gradle-plugin package tangle
Relocate `SpringBootPlugin` to fix a package tangle.

Fixes gh-6355
2016-07-11 10:43:52 -07:00
Andy Wilkinson
8e669e2eef Merge branch '1.3.x 2016-07-11 17:03:16 +01:00
Andy Wilkinson
4963cfd67b Reset thread's interrupted flag when catching InterruptedException
Closes gh-6360
2016-07-11 16:46:05 +01:00
Spring Buildmaster
2216369348 Next Development Version 2016-07-04 14:15:02 +00:00
Andy Wilkinson
92bb24e365 Avoid synchronizing on this and use an internal monitor instead
Where possible, code that previously synchronized on this (or on the
class in the case of static methods) has been updated to use an
internal monitor object instead. This allows the locking model that's
employed to be an implementation detail rather than part of the
class's API.

Classes that override a synchronized method continue to declare
the overriding method as synchronized. This ensures that locking
is consistent across the superclass and its subclass.

Closes gh-6262
2016-07-01 10:44:23 +01:00
Phillip Webb
266445aaf0 Polish 2016-06-29 10:44:33 -07:00
Stephane Nicoll
e9fb51bdd7 Fix test 2016-06-27 12:08:48 +02:00
Stephane Nicoll
6631136f91 Merge branch '1.3.x' 2016-06-27 12:08:04 +02:00
Stephane Nicoll
17f8a244de Fix property names with successive capital letters
Previously, if a property name had successive capital letters, the
generated meta-data would clean it in such a way it is defined as a
regular word. For instance a `myFOO` property would be written as
`my-foo` in the meta-data.

It turns out this decision is wrong as the binder has no way to compute
back the name of the property and therefore `my-foo` wouldn't bind to
`setMyFOO` as it should.

This commit updates the meta-data name generation algorithm to properly
identify such cases: `myFOO` now translates to `my-f-o-o`. While the
generated name is a bit ugly, it now provides a consistent binding
experience.

Closes gh-5330
2016-06-27 12:02:34 +02:00
Phillip Webb
a5cddf79a8 Reduce JarURLConnection allocations
Update JarURLConnection & Handler so that a shared static final
connection is returned for entries that cannot be found.

See gh-6215
2016-06-26 08:40:25 -07:00
Phillip Webb
c22a0e90a2 Polish 2016-06-24 11:52:43 -07:00
Andy Wilkinson
0d207d438a Improve the performance of JarURLConnection
This commit improves the performance of JarURLConnection. There are two
main changes:

Firstly, the way in which the spec is determined has been changed so
that it’s no longer necessary to create an absolute file. Instead,
the JarFile’s pathFromRoot is used to extract the spec from the URL
relative to the JarFile.

Secondly, the number of temporary Objects that are created has been
reduced, for example by tracking an index as we process a String
rather than creating a new substring for each iteration.

See gh-6215
2016-06-24 16:14:33 +01:00
Andy Wilkinson
9788a7bdda Merge branch '1.3.x' 2016-06-24 11:53:01 +01:00
Andy Wilkinson
8d491f278b Create FilePermission lazily in JarURLConnection
JarURLConnection is very performance sensitive. The change in 3772d9f
meant that every JarURLConnection would create a FilePermission,
irrespective of whether it was actually used.

This commit updates JarURLConnection to create its FilePermission
lazily. When there is no security manager a permission will no longer
be created at all.

Closes gh-5411
See gh-6215
2016-06-24 11:49:35 +01:00
Phillip Webb
bdb0eb29a3 Cache JarURLConnection absoluteFile lookups
Update JarURLConnection.getNormalizedFileUrl so that expensive absolute
file lookups are cached.

See gh-6177
See gh-6109
2016-06-23 14:30:10 -07:00
Phillip Webb
b03d8a5914 Skip antlib integration tests on -DskipTests 2016-06-23 14:29:11 -07:00
Stephane Nicoll
cfe1fe8736 Merge branch '1.3.x' 2016-06-23 10:44:55 +02:00
Stephane Nicoll
bffcb1aad2 Document available layouts
Closes gh-5524
2016-06-23 10:42:47 +02:00
Andy Wilkinson
a395679b95 Fix JarURLConnectionTests on Windows
Closes gh-6109
2016-06-22 10:02:42 +01:00
Andy Wilkinson
02dbd6e4a7 Allow JarURLConnection to be created with a relative URL
Previously, JarURLConnection assumed that that URL with which it was
created would contain the absolute path of the underlying jar file.
This meant that when it was created with a relative URL, it could fail
to find an entry or throw a StringIndexOutOfBoundsException.

This commit updates the logic for normalizing the input URL so that
both absolute and relative URLs are supported.

Closes gh-6109
2016-06-21 11:30:51 +01:00
Phillip Webb
7446235ff4 Polish 2016-06-20 20:13:13 -07:00
Stephane Nicoll
5407cf5f7a Prevent several registration of the same config pojo
This commit detects case where the same set of keys are exposed several
times and prevents the compilation to complete. Previously, duplicate
keys were silently added to the meta-data.

Closes gh-5939
2016-06-20 09:19:02 +02:00
Andy Wilkinson
7a5880c900 Merge branch '1.3.x' 2016-06-16 11:36:28 +01:00
Andy Wilkinson
ec7d6381aa Update RunMojo to fail when forked JVM returned non-zero exit code
Closes gh-6172
2016-06-16 11:34:15 +01:00
Andy Wilkinson
af20dc6cc4 Merge branch '1.3.x' 2016-06-15 20:52:18 +01:00
Andy Wilkinson
159ef8f189 Ensure that URL returned from ExplodedArchive.getURL() is encoded
Closes gh-5971
2016-06-15 20:47:29 +01:00
Andy Wilkinson
fc78a8de90 Merge branch '1.3.x' 2016-06-15 20:22:56 +01:00
Andy Wilkinson
c808de0021 Allow custom repackage task to be used without a global main class
Closes gh-5956
2016-06-15 20:17:51 +01:00
Dave Syer
9e8beb7323 Merge remote-tracking branch 'origin/1.3.x' 2016-06-14 09:56:18 +01:00
Dave Syer
e4b544bd39 Create PID_FOLDER if it doesn't exist
In fact the folder was already created if the app is running as
a different user, but not if running as the current user, so it
was just a question of moving one line out of an if block.

Fixes gh-5986
2016-06-14 09:54:58 +01:00
Phillip Webb
e27bc9ddea Merge branch '1.3.x' 2016-06-10 17:24:02 -07:00
Phillip Webb
f27bdcb737 Prevent APT crashes on older Java versions
Update TypeUtils to guard against the use of older Java versions.
Both `Collection` and `Map` type lookups now fallback to generic free
versions of the classes.

Prior to this commit using `xmlbeans-maven-plugin` in combination with
Spring Boot's annotation processor could result in
`IllegalArgumentException: Incorrect number of type arguments`.

Fixes gh-6122
2016-06-10 17:06:45 -07:00
Stephane Nicoll
f9288a3af1 Revert "Polish maven repositories definition"
This commit reverts 62fa602fea

See gh-6031
2016-06-10 17:25:31 +02:00
Stephane Nicoll
62fa602fea Polish maven repositories definition
Previously, Maven repositories definition was specified in a profile that
is active by default. It means that as soon as any profile is enabled by
the user, said profile is no longer enabled. This has the nasty
consequences of having copy/paste in several places to make sure our own
profiles still have the proper repositories definition.

This commit creates a single "repositories" profile that is always active
unless a given property is explicitely specified. This allows to remove
the duplication and make things more consistent.

Some Gradle-specific repositories were also hard-coded in two modules
without any profile at all, meaning they were polluting the build of
anybody using it. While the impacted modules are gradle specific, that
repository has been shared in the new "repositories" profile as well.

Closes gh-6031
2016-06-10 11:55:46 +02:00
Phillip Webb
77f6b4c983 Formatting 2016-06-09 20:45:37 -07:00
Andy Wilkinson
436b58acbf Merge branch '1.3.x' 2016-06-01 15:41:36 +01:00
Andy Wilkinson
3772d9f937 Update JarURLConnection to only require file read permission
Previously, JarURLConnection didn't override getPermission(). This
meant that it required all permissions. This was at odds with the
Oracle JVM's concrete sun.net.www.protocol.jar.JarURLConnection which
overrides getPermission to return a FilePermission with the read
action for the path of the underlying jar.

This commit updates our JarURLConnection to align its behaviour with
sun.net.www.protocol.jar.JarURLConnection.

Closes gh-5411
2016-06-01 15:33:36 +01:00
Andy Wilkinson
ac5afb142c Merge branch '1.3.x' 2016-05-25 17:42:51 +01:00
Andy Wilkinson
a98d1a41a4 Run Maven Plugin's integration tests when full profile is active
Closes gh-6036
2016-05-25 17:42:08 +01:00
Andy Wilkinson
fc1814919c Add jars that should have been commited in 6ed63a6 2016-05-25 17:41:12 +01:00
Stephane Nicoll
6ed63a6eff Add support of system-scoped dependencies
In Maven land, provided and system-scope dependencies are very similar,
the latter being an special kind that allows you to specify the path to
the artifact rather than using the repository to locate it.

Prior to this commit, the repackage goal of the maven plugin was
inconsistent as it would repackage provided-scope dependencies but would
ignore the system-scoped ones.

This commit adds an extra boolean flag, `includeSystemScope` to control
this behaviour. For backward compatibility reasons, its default value is
`false`.

Closes gh-2224
2016-05-24 16:25:54 +02:00
Andy Wilkinson
183613a5ca Merge branch '1.3.x' 2016-05-13 11:41:58 +01:00
Andy Wilkinson
4c65e5e704 Always handle quoted arguments correctly in the launch script
Previously, arguments passed to the script were handled in one way
if a service was being started using start-stop-daemon and in another
way if start-stop-daemon wasn’t available or the application is being
launched in run mode. This meant that quoted arguments were only 
handled correctly when the application was being started using
start-stop-daemon.

This commit updates the launch script so that argument handling is
the same across all three different way that the application can be
launched.

Closes gh-5942
2016-05-13 11:13:54 +01:00
Tommy Ludwig
bae567992d Polish Maven plugin doc
Closes gh-5938
2016-05-13 09:49:57 +02:00
Andy Wilkinson
e561cc1997 Don't use a separate thread in the launcher to call app's main method
Using a separate thread to call the application's main method is
unnecessary – the context class loader of the current thread can be
updated instead – and makes exception and exit code handling more
complicated than it needs to be.

This commit updates the Launcher so that it calls the main method
runner using the current (main) thread. As a result, any exception
that's thrown will be caught by the JVM and result in a non-zero exit
code being returned from the process.

Closes gh-5922
2016-05-12 16:57:16 +01:00
Phillip Webb
6575ca6ff8 Merge branch 1.3.x 2016-05-10 09:35:49 -07:00
Phillip Webb
7fb545d26c Polish 2016-05-10 09:35:10 -07:00
Christian Flamm
6bbd50e084 Update launch script to canonicalize jarfolder
Previously, if the folder which contained the jar was a symlink the
launch script would use the symlinked folder's name when determining
the default identity.

This commit updates the launch script so that symlinks are resolved
and the canonical name of the folder which contains the jar is used
when determining the script's default identity. The behaviour when
APP_NAME has been set is unchanged.

Closes gh-5679
Closes gh-5733
2016-05-10 16:20:33 +01:00
Spring Buildmaster
819a9574a6 Next Development Version 2016-05-10 05:28:34 +00:00
Spring Buildmaster
376bbe68d8 Next Development Version 2016-05-06 11:23:57 +00:00
Stephane Nicoll
21536f64e1 Polish info contributor feature
This commit improves the `InfoContributor` infrastructure as follows:

* `InfoEndpoint` no longer breaks its public API and returns a Map as
before
* `Info` is now immutable
* All properties of the build are now displayed. Since we control the
generation of that file, there is no longer a mode to restrict what's
shown
* Build info is now generated in `META-INF/build-info.properties` by
default

Closes gh-5734
2016-05-06 10:52:26 +02:00
Stephane Nicoll
6fe9177f0d Merge branch '1.3.x' 2016-05-02 10:40:27 +02:00
Stephane Nicoll
4ccc7dc554 Ignore invalid accessors
Previously, if a void method with a single argument was named "set", the
annotation processor wrongly considered it was a setter candidate. This
commit updates the condition to ignore it.

Closes gh-5826
2016-05-02 10:38:19 +02:00
Andy Wilkinson
3bfc6b1a4b Avoid packaging two versions of same dependency in Gradle repackaging
Previously, the Gradle plugin would include all of the dependencies
from both the compile and runtime configurations in the repackaged
jar. In the unlikely event that the compile and runtime configurations
contained different versions of the same dependency, this would lead
to both versions of the dependency being packaged in the jar file.

The runtime configuration extends the compile configuration so, in
normal circumstances, it will contain a superset of the compile
configuration's dependencies. In the situation described above where
the two configurations contain different versions of the same
dependency the runtime configuration will only contain whichever
version of the two dependencies has "won". By default, this will
be the dependency with the higher version.

This commit updates the Gradle plugin to only include the runtime
configuration's resolved dependencies during repackaging. As explained
above, the runtime configuration extends the compile configuration so
any compile dependencies will still be included, with the added
benefit that duplicate versions of the same dependency will have been
resolved to a single, preferred version.

Closes gh-5749
2016-04-21 11:37:40 +01:00
Johnny Lim
b914b4aa52 Remove the second parameter of substring() if possible
Closes gh-5720
2016-04-20 09:18:35 +02:00
Jakub Narloch
64989ae192 Replacing StringBuffer with lock-free StringBuilder
Closes gh-5727
2016-04-19 08:01:05 +02:00
Andy Wilkinson
e4324a5c77 Polishing
Make RunProcessKiller final
2016-04-18 14:55:35 +01:00
Andy Wilkinson
310be23ad5 Registered shutdown hook to kill JVM forked by spring-boot:run
Previously, a JVM that was forked by spring-boot:run could be orphaned
when the parent process (the Maven build) was terminated in an IDE. Note
that this doesn’t happen when spring-boot:run is invoked from a shell.

This commits add a shutdown hook that registered when RunMojo forks the
JVM. The shutdown hook attempts to kill the forked JVM’s RunProcess
rather than relying on the death of the parent process being sufficient
to also kill the child.

Closes gh-5815
2016-04-18 13:39:50 +01:00
Phillip Webb
caaf8e96b9 Reduce churn when parsing Jar files
Update CentralDirectoryParser to reduce the number of objects created
when parsing the central directory. A single CentralDirectoryFileHeader
object is now reused as entries are parsed.

Fixes gh-5260
2016-04-12 13:25:04 -07:00
Phillip Webb
5bc274ca09 Polish 2016-04-12 13:23:43 -07:00
Andy Wilkinson
0c78b2fd3d Handle fully-qualified Windows paths correctly in the CLI
Previously, the CLI would always use the class loader to try to locate
a source file. This was contrary to the SourceOptions javadoc which
states that the class loader is “used to try and load files that are
not found in the local filesystem”. This provide to be problematic on
Windows when a fully-qualified source file was supplied. The driver
letter colon slash (e.g. c:/) at the start of the path is considered
invalid for a class path resource by URLClassPath.Loader resulting in an
IllegalArgumentException being thrown.

A workaround for this URLClassPath behaviour was added in a71c9b5d. It
was removed as part of reworking LaunchedURLClassLoader to use a
conventional delegation model in 87fe0b2a. It was then reinstated in
cc140b2c. This work around is undesirable as it causes
LaunchedURLClassLoader’s behaviour to diverge from URLClassLoader’s
behaviour (this is contrary to the comments in the test added in
a71c9b5d which incorrectly tests the two class loader with different
class paths. If the two class loaders are created with the same class
path then their behaviour is the same).

This commit updates SourceOptions to make its behaviour match its
javadoc so that a search of the class path is only performed if the
filename doesn’t exist on the filesystem. Furthermore, when running on
Windows, if the filename is an absolute path no further searching is
performed as the path cannot reliably be used to search the class path
due to the behaviour of URLClassPath.Loader when given a path that
is an absolute file path on Windows. This ensures that the user is
presented with an error message indicating that the file could not be
found.

Closes gh-5650
2016-04-11 16:27:50 +01:00
Johnny Lim
b5f92611aa Use the passed parameter in BuildInfo.coerceToStringValues()
Closes gh-5652
2016-04-11 09:24:52 +01:00
Phillip Webb
cc140b2c34 Reinstate escape hatch for findResource()
Reinstate the defensive call of super.findResource() in
LaunchedURLClassLoader.

Closes gh-5650
See gh-486
2016-04-10 21:29:20 -07:00
Phillip Webb
7709352c2d Tweak timings for Windows build 2016-04-10 14:35:39 -07:00
Phillip Webb
61b7e6f3b3 Merge branch '1.3.x' 2016-04-10 12:13:28 -07:00
Phillip Webb
af2483816b Fix JarFileTests to work on Windows
See gh-5287
2016-04-10 12:12:19 -07:00
Andy Wilkinson
d1a487333d Merge branch '1.3.x' 2016-04-06 17:17:18 +01:00
Andy Wilkinson
74e27db486 Polish contribution 2016-04-06 17:04:10 +01:00
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
2016-04-06 17:02:59 +01:00
Andy Wilkinson
1d4e52cc2b Merge branch '1.3.x' 2016-04-06 11:47:42 +01:00
Christian Brunotte
677080b8e2 Update launch.script so popd does not print directory name to stdout
Closes gh-5394
2016-04-06 11:46:36 +01:00
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
2016-04-05 16:30:50 +01:00
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
2016-04-05 16:28:36 +01:00
Andy Wilkinson
f55066464d Merge branch '1.3.x' 2016-04-01 11:53:35 +01:00
Phillip Webb
893a6c32f3 Upgrade to checkstyle 6.17
Fixes gh-5547
2016-03-31 13:14:53 -07:00
Andy Wilkinson
4f200a852b Add missing jar file
It should have been in 68b83a8f but was excluded by gitignore.

See gh-3701
2016-03-31 13:16:55 +01:00
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
2016-03-31 10:33:03 +01:00
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
2016-03-31 09:42:11 +01:00
Phillip Webb
39140945b5 Polish 2016-03-29 21:45:11 -07:00
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
2016-03-29 11:35:38 +01:00
Andy Wilkinson
fc463afb89 Merge branch '1.3.x' 2016-03-29 11:16:16 +01:00
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
2016-03-29 11:03:47 +01:00
Phillip Webb
faba7a9514 Rename internal OutputCapture classes
Rename the internal versions of OutputCapture to prevent accidental
import.

See gh-5492
2016-03-25 12:46:52 -07:00
Andy Wilkinson
c42f859390 Ensure that ExplodedArchive lists its file in a consistent order
Closes gh-5422
2016-03-24 17:35:40 +00:00
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
2016-03-24 15:59:01 +00:00
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
2016-03-24 15:59:01 +00:00
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
2016-03-24 08:59:55 +00:00
Phillip Webb
7942d9f787 Polish 2016-03-21 22:52:25 -07:00
Stephane Nicoll
10012cfddc Rename Maven plugin mojo
Rename the goal from `generate-build-info` to `build-info` for consistency.

See gh-2559
2016-03-17 16:58:08 +01:00
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
2016-03-10 17:21:31 +01:00
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
2016-03-09 12:30:35 +00:00
Phillip Webb
644ae2c21a Merge branch '1.3.x' 2016-03-08 09:51:57 -08:00
Phillip Webb
5e722dae6a Polish 2016-03-08 09:37:13 -08:00
Stephane Nicoll
cc2f6f4b9c Merge branch '1.3.x' 2016-03-08 10:07:06 +01:00
Stephane Nicoll
a83dae0e10 Polish contribution
Closes gh-5335
2016-03-08 10:01:14 +01:00
Eric Bottard
79cd01eb7a Fix configuration property name when group is empty
See gh-5335
2016-03-08 09:48:26 +01:00
Phillip Webb
73cbb2f40a Polish 2016-03-03 09:14:24 -08:00
Stephane Nicoll
c6c001457a Fix description of classifier attribute
See gh-5258
2016-03-01 11:15:10 +01:00
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
2016-03-01 11:12:59 +01:00
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
2016-02-29 15:11:28 +00:00
Andy Wilkinson
779649bfdb Merge branch '1.3.x' 2016-02-29 14:53:52 +00:00
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
2016-02-29 14:44:27 +00:00
Uwe Schaefer
9c3003071b Add CONF_FOLDER property
Closes gh-5203
2016-02-29 11:36:59 +01:00
Spring Buildmaster
225d877ab9 Next Development Version 2016-02-26 01:06:16 -08:00
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
2016-02-25 12:25:41 +00:00
Andy Wilkinson
44ddfcc7fa Upgrade copyright headers of all files changed in 2016 2016-02-25 12:09:42 +00:00
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
2016-02-25 11:48:03 +00:00
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
2016-02-19 19:28:37 -08:00
Phillip Webb
4b55144d80 Polish 2016-02-19 16:19:22 -08:00
Andy Wilkinson
5ed4ef1272 Add manifest entries for location of lib and classes in executable archives
Closes gh-5183
2016-02-19 17:04:51 +00:00
Andy Wilkinson
fcbf15aea3 Update Ant support following changes the executable jar layout
Closes gh-4897
2016-02-19 15:00:25 +00:00
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
2016-02-19 14:15:40 +00:00
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
2016-02-17 15:25:03 +01:00
Phillip Webb
00cfe1d054 Use AssertJ in spring-boot-tools
See gh-5083
2016-02-06 15:51:26 -08:00
Phillip Webb
516afcd2ca Polish 2016-02-06 15:02:12 -08:00
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
2016-02-04 14:15:49 +00:00
Johnny Lim
46540de694 Fix typos
Closes gh-5067
2016-02-02 11:19:07 +01:00
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
2016-01-29 21:42:19 -08:00
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
2016-01-29 21:42:18 -08:00
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
2016-01-29 21:42:18 -08:00
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
2016-01-26 09:59:37 +01:00
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
2016-01-25 14:06:06 +01:00
Phillip Webb
fbaf209240 Move master to 1.4.0.BUILD-SNAPSHOT 2016-01-24 10:45:24 -08:00
Spring Buildmaster
504d3e97ba Next development version 2016-01-21 18:41:30 -08:00
Phillip Webb
93c3b22bb4 Merge branch '1.2.x' 2016-01-21 11:14:20 -08:00
Phillip Webb
c71aa32fbb Polish 2016-01-21 10:53:25 -08:00
Andy Wilkinson
9dc858cdf5 Add missing properties to RepackageTask and improve test coverage
Closes gh-4978
2016-01-21 17:04:25 +00:00
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
2016-01-21 14:58:51 +00:00
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
2016-01-21 09:57:13 +00:00
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
2016-01-18 09:45:06 +01:00
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
2016-01-15 17:02:42 +00:00
Andy Wilkinson
89beef4099 Merge branch '1.2.x' 2016-01-14 17:09:40 +00:00
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
2016-01-14 17:05:08 +00:00
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
2016-01-14 10:37:45 +00:00
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
2016-01-14 10:37:37 +00:00
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
2016-01-13 16:22:35 +00:00
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
2016-01-13 13:28:14 +00:00
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
2016-01-13 13:28:14 +00:00
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
2016-01-13 13:28:14 +00:00
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
2016-01-13 12:31:37 +00:00
Andy Wilkinson
2aff82bb64 Merge branch '1.2.x' 2016-01-12 10:19:36 +00:00
Andy Wilkinson
6117b6c5c8 Consistent use of tabs for indentation in pom files 2016-01-12 10:16:40 +00:00
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
2015-12-24 11:44:55 +01:00
Spring Buildmaster
8db59059a5 Next Development Version 2015-12-18 05:43:02 -08:00
Stephane Nicoll
bb736e255b Fix SNAPSHOT version 2015-12-17 14:15:14 +01:00
Kirill Vlasov
ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
2015-12-16 21:02:53 +00:00
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
2015-12-16 20:59:33 +00:00
Michitomo Nakahara
2b5b7cd81e Update launch.script to append to $log_file rather than overwriting it
Closes gh-4506
2015-12-16 17:05:29 +00:00
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
2015-12-16 13:53:26 +00:00
Andy Wilkinson
81a4763940 Address problems in launch.script reported by Shellcheck 0.4.1
Closes gh-4653
2015-12-16 13:24:28 +00:00
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
2015-12-15 20:37:43 +00:00
Phillip Webb
34b31f1abc Protect against null description
Update `removeLineBreaks` to also work with `null`.

See gh-4703
2015-12-11 17:40:28 +00:00
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
2015-12-11 13:57:14 +00:00
Phillip Webb
2d2e4eea82 Merge branch '1.2.x' 2015-12-10 15:01:29 +00:00
Phillip Webb
2694605a4d Polish 2015-12-10 14:43:00 +00:00
mnhock
7348ef5ef1 Remove double instantiation of Manifest
Closes gh-4701
2015-12-08 11:05:40 +01:00
Johnny Lim
ec7fed1ecc Polish
Closes gh-4677
2015-12-07 20:46:36 +01:00
Andy Wilkinson
46edee2e45 Only make bootRun depend on findMainClass and not all java exec tasks
Closes gh-4639
2015-12-04 14:36:07 +00:00
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
2015-12-03 09:57:30 +00:00
吉田 尚弘
02363b38eb Make launch script's chkconfig configurable via a property
Closes gh-4564
2015-12-02 10:12:03 +00:00
Andy Wilkinson
0f032eeb8a Address warnings reported by shellcheck for changes made in 7011944
Closes gh-4524
2015-12-01 12:44:10 +00:00
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
2015-12-01 11:47:22 +00:00
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
2015-11-30 09:51:15 +01:00
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
2015-11-26 20:25:00 +01:00
Stephane Nicoll
ae13082e0d Generate meta-data for nested Lombok types
Closes gh-4397
2015-11-26 20:23:24 +01:00
Johnny Lim
8ec00c35bf Polish
Closes gh-4572
2015-11-21 08:12:21 +01:00
Johnny Lim
36ed0f5c20 Polish
Closes gh-4537
2015-11-19 09:49:33 +00:00
Spring Buildmaster
3f6f57a80e Next Development Version 2015-11-16 03:18:54 -08:00
Johnny Lim
0a85281a66 Fix typos
Closes gh-4463
2015-11-13 13:54:50 +01:00
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
2015-11-10 11:16:00 -08:00
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
2015-11-09 14:27:05 -08:00
Phillip Webb
6c2ea4648f Polish 2015-11-03 20:36:20 -08:00
Dave Syer
fa9724becb Revert "Add or avoid proxy configurations for integration tests"
This reverts commit 251f2805a8.
2015-11-02 17:38:54 +00:00
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
2015-11-02 17:23:30 +00:00
ZakarFin
efa7303507 Fix linux service script command syntax
Closes gh-4359
2015-11-01 13:31:58 +01:00
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
2015-10-31 10:16:24 +01:00
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
2015-10-30 15:10:02 +00:00
Andy Wilkinson
1ef68ef231 Correct the reference to jarfolder in the init script
Closes gh-4287
2015-10-28 14:32:11 +00:00
Andy Wilkinson
17f61c1dad Update javadoc of LaunchedURLClassLoader to describe delegation model
Closes gh-3864
2015-10-27 10:09:10 +00:00
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
2015-10-20 17:48:22 -07:00
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
2015-10-20 15:04:25 +02:00
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
2015-10-20 11:27:43 +01:00
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
2015-10-20 11:50:29 +02:00
Phillip Webb
90f7bc0321 Polish 2015-10-19 13:04:06 -07:00
Phillip Webb
634bb770b2 Organize imports with new settings
See gh-4234
2015-10-19 12:58:34 -07:00
Phillip Webb
1e4d974ec0 Merge remote-tracking branch 'local12x/1.2.x' 2015-10-19 12:56:55 -07:00
Phillip Webb
a79131f8d2 Organize imports with new settings
See gh-4234
2015-10-19 12:55:44 -07:00
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
2015-10-19 11:38:22 +01:00
Spring Buildmaster
2b38a861e3 Next Development Version 2015-10-16 05:57:24 -07:00
Phillip Webb
03d54fa1d0 Polish 2015-10-15 16:15:23 -07:00
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
2015-10-15 16:57:52 +02:00
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
2015-10-14 23:16:53 -07:00
Andy Wilkinson
30f24eac0a Merge branch '1.2.x' 2015-10-14 16:33:55 +01:00
Andy Wilkinson
7e718cda26 Remove redundant hash from path of unpacked nested library
Closes gh-4124
2015-10-14 16:32:58 +01:00
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
2015-10-14 01:22:57 -07:00
Andy Wilkinson
6c4e4520d4 Merge branch '1.2.x' 2015-10-12 10:37:25 +01:00
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
2015-10-12 10:33:33 +01:00
Andy Wilkinson
9c14ed3502 Remove stale Java source from src/main/groovy in the Gradle plugin
Closes gh-4113
2015-10-12 10:30:31 +01:00
Phillip Webb
6333426cbf Reformat package-info.java files with Eclipse Mars 2015-10-09 13:54:25 -07:00
Phillip Webb
04074fece1 Merge branch '1.2.x' 2015-10-09 13:39:09 -07:00
Phillip Webb
94736719f1 Reformat package-info.java files with Eclipse Mars 2015-10-09 13:32:57 -07:00
Andy Wilkinson
2afb641603 Merge branch '1.2.x' 2015-10-09 15:21:21 +01:00
Andy Wilkinson
04c2bd9c89 Update tests to expect additional entry in test jar
Closes gh-4124
2015-10-09 15:19:50 +01:00
Andy Wilkinson
8948322d7a Merge branch '1.2.x' 2015-10-09 14:59:54 +01:00
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
2015-10-09 14:59:18 +01:00
Phillip Webb
aae38db9af Fix compiler warnings only shown in Eclipse Mars 2015-10-07 23:40:28 -07:00
Phillip Webb
c9fb9916b8 Reformat code using Eclipse Mars 2015-10-07 23:37:10 -07:00
Phillip Webb
e473364e4e Merge branch '1.2.x' 2015-10-07 23:34:08 -07:00
Phillip Webb
6ab376e2e8 Reformat code use Eclipse Mars 2015-10-07 23:32:31 -07:00
Phillip Webb
47576354f7 Merge branch '1.2.x' 2015-10-07 23:19:50 -07:00
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
2015-10-07 23:12:25 -07:00
Thomas Raehalme
3865f3b303 Allow launch script to be used by accounts that use /sbin/nologin
Closes gh-3852
Closes gh-3906
2015-10-05 11:08:52 +01:00
Andy Wilkinson
051ebf3fac Polishing: fix a number of compiler warnings reported by Eclipse 2015-09-22 13:30:07 +01:00
Andy Wilkinson
94a737638e Update launch script to specify -jar as last option
The recommended usage for the java executable is:

    java [-options] -jar jarfile [args...]

This commit updates the default launch script to match this recommended
usage by moving -jar to be the last option, after both the
disableJarChecking system property and any JAVA_OPTS.

Closes gh-3930
2015-09-21 14:51:03 +01:00
Spring Buildmaster
9409c49c10 Next development version 2015-09-16 09:00:17 -07:00
Phillip Webb
269815dbcf Make LaunchedURLClassLoader constructor public
Restore the public constructor in LaunchedURLClassLoader which was
accidentally removed in commit e07df7e4c6.
2015-09-09 09:20:34 -07:00
Phillip Webb
e674d751de Polish Javadoc 2015-09-08 17:01:36 -07:00
Phillip Webb
e07df7e4c6 Remove redundant modifiers 2015-09-08 17:01:30 -07:00
Phillip Webb
460ca75fce Polish newline at end of file 2015-09-08 16:05:22 -07:00
Phillip Webb
d09805fd75 Polish license headers 2015-09-08 16:05:05 -07:00
Phillip Webb
6e29ee4557 Polish 2015-09-08 16:04:30 -07:00
Phillip Webb
67402405db Reformat code 2015-09-08 14:56:40 -07:00
Phillip Webb
2615990ffb Organize imports 2015-09-08 14:40:35 -07:00
Phillip Webb
0335053139 Merge branch '1.2.x' 2015-09-08 14:37:16 -07:00
Phillip Webb
15686ed4fd Reformat code 2015-09-08 14:07:06 -07:00
Phillip Webb
0f6b60d8c8 Organize imports 2015-09-08 14:05:00 -07:00
Phillip Webb
690da89c82 Fix warnings 2015-09-05 00:21:09 -07:00
Ilayaperumal Gopinathan
61ac04aa4c Make it easier to subclass Launchers
Change constructors from `package private` to `protected` for subclasses
to use.

Closes gh-3741
2015-09-03 14:40:23 -07:00
Phillip Webb
4aa2fed48b Revert "configure JRE that is different from compiler target level"
This reverts commit 678f36cfef.
2015-09-02 23:44:27 -07:00
Dave Syer
9dec0971d6 Change restart to fail if not running 2015-08-27 07:30:00 +01:00
Dave Syer
ff681adc5b Fix launch.script to not exit prematurely
Use "return" instead of "exit" where possible, especially in
function definitions.

Also fixed the exit codes to match the LSB spec for some specific
conditions (fixes gh-3521).

Fixes gh-3199, fixes gh-3535
2015-08-26 17:54:20 +01:00
Stephane Nicoll
35875c7f08 Merge manual item meta-data
Previously, manual meta-data were added to the existing set of entries
which could lead to duplicates if a manual entry is meant to complement
a property that is detected via the processor.

We now match the name and type of the item against the auto-detected
entries. If no match is found, we add the extra entry as we did before.
If a match is found we override the description, default value and
deprecation information.

Closes gh-3562
2015-08-20 17:08:54 +02:00
Martin Lippert
678f36cfef configure JRE that is different from compiler target level 2015-08-19 17:00:38 +01:00
Martin Lippert
511c6d39fa Replace ignore with lifecycle mapping to smooth import into Eclipse
Closes gh-3516
2015-08-13 13:24:15 +01:00
Stephane Nicoll
3763eda64e Merge branch '1.2.x' 2015-08-10 16:36:11 +02:00
Stephane Nicoll
1ee31e73d3 Avoid NPE if @ConfigurationProperties is not present
The annotation processor detects `@ConfigurationProperties` bean or
method definition and merges manual meta-data. The former step will fail
with a NPE if the annotation is not present on the classpath. This could
happen if the annotation processor is added to a module that is not
actually using Spring Boot.

We now have a defensive check that skips that steps but still attempts to
merge manual meta-data if present.

Closes gh-3720
2015-08-10 16:34:30 +02:00
Dave Syer
25ac258d22 Clarify plugin documentation for requiresUnpack 2015-08-10 12:52:00 +01:00
Phillip Webb
891dd5a0f6 Polish 2015-08-03 11:03:48 -07:00
Andy Wilkinson
4660a3ed4d Merge branch '1.2.x' 2015-08-03 15:50:26 +01:00
Andy Wilkinson
d241171fff Use fast exceptions in hasMoreElements in LaunchedURLClassLoader
When nested jars are being used, hasMoreElements requires opening a
connection for an entry in every nested jar. If that entry doesn't
exist, a FileNotFoundException is thrown to indicate that a particular
jar doesn't contain the requested entry. This exception is used to
indicate the lack of an entry and is then swallowed, i.e. its stack
trace is of no importance. This means that the performance of
hasMoreElements can be improved by switching on fast exceptions while
it's being called. When fast exceptions are switched on a general
purpose pre-initialized FileNotFoundException is thrown rather than
creating a new FileNotFoundException instance each time.

In certain situations, the use of fast exceptions as described above
can improve performance fairly significantly. The JRE's default SAAJ
implementation uses META-INF/services-based discovery for _every_
request that's handled by Spring Web Services. Each discovery attempt
results in hasMoreElements being called making its performance
critical to throughput.

See gh-3640
2015-08-03 15:39:56 +01:00
Stephane Nicoll
bc0487f791 Polish
Make sure that the meta-data can be serialized.
2015-07-29 14:01:21 +02:00
arghya88
64c6e5b403 Fix typo
Closes gh-3610
2015-07-28 10:39:10 +02:00
arghya88
9de4fd7913 Fix typo
Closes gh-3606
2015-07-27 15:30:48 +02:00
Stephane Nicoll
057824aca7 Fix maven plugin configuration
Closes gh-3601
2015-07-27 08:18:09 +02:00
Stephane Nicoll
94405455dd Fix maven plugin configuration
Closes gh-3601
2015-07-26 09:09:43 +02:00
Stephane Nicoll
e033daed0f Use standard name for main thread
DevTools look for a main thread named "main". The maven plugin is
actually using a different value and there is no real reason to. This
change fixes DevTools support as long as forking is enabled.

See gh-3315
2015-07-24 10:36:14 +02:00
Stephane Nicoll
42e230192f Polish 2015-07-24 07:19:53 +02:00
Stephane Nicoll
e9a6245a44 Remove unnecessary System.out 2015-07-22 16:59:53 +02:00
Stephane Nicoll
178c690d37 Fix meta-data root attributes ordering 2015-07-22 16:59:25 +02:00
Andy Wilkinson
434f528e0a Fix Gradle plugin task dependencies broken by removal of app plugin
8673250 updated the plugin so that the application plugin is no longer
applied by default. This exposed three problems:

 1. bootRepackage may run before findMainClass has run, leaving it with
    an unknown main class.
 2. findMainClass may run before the classes have been built, making it
    unable to find the main class by examining the class files
 3. The project's mainClassName property was still being used as a
    convention for the bootRun task's main property. If the application
    plugin has not be applied, then this property does not exist.

The first problem has been addressed by configuring bootRepackage to
depend on findMainClass.

The second problem has been addressed by configuring the main source
set's output as an input of findMainClass, and configuring findMainClass
to depend on the tasks that build the output.

The third problem has been addressed by only using the mainClassName
property if it exists and its value is not null. We then fallback to
using the mainClassName property on the project's extra properties in
the same way. 

See gh-2679
2015-07-22 13:47:29 +01:00
Andy Wilkinson
8673250955 Make use of Gradle's application plugin optional when using Boot plugin
Previously, the Spring Boot Gradle plugin would always apply the
application plugin to a project. It then piggy-backed on the application
plugin’s mainClassName and applicationDefaultJvmArgs properties for the
configuration of the bootRun task.

This commit updates the Spring Boot Gradle plugin so that it no longer
applies the application plugin. If the user applies the application
plugin then its configuration will be used, but it’s a no longer
requirement.

Users who do not need the application plugin, but who were using the
mainClassName or applicationDefaultJvmArgs properties will need to
change their builds as a result of this change as those properties will
no longer exist. As before, the mainClassName can be configured on the
springBoot extension:

springBoot {
	mainClassName 'com.example.YourApplication'
}

The applicationDefaultJvmArgs property can be used, but it must now be
declared with the project's ext block. For example:

ext {
	applicationDefaultJvmArgs = [ '-Dcom.example.property=true' ]
}

Closes gh-2679
2015-07-22 11:38:15 +01:00
Phillip Webb
e9d252e05c Add @DeprecatedConfigurationProperties annotation
Add a new @DeprecatedConfigurationProperties annotation which can be
used by the `ConfigurationMetadataAnnotationProcessor` to generating
meta-data deprecated blocks.

Fixes gh-3543
2015-07-17 14:14:37 -07:00
Phillip Webb
728e64b929 Polish 2015-07-16 12:56:49 -07:00
izeye
f4589e7cc3 Fix typos
Closes gh-3504
2015-07-15 15:45:02 +02:00
Stephane Nicoll
f2d32d3e98 Add support for property deprecation
Previously, an item could only have a 'deprecated' boolean flag to
indicate that the property is deprecated. It is desirable to provide an
additional description for the deprecation as well as the name of the
property to use instead.

The `deprecated` boolean flag is now supported. Instead, a `deprecated`
object can be specified with two optional attributes: `reason` to provide
an explanation for the deprecation and `replacement` to refer to the
property that should be used instead. If none of them is present, an
empty deprecation object should be set.

For backward compatibility, the `deprecated` field is still set.

Deprecation information can only set via manual meta-data.

Closes gh-3449
2015-07-15 15:41:52 +02:00
izeye
019140c901 Remove redundant check
Closes gh-3497
2015-07-15 09:58:15 +02:00
Phillip Webb
f0f5f78e25 Polish 2015-07-14 22:17:52 -07:00
Stephane Nicoll
68d875bdc6 Fix windows build 2015-07-14 21:39:54 +02:00
Stephane Nicoll
c4c24b1f44 Detect default value from factory method
If a field is initialized via a factory method taking a single argument,
we can relatively safely consider that said argument is a good
representation of its default value. This is typically the case for
Charset or MimeType instances.

We now make sure to detect such use case (i.e. method argument with a
single argument).

Closes gh-3482
2015-07-14 15:08:43 +02:00
Dave Syer
de02eaa26b Add missing jar (.gitignored) 2015-07-14 12:44:23 +01:00
Dave Syer
bfa816f2a3 Maintain classpath order in PropertiesLauncher
I think this is safe, judging by the integration tests, but I'm not
putting it in 1.2.x until we've had some feedback on it. The
integration tests actually had a bug that was masking this problem
because they were merging Properties from the whole classpath instead
of picking the first available resource (which is generally what
we do in Spring Boot applications for application.properties for
instance).

Fixes gh-3048
2015-07-14 10:22:36 +01:00
Phillip Webb
9ebe15232e Polish 2015-07-13 11:05:46 -07:00
Stephane Nicoll
cb5eccb5c1 Add missing handle-as meta-data
Liquibase has a `changeLog` property that is definitely used as a
`Resource` but cannot be defined as such as the original String value
should be kept against an API we don't control.

Update the tests also to make it more clear that if hints are added
against a property that is detected automatically, said property still
keeps all its auto-discovered capabilities.

Closes gh-3457
2015-07-13 13:45:23 +02:00
Stephane Nicoll
d64ee99b20 Add configuration meta-data parser
Add a new `spring-boot-configuration-metadata` module that provides an
API to manipulate Spring Boot configuration meta-data. Can read meta-data
from arbitrary locations, though the standard
`META-INF/spring-configuration-metadata.json` location must be preferred.

Closes gh-1970
2015-07-13 11:53:31 +02:00
izeye
f85f316873 Polish toString()
Closes gh-3465
2015-07-13 09:52:29 +02:00
Stephane Nicoll
3664895f04 Polish 2015-07-12 09:20:12 +02:00
Dave Syer
b2a2c5b168 Add Maven incantation to make STS 3.7 happy 2015-07-10 15:56:40 +01:00
Phillip Webb
e3b59774c8 Merge branch '1.2.x' 2015-07-09 10:37:30 -07:00
Phillip Webb
4b17f3ceef Formatting 2015-07-09 10:37:21 -07:00
Andy Wilkinson
a2d58030dd Merge branch '1.2.x' 2015-07-09 16:42:37 +01:00
Andy Wilkinson
68e54e1d5d Favour entries in source jar over standard libraries when repackaging
When writing a jar, once an entry has been written it will never be
overwritten, i.e. the first write of a given entry will win. Previously,
when repackaging a jar, the existing contents were written followed by
any libraries. This caused a problem when repackaged a WAR file and
a library needed to be unpacked as the existing entry in WEB-INF/lib
would prevent the library with the UNPACK comment from being written.
This was addressed in f761916b by inverting the order so libraries
would take precedence over entries in the source jar.

It’s now become apparent that this change in the order causes a problem
for users who are obfuscating their code. The obfuscated code exists in
the source jar but is also provided to the repackager in its original
form as a library. When libraries take precedence, this means that the
code in its original form ends up in the repackaged war and the
obfuscation is lost.

This commit updates the repackager to write libraries that require
unpacking first. This allows the UNPACK comment to be written even if
there’s also a source entry for the library. Next, source entries are
written. This allows obfuscated source entries to take precedence over
any unobfuscated library equivalents. Lastly, standard libraries that
do not require unpacking are written into the repackaged archive.

Closes gh-3444
2015-07-09 16:37:10 +01:00
Stephane Nicoll
97634e85ac Remove unnecessary keyword 2015-07-09 14:33:01 +02:00
Andy Wilkinson
2263095bbb Update launch.script to match chkconfig start levels with defaults
Closes gh-3419
2015-07-07 17:57:47 +01:00
Phillip Webb
0cf6efca4f Polish 2015-07-06 13:05:09 -07:00
Stephane Nicoll
e307fe3137 Honor outputDirectory properly
Previously, if the repackaged file was different from the main artifact
of the build, the maven plugin wrongly considered that it should attach
the file with a classifier.

The outputDirectory is honored properly now, regardless of the fact a
classifier is defined or not.

Fixes gh-3177
2015-07-06 15:24:48 +02:00
Stephane Nicoll
162cbdd5cb Fail the build if the meta-data are invalid
Make sure to fail the build with a proper compilation error message if
the user-defined meta-data are invalid. For now, this takes care of the
JSON format but other checks may be added in the future.

Closes gh-3329
2015-07-06 11:35:57 +02:00
Spring Buildmaster
7ce391db4f Next development version 2015-07-01 22:48:01 -07:00
Phillip Webb
b1f8a692a8 Merge branch '1.2.x' 2015-07-01 19:30:12 -07:00
Phillip Webb
a1b87766a7 Fix PropertiesLauncher javadoc
See gh-3392
2015-07-01 18:09:56 -07:00
Matt Benson
ae4559eb4f Create spring-boot-antlib module
Create a new spring-boot-antlib module which allows Apache Ant users
to easily create executable jars.

Fixes gh-3339
2015-06-30 00:30:28 -07:00
Phillip Webb
7879743b9f Polish 2015-06-25 12:00:48 -07:00
Stephane Nicoll
0ec9de9137 Add support for value provider
Improve the "hints" section of the metadata so that each hint can provide
the reference to a value provider.

A value provider defines how a tool can discover the potential values of
a property based on the context. The provider is identifed by a name and
may have an arbitrary number of parameters.

Closes gh-3303
2015-06-25 14:58:10 +02:00
Phillip Webb
778e3eb091 Polish 2015-06-24 16:15:12 -07:00
Stephane Nicoll
bc9321734f Add support for property hint
Create a new section in the meta-data called "hints" where users can
provide hints about a given property. The most basic use case for now
is to provide a list of values that a property can have. Each value may
have a description.

This sample JSON provides a basic example for a property called `foo.mode`
that exposes 3 values: "auto", "basic" and "advanced".

```
 "hints": [
    {
      "id": "foo.mode",
      "values": [
        {
          "value": "auto",
          "description": "Some smart description."
        },
        {
          "name": "basic"
        },
        {
          "name": "advanced"
        }
      ]
    }
]
```

This information can be read by tools (such as IDE) and offer an
auto-completion with the list of values.

Closes gh-2054
2015-06-24 18:53:11 +02:00
Phillip Webb
61fc4f3f12 Polish copyright headers 2015-06-23 10:22:14 -07:00
Phillip Webb
f22c91ac94 Add chkconfig comment to launch script
Update the embedded launch script to include a `chkconfig` comment. This
solves the "Service doesn't support chkconfig" error when executing
the chkconfig command.

Fixes gh-3115
2015-06-19 15:43:05 -07:00
Phillip Webb
f65dfe4bcb Fix javadoc errors and warnings 2015-06-19 14:04:55 -07:00
Johannes Stelzer
f0bb60bf9d Improve executable jar launch script
Update the launch script used in fully executable jars to:

- Include LSB-Header comments
- Source `.conf` files either next to the jar for additional script
  configuration

Fixes gh-3243
2015-06-18 23:11:07 -07:00
Phillip Webb
2f16a01dd5 Polish 2015-06-18 14:11:40 -07:00
Daniel Young and Mathew Johnson
e3c2fb7287 Add useTestClassPath to run/start maven goals
Add `useTestClasspath` flag to add test dependencies to the classpath of
the application. Works with both the `start` and `run` goals.

Closes gh-2792
2015-06-18 09:33:44 +02:00
Phillip Webb
d87f2713af Merge branch '1.2.x' 2015-06-15 11:38:24 -07:00
Phillip Webb
135e9d10a6 Polish 2015-06-15 10:52:02 -07:00
Stephane Nicoll
f87b2be2f9 Update default JMX name used by Maven plugin
Closes gh-3124
2015-06-10 17:31:06 +02:00
Stephane Nicoll
e0787cbaf0 Polish
Review 105039c that still refer to "lifecycle" instead of "admin". In
particular, harmonized the configuration properties.

Closes gh-3124
2015-06-10 11:28:47 +02:00
Stephane Nicoll
18c65f6e63 Merge branch '1.2.x' 2015-06-10 10:31:00 +02:00
Lugi Cardito
a37e983296 Create output directory if necessary
If the `repackage` goal defines an output directory that does not exist,
the maven plugin now creates it.

Closes gh-3136
2015-06-10 10:27:53 +02:00
Phillip Webb
105039cdb2 Rename SpringApplicationLifecycle => Admin
Rename SpringApplicationLifecycle JMX beans to SpringApplicationAdmin
and relocate to a dedicated package.

Fixes gh-3124
2015-06-09 16:06:28 -07:00
Phillip Webb
7609c43685 Switch Javadoc <code>...</code> to {@code ...}
Update Javadoc to use the {@code ...} syntax when possible.
2015-06-05 10:10:34 -07:00
Eddú Meléndez
baca62a6c0 Fix typos 2015-06-05 16:59:51 +02:00
Phillip Webb
316b07d3b9 Change the embedded script default to disabled
Update the Maven and Gradle repackage tasks so that the embedded
startup script is no longer included by default. This change is
primarily due to the `cf` command line not currently accepting
the unusual jar format.

Fixes gh-3045
2015-06-04 21:59:27 -07:00
Phillip Webb
bce4bb8860 Polish start stop support 2015-06-04 01:09:53 -07:00
Spring Buildmaster
5d81c87b43 Next Development Version 2015-06-04 00:49:11 -07:00
Phillip Webb
49c4710f63 Merge branch '1.2.x' 2015-06-02 12:32:46 -07:00
Phillip Webb
968b68c322 Polish 2015-06-02 11:17:16 -07:00
Stephane Nicoll
4ec519fd08 Merge branch '1.2.x' 2015-05-26 16:21:23 +02:00
Stephane Nicoll
f25ce8a381 Fix artifact extension retrieval
Do not rely on the packaging type to figure out what the extension of the
main artifact will be. So far, using `jar` and `war` packaging for `.jar`
and `.war` files worked by chance.

We know retrieve the actual extension as provided by Maven's
`ArtifactHandler`.

Fixes gh-2762
2015-05-26 16:21:00 +02:00
Andy Wilkinson
b7a02feda8 Make the Maven plugin’s start and stop tests more robust
- Verify that isReady has been called
 - When forking, use a random port for JMX
 - Don’t wait for application termination as it introduces a race
   condition and verifying that shutdown has been requested is
   sufficient

See gh-2525
2015-05-19 15:26:03 +01:00
Stephane Nicoll
e0dfe9fb86 Add start/stop goals to maven plugin
SpringApplicationLifecycle provides basic lifecycle operations on the
current Spring Boot application (that is checking if the application has
fully started and gracefully terminate the app). It can be registered as
an MBean of the platform MBean server if a specific property is set.

The Maven plugin uses that MBean to check that the application is ready
before ending the "start" phase. It uses it to trigger a proper shutdown
of the application during the "stop" phase.

If the process has to be forked, the platform MBean server is exposed on
a configurable port so that the maven plugin can connect to it.

Such change permits the maven plugin to integrate a classical integration
test scenario where the "start" goal is invoked during the
pre-integration phase and the "stop" goal during the post-integration
phase.

Closes gh-2525
2015-05-19 11:22:47 +02:00
Andy Wilkinson
63a7b24d27 Fix test that was broken in b24e736c 2015-05-12 10:46:25 +01:00
Dave Syer
b24e736cfe Add env var parameters to launch.script
Some of the features of the launch.script were not exposed for users
to be able to control at runtime. It now accepts things like
PID_FOLDER and LOG_FOLDER as environment variables, and also adopts
a clear naming convention where only the inputs are UPPER_CASE.
2015-05-12 10:23:44 +01:00
Andy Wilkinson
51c49b69c5 Support bom-based dependency management in the CLI
Previously, the CLI’s dependency management used proprietary Properties
file-based metadata to configure its dependency management. Since
spring-boot-gradle-plugin’s move to using the separate dependency
management plugin the CLI was the only user of this format.

This commit updates the CLI to use Maven boms to configure its
dependency management. By default it uses the spring-boot-dependencies
bom. This configuration can be augmented and overridden using the new
@DependencyManagementBom annotation which replaces @GrabMetadata.

Closes gh-2688
Closes gh-2439
2015-05-07 14:58:23 +01:00
Andy Wilkinson
4452bb1873 Revert "Upgrade Gradle plugin’s ID so it’s suitable for the Plugin Portal"
This reverts commit b1c0a7cda4.

The plugin publishing process has moved to a new plugin-based approach
that brings with it some significant limitations:

 - There's no staging to allow the promotion of good release builds
 - There's no easy way to upload an existing artifact
 - There's no control over the published pom.

The risk brought by these limitations, particularly the first, are
too great so we will no be publishing the Boot plugin to the Portal
until they're resolved.

Changing the plugin's ID was a breaking change that would require
users to do some work when they upgrade to Boot 1.3. The ID of the
plugin was changed purely so that it met the Portal's requirements.
Given that the plugin will not be published to the Portal for the
foreseaable future there's no need for us to inflict a breaking change
on people when there will be no benefit.

See gh-1567
2015-04-21 12:37:12 +01:00
Phillip Webb
2176afb49e Set timestamps of nested jars
Update JarWriter to set the entry timestamp for nested jars. The
timestamp is set to same time as the first (non directory) entry in
the nested jar.

This change should make it easier to created layered docker images.

Fixes gh-2807
2015-04-16 21:20:28 -07:00
Phillip Webb
a8d099f6b8 Revert "Add start/stop goals to maven plugin"
This reverts commit 54e12a07e6.
2015-04-16 12:32:06 -07:00
Stephane Nicoll
54e12a07e6 Add start/stop goals to maven plugin
SpringApplicationLifecycle provides lifecycle operations on the current
Spring Boot application. It can be registered as an MBean of the platform
MBean server if a specific property is set. Besides, the JMX name can
also be customized via a property in case more than one Spring Boot
application is started in the same process.

The Maven plugin uses that MBean to check that the application is ready
before ending the "start" phase. It uses it to trigger a proper shutdown
of the application during the "stop" phase.

If the process has to be forked, the platform MBean server is exposed on
a configurable port so that the maven plugin can connect to it.

Such change permits the maven plugin to integrate a classical integration
test scenario where the "start" goal is invoked during the
pre-integration phase and the "stop" goal during the post-integration
phase.

Closes gh-2525
2015-04-16 11:50:18 +02:00
Andy Wilkinson
02859cc2d4 Merge branch '1.2.x' 2015-04-15 17:04:05 +01:00
Andy Wilkinson
ebb8d0c55f Read the time of a JarEntryData using MSDOS Date Time format
The format is rather unusual.

The time is 16 bits: 5 bits for the hour, 6 bits for the minutes, and 5
bits for the seconds. 5 bits only allows 32 values (0-31) so the number
must be doubled, meaning that the time is only accurate to the nearest
two seconds. Also, the JDK rounds this down by subtracting one. The
doubling and rounding is performed by shifting one place to the left
and masking off the right-most bit respectively.

The date is 16 bits: 7 bits for the year, 4 bits for the month, and 5
bits for the day. The year is from 1980, i.e. the earliest date that
can be represented is 1980-01-01.

See http://mindprod.com/jgloss/zip.html for more details of the format.

Fixes gh-2826
2015-04-15 17:03:06 +01:00
Phillip Webb
c2e2bc879e Fix broken RepackerTests on Windows
Update test to deal with the fact that POSIX operations aren't available
on Windows.

Fixes gh-1117
2015-04-14 10:39:27 -07:00
Sylvère Richard
d8308cbf45 Support ANSI color from gradle bootRun
Update the BootRunTask to record the state of the System.console() so
that it can be picked up later by AnsiOutput.

Fixes gh-747
2015-04-09 13:13:44 -07:00
Phillip Webb
793481843c Support embedded jar initialization scripts
Update the Maven and Gradle plugin to generate fully executable jar
files on Unix like machines. A launcher bash script is added to the
front of the jar file which handles execution.

The default execution script will either launch the application or
handle init.d service operations (start/stop/restart) depending on if
the application is executed directly, or via a symlink to init.d.

See gh-1117
2015-04-09 10:57:31 -07:00
Phillip Webb
8143d1f36d Apply animal sniffer to entire build
Move animal sniffer configuration out of spring-boot-dependencies to
spring-boot-parent and apply it to all projects.

See gh-716
2015-04-06 19:47:22 -07:00
Spring Buildmaster
e03c11dda8 Next development version 2015-03-30 22:56:20 -07:00
Andy Wilkinson
20a2f21493 Merge branch '1.2.x' 2015-03-26 10:01:01 +00:00
Andy Wilkinson
c3a040acb3 Polishing
Remove unwanted System.out.println call
2015-03-26 10:00:35 +00:00
Andy Wilkinson
b1c0a7cda4 Upgrade Gradle plugin’s ID so it’s suitable for the Plugin Portal
Gradle’s plugin portal requires each plugin’s ID to be in a namespace.
Our existing ID, spring-boot, does not meet this requirement. This
commit changes the plugin’s ID to org.springframework.boot.spring-boot.
Note that, as is recommended [1], the plugin’s ID does not include
“gradle”.

See gh-1567

[1] http://plugins.gradle.org/submit
2015-03-19 14:25:07 +00:00
Andy Wilkinson
0f51a53691 Remove manual Gradle plugin versionManagement test
Following the move to using the separate dependency management plugin
this test is no longer valid. It should have been removed as part of
2c3c62d7

See gh-2133
2015-03-19 13:55:32 +00:00
Andy Wilkinson
2c3c62d71c Replace basic Gradle dependency management with use of separate plugin
This commit replaces Spring Boot's basic dependency management support
with separate dependency management plugin. This has a number of
benefits including:

1. A Maven bom can be used rather than a custom properties file
2. Dependency management is applied transitively rather than only to
   direct dependencies
3. Exclusions are applied as they would be in Maven
4. Gradle-generated poms are automatically configured with the
   appropriate dependency management

Closes gh-2133
2015-03-19 13:23:40 +00:00
Andy Wilkinson
3649a89a03 Use maven-dependency-plugin 2.10 in Loader's integration test projects
Closes gh-2430
2015-03-05 14:07:40 +00:00
Andy Wilkinson
6a32519aa8 Merge branch '1.2.x' 2015-03-04 13:43:25 +00:00
Andy Wilkinson
f761916b51 Honor unpack for war files
Previously repackaging of an archive was performed in three steps:

1. Write the manifest
2. Write entries from the source archive into the destination
3. Write any libraries into the destination if they’re not already there

This worked fine for jar files, but not for war files. In the war file
case the libraries are already in the source archive’s WEB-INF/lib
directory so they’re copied into the destination in step 2. This means
that step 3 largely becomes a no-op and, crucially, the UNPACK comment
is not applied to any libraries that require it.

This commit reorders steps 2 and 3 so that the libraries are copied into
the destination first (allowing the UNPACK comment to be written, if
required) and then any entries in the source are written into the
destination if they’re not already there.

Fixes gh-2588
2015-03-04 13:42:50 +00:00
Phillip Webb
0174476ff1 Merge branch '1.1.x' into 1.2.x 2015-03-02 12:12:57 -08:00