421 Commits

Author SHA1 Message Date
Phillip Webb
a624245b78 Remove dead code
Remove what appears to be unused CLI code.
2014-01-27 16:25:41 -08:00
Phillip Webb
ac0ff3c0b8 Upgrade to Spring Framework 4.0.1 SNAPSHOT
Upgrade to the latest 4.0.x SNAPSHOT of the Spring Framework in
preparation for the 4.0.1 release.
2014-01-27 14:41:03 -08:00
Phillip Webb
49ef1cd236 Update CLI to use spring-boot-dependency-tools
Update `GroovyCompiler` and `AetherGrapeEngineFactory` to use the
recently added `spring-boot-dependency-tools` in favor of loading
dependency information from a generated properties file.
2014-01-24 22:51:40 -08:00
Dave Syer
c5584b490a Add some more smarts around --debug
--verbose seems to be only for CLI logging (so really only
for dependency resolution). --debug is interpreted by SpringApplication
but up to now has been extracted and deleted from the command line
by the CommandRunner. This change makes --debug set a System property
*and* pass it down to the application (if used with -- separator).

Fixes gh-266
2014-01-24 12:35:25 +00:00
Phillip Webb
f500e48e2c Fix version replacement in homebrew generation 2014-01-21 21:05:23 -08:00
Phillip Webb
43e54d38f7 Make fields private where possible 2014-01-21 16:29:07 -08:00
Phillip Webb
0160760568 Apply latest eclipse cleanup rules 2014-01-21 16:28:26 -08:00
Phillip Webb
ac54d7fe3c Final polish before 1.0.0.RC1 2014-01-21 16:28:17 -08:00
Phillip Webb
cdda330acd Update copyright header for files changed in 2014 2014-01-21 10:27:10 -08:00
Phillip Webb
7bb6bf6a54 Polish 2014-01-21 00:44:02 -08:00
Phillip Webb
18cecd077d Move CLI integration tests into spring-boot-cli
Use `maven-failsafe-plugin` to run CLI integration tests as part of
the `spring-boot-cli` project, removing the need for
`spring-boot-cli-integration-tests`.
2014-01-20 12:12:10 -08:00
Dave Syer
5627caa724 Move spring-boot tests utilities to main spring-boot.jar
Fixes gh-233
2014-01-17 18:31:08 +00:00
Phillip Webb
28a92d22dc Prevent CTRL-D from causing NPE in shell
Update the integrated shell to deal with a null line which can be
triggered with CTRL-D.

Fixes gh-229
2014-01-16 09:31:54 -08:00
Dave Syer
796816e8c3 Remove CleanCommand
Fixes gh-230
2014-01-16 17:29:52 +00:00
Phillip Webb
c8a1d8830c Refactor CLI internals for REPL shell
Numerous updates to the Spring CLI, primarily for better embedded REPL
shell support:

* Refactor the CLI application to help separate concerts between the
  main CLI and the embedded shell. Both the CLI and embedded shell now
  delegate to a new `CommandRunner` to handle running commands. The
  runner can be configured differently depending depending on need.
  For example, the embedded shell adds the 'prompt' and 'clear'
  commands.

* Most `Command` implementations have been moved to sub-packages so that
  they can be co-located with the classes that they use.

* Option commands are now only used in the CLI, the embedded shell
  does not user them and details have been removed from the Command
  interface.

* The REPL shell has been significantly refactored to:
    - Support CTRL-C to cancel the running process. This is supported
      when running external commands and most internal commands.
    - Fork a new JVM when running commands (primarily for CTRL-C support
      but also for potential memory and classpath issues)
    - Change the "continue" trigger from `<<` to `\`
    - Support command completion of files
    - Add ANSI color output
    - Provide 'help' support for internal commands (such as 'clear')
    - Remove the now redundant `stop` command

Fixes gh-227
2014-01-15 14:03:18 -08:00
Phillip Webb
cad9fbfdf0 Fix CLI help formatting issue with '-cp'
Ensure that '--cp' is replaced with a same length string to prevent
odd help text formatting.
2014-01-15 13:29:32 -08:00
Phillip Webb
3b259bc865 Polish 2014-01-15 10:31:08 -08:00
Andy Wilkinson
5fb42c3c33 Support @Grab when app has multiple groovy scripts
The AST transformation that processes @Grab annotations is driven once
per source file. Previously, this meant that if an app consisted of
multiple source files then multiple, discrete dependency resolutions
would be performed.

This commit updates AetherGrapeEngine to cache a previous resolution's
outcome and use its dependency to influence the outcome of subsequent
resolutions. For example if a one resolution results in spring-core
4.0.0.RELEASE being added to the classpath, subsequent resolutions
that depend upon spring-core will always get the 4.0.0.RELEASE
version. This is achieved by using the dependencies found by earlier
resolutions as dependency management configuration of the current
resolution. This removes the possibility of multiple versions of the
same dependency ending up on the classpath.

In addition to using the results of earlier resolutions to provide
dependency management configuration, default dependency management
configuration is also provided. This configuration is specified by
the springcli.properties file and ensures that, where Boot prescribes
certain versions of a dependency, that is the version that will be
resolved. For example, this ensures that spring-data-redis, which
depends upon Spring 3.1.4, pulls in the version of Spring that Boot
requires instead.

Fixes #224
2014-01-15 10:51:42 +00:00
Dave Syer
57ba6a40b6 Divert out/err streams while command runs
Actually System.in works fine, it's the output streams that get buffered.
We can fix it by diverting them for the duration of the command.

Fixes gh-217
2014-01-14 17:44:29 +00:00
Dave Syer
6b6bd37924 Add hint to user about 'stop' command
Improves gh-218
2014-01-14 17:43:50 +00:00
Dave Syer
1f5cba9e32 Clear prompt before clearing screen
Fixes gh-219
2014-01-14 17:26:13 +00:00
Dave Syer
fa8e4768b9 Prevent JLine from expanding !history events
We might also want to rethink "!" as a shell exec command (since it means
something in a real shell and in JLine). E.g. use "exec" or something.

Partial fix for gh-220 (ideally we'd process the events and catch
and handle exceptions).
2014-01-14 15:39:13 +00:00
Dave Syer
b07a1998df Remove InitCommand altogether
Related to gh-212
2014-01-14 14:49:00 +00:00
Dave Syer
8ff2a88712 Fix counting error in SourceOptions 2014-01-14 14:44:20 +00:00
Dave Syer
a5f16d46fe Remove ScriptCommand support
InitCommand remains for now, so that you can @Grab a jar with
custom commands if you so choose.

Contributes to gh-212
2014-01-14 14:44:20 +00:00
Dave Syer
3e6eb6fec8 Remove support for InitCommand outside REPL
In this commit we retain "init" as a command inside the ShellCommand
but not on the bash command line.

Seems to have an impact on performance so relevant to gh-212.
2014-01-14 13:27:40 +00:00
Dave Syer
5b90e18564 More performance tweaks for SpringCli 2014-01-14 13:04:00 +00:00
Andy Wilkinson
895daacde9 Roll spring-boot-maven-settings into the CLI 2014-01-14 10:06:45 +00:00
Phillip Webb
e3b352e0b5 Support 'headless' applications
Update SpringApplication to run by default in 'headless' mode. This
prevents the AWT system from creating a Java icon (for example in the
OSX dock).

Also update builds to run tests in 'headless' mode.
2014-01-13 22:43:37 -08:00
Dave Syer
165ba2eb45 Add some performance tests for InitCommand
Fixed gh-212 again
2014-01-13 12:47:54 +00:00
Dave Syer
420fc69983 Only run InitCommand if there is code to process
This appears to be a significant improvement in performance
(checking for the existence of init.grooy is cheap, but compiling
it is expensive).

I'm going to say this fixes gh-212.
2014-01-11 07:23:39 +00:00
Phillip Webb
47da8a817a Polish 2014-01-10 13:06:54 -08:00
Phillip Webb
18a666caf8 Replaces references to 'files' with 'sources'
Replace references to 'files' throughout the code-base with 'sources'
following the rename of `FileOptions` to `SourceOptions`.

Also cleanup ResourceUtils a little
2014-01-10 12:27:23 -08:00
Dave Syer
bd73705393 FileOptions -> SourceOptions to work with String paths instead of Files
We check for existence of the sources and (as before) resolve multiple
resources on the classpath if a path is not a File. In addition supports
Spring pseudo-URL prefixes as well as normal URLs as source locations.

In addition sources can now be specified as a directory (searched
recursively by default), or a resource pattern (e.g. app/**/*.groovy).

Fixes gh-207
2014-01-10 11:59:04 +00:00
Dave Syer
edaaac8993 Fix broken test
Recent changes to the repository configuration for @Grab
didn't update the tests which use the GroovyCompiler as
a standalone. Fixed that by using the
RepositoryConfigurationFactory.
2014-01-10 08:25:28 +00:00
Andy Wilkinson
9a5be9f4cd Revert "Test that auto configurations can be added by init scripts"
The test passes locally, both in Eclipse and on the command line, but
fails on the CI server. Revert the addition of the test while I
hopefully figure out why.

This reverts commit 2e81b1d0d0924f1a24c3c0dd2d686218cd701f06.
2014-01-08 11:43:59 +00:00
Andy Wilkinson
a010de955d Reinstate ./repository as a "remote" repository
The grab command downloads the dependencies of one or more Groovy
scripts to ./repository. This commit ensures that those previously
downloaded dependencies can be used by a subsequent invocation of the
run command.

The location and behaviour of the local cache is unaffected by this
change. If the dependencies in ./repository do not exist in the local
cache, Aether will "download" them from ./repository and store them in
the local cache.

Fixes #191
2014-01-08 11:34:17 +00:00
Andy Wilkinson
a58e4cbb1f Add support for configuring Aether via settings.xml
Previously, Aether's configuration was largely hard-coded making it
impossible to configure a mirror, provide credentials for accessing
a repository, etc.

This commit adds support for configuring Aether via Maven's
settings.xml file. The support is optional and must be enabled by
grabbing spring-boot-maven-settings in an init script. The Aether
instance that's used when running the application will then be
configured using settings.xml. The settings file is expected to be
found in ${user.home}/.m2/settings.xml.

The configuration of the following items is currently supported:

 - Offline
 - Proxies
 - Mirrors
 - Server authentication
 - Local repository location

If the support is not enabled, settings.xml does not exist, or
settings.xml does not configure certain things then sensible defaults
are applied.
2014-01-08 11:21:56 +00:00
Andy Wilkinson
2e81b1d0d0 Test that auto configurations can be added by init scripts
When an init command is run, it may add entries to the classpath. This
commit adds a test that verifies that, if an entry that is added to
the classpath contains a CompilerAutoConfiguration file in
META-INF/services, then the CompilerAutoConfigurations declared in it
are found by subsequent ServiceLoader.load calls.
2014-01-08 11:21:56 +00:00
Andy Wilkinson
3336b6da44 Remove redundant @GrabResolver transform
Previously, a transform was used to add @GrabResolver annotations
during compilation that added the Spring milestone and snapshot
repositories. This functionality is now handled by
RepositoryConfigurationFactory so the transform is no longer required.
2014-01-07 10:31:10 +00:00
Greg Turnquist
b5b86d07ba Add Spring MVC's org.springframework.ui package to the list of automatic imports 2014-01-06 17:30:05 +00:00
Dave Syer
ac34f9c993 First proper draft of DSL for Groovy Commands
Users can declare or Command, OptionHandler classes in an init script
or they can use a DSL, e.g.

command("foo") { args -> println "Do stuff with ${args} array" }

or

command("foo") {
  options { option "bar", "Help text for bar option" ithOptionArg() ofType Integer }
  run { options -> println "Do stuff with ${options.valueOf('bar')}" }
}
2014-01-06 16:00:10 +00:00
Dave Syer
1e75c0a55b Extend programming model for script commands 2014-01-06 11:40:21 +00:00
Dave Syer
b5db4d3ff4 Enhance FileOptions to support multiple classpath resources 2014-01-06 11:40:21 +00:00
Dave Syer
cd7b1b19c5 Add InitCommand to execute groovy script on startup
InitCommand runs on creation of SpringCli so it can search for additional
Commands in updated classpath. Also added as interactive command in Shell
session.
2014-01-06 11:40:21 +00:00
Dave Syer
e48ddaeb99 Fix grab test 2014-01-06 10:41:49 +00:00
Dave Syer
df476bed1f Ensure local repository cache is always used 2014-01-03 09:56:22 +00:00
Phillip Webb
bd6c672bba Drop jumping into shell when running without args
Change SpringCli so that running without arguments no longer jumps into
the embedded REPL shell. This restores the ability to obtain quick usage
help by simply typing `spring` from the command prompt.

Windows users or developers that prefer the embedded shell can still
launch it using `spring shell`.
2014-01-02 14:26:04 -08:00
Phillip Webb
f56318e9b8 Polish embedded REPL shell 2014-01-02 14:13:22 -08:00
Phillip Webb
1bcd3de7b5 Polish 2014-01-02 12:10:37 -08:00