Commit Graph

267 Commits (a330cb9b8a80fb40c3fb352cd8a78d37b562ebb9)

Author SHA1 Message Date
Phillip Webb af93ae2dac Ignore failing JMS tests for now
Ignore JMS sample which intermittently fails to run on CI.

See gh-323
11 years ago
Phillip Webb 2d8f66e3c5 Add more JMS sample log output 11 years ago
Phillip Webb ed9735361e Apply source cleanup and formatting 11 years ago
Phillip Webb 0f083c2f9d Fix CLI class tangle 11 years ago
Phillip Webb 1061d582dc Fix CLI package tangles 11 years ago
Phillip Webb 70cb8cfed6 Fix CLI package and class tangles 11 years ago
Phillip Webb c65dc9063c Don't expose URLs from InnerLoader
Update the CLI Groovy InnerLoader to not expose URLs. This prevents the
'TLD skipped' log messages from Tomcat that occurred previously due to
the InnerLoader and parent returning the same URLs.

Fixes gh-277
11 years ago
Phillip Webb 208bf8fc96 Polish CLI Jar generation 11 years ago
Phillip Webb d648603634 Exclude *.jar and *.groovy from generated JARs
Update `JarCommand` to exclude `**/*.groovy` and `**/*.jar` by default.
11 years ago
Phillip Webb c852fb5a79 Update packaged JARs to use standard JarLauncher
Change CLI generated JARs to use the standard `JarLauncher` instead of
a custom `JarRunner`. The `PackagedSpringApplicationLauncher` is used
as the `Start-Class` which in turn calls `SpringApplication.run()`.
11 years ago
Andy Wilkinson 96e10104e4 Add a command to produce a self-contained executable JAR for a CLI app
A new command, jar, has been added to the CLI. The command can be
used to create a self-contained executable JAR file from a CLI app.

Basic usage is:

spring jar <jar-name> <source-files>

For example:

spring jar my-app.jar *.groovy

The resulting jar will contain the classes generated by compiling the
source files, all of the application's dependencies, and entries
on the application's classpath.

By default a CLI application has the current working directory on
its classpath. This can be overridden using the --classpath option.
Any file that is referenced directly by the classpath is always
included in the jar. Any file that is found a result of being
contained within a directory that is on the classpath is subject to
filtering to determine whether or not it should be included. The
default includes are public/**, static/**, resources/**,
META-INF/**, *. The default excludes are .*, repository/**, build/**,
target/**. To be included in the jar, a file must match one of the
includes and none of the excludes. The filters can be overridden using
the --include and --exclude options.

Closes #241
11 years ago
Ben Hale f2951b38d9 Ruby indentation conventions
By convention, Ruby code is indented using two spaces (  ) per-level.
The code used tabs (\t) previously and therefore wasn't idiomatic.
This change updates the indenting to use two spaces.
11 years ago
Ben Hale a3c398ca0a Add --HEAD support to Homebrew formula
This change adds support for --HEAD builds to the Homebrew formula. It
defines a conditional dependency on Maven and builds the -cli project
during install.  The location to install from is abstracted out so
that code is identical regardless of whether the build is --HEAD or
mainline.
11 years ago
Phillip Webb a624245b78 Remove dead code
Remove what appears to be unused CLI code.
11 years ago
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.
11 years ago
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.
11 years ago
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
11 years ago
Phillip Webb 4a0ef9720b Update READMEs to reference latest version number 11 years ago
Phillip Webb 595cb6d55b Fix version-type logic to deal with RCx form 11 years ago
Phillip Webb f500e48e2c Fix version replacement in homebrew generation 11 years ago
Phillip Webb d0f3e33f21 Remove unused test dependency 11 years ago
Phillip Webb 43e54d38f7 Make fields private where possible 11 years ago
Phillip Webb 0160760568 Apply latest eclipse cleanup rules 11 years ago
Phillip Webb ac54d7fe3c Final polish before 1.0.0.RC1 11 years ago
Phillip Webb cdda330acd Update copyright header for files changed in 2014 11 years ago
Phillip Webb 7bb6bf6a54 Polish 11 years ago
Phillip Webb 68293f34af Upgrade version to 1.0.0.BUILD-SNAPSHOT
Fixes fg-243
11 years ago
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`.
11 years ago
Dave Syer 5627caa724 Move spring-boot tests utilities to main spring-boot.jar
Fixes gh-233
11 years ago
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
11 years ago
Dave Syer 796816e8c3 Remove CleanCommand
Fixes gh-230
11 years ago
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
11 years ago
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.
11 years ago
Phillip Webb 3b259bc865 Polish 11 years ago
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
11 years ago
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
11 years ago
Dave Syer 6b6bd37924 Add hint to user about 'stop' command
Improves gh-218
11 years ago
Dave Syer 1f5cba9e32 Clear prompt before clearing screen
Fixes gh-219
11 years ago
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).
11 years ago
Dave Syer b07a1998df Remove InitCommand altogether
Related to gh-212
11 years ago
Dave Syer 8ff2a88712 Fix counting error in SourceOptions 11 years ago
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
11 years ago
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.
11 years ago
Dave Syer 5b90e18564 More performance tweaks for SpringCli 11 years ago
Andy Wilkinson 895daacde9 Roll spring-boot-maven-settings into the CLI 11 years ago
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.
11 years ago
Phillip Webb ffe8bf5419 Remove unused .gitignore files 11 years ago
Andy Wilkinson e96fa79c31 Don't pull test and provided dependencies into the CLI jar 11 years ago
Dave Syer 165ba2eb45 Add some performance tests for InitCommand
Fixed gh-212 again
11 years ago
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.
11 years ago
Dave Syer 322af41d72 Revert CLI to JarLauncher
Affects gh-212
11 years ago
Phillip Webb 47da8a817a Polish 11 years ago
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
11 years ago
Phillip Webb 2c6231a0fc Restore eclipse settings to stop m2e errors 11 years ago
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
11 years ago
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.
11 years ago
Andy Wilkinson 73b9899708 Use a single <manifestEntries> element
Previously, there were two <manifestEntries> elements in the CLI's
pom.xml. With certain versions of Maven, this appeared to cause the
first element to be ignored in favour of the second. The problem did
not occur when built locally with Maven 3.1.1, but did occur when built
by Bamboo which, I believe, uses 3.0.x

This commit combines the two <manifestEntries> into one.
11 years ago
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 2e81b1d0d0.
11 years ago
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
11 years ago
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.
11 years ago
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.
11 years ago
Dave Syer 4e1245d9ee Restore changes from 0332501 (fix class loader test failure) 11 years ago
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.
11 years ago
Greg Turnquist b5b86d07ba Add Spring MVC's org.springframework.ui package to the list of automatic imports 11 years ago
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')}" }
}
11 years ago
Dave Syer 1e75c0a55b Extend programming model for script commands 11 years ago
Dave Syer b5db4d3ff4 Enhance FileOptions to support multiple classpath resources 11 years ago
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.
11 years ago
Dave Syer 033250195b Allow user to specify classLoader as loader property
PropertiesLauncher now supports creating its own class loader
from looader.classLoader property. It will succeed if the
implementation specified has a default constructor or one
that takes a parent class loader, or one that takes a URL[]
and a parent class loader (like URLClassLoader).
11 years ago
Dave Syer e48ddaeb99 Fix grab test 11 years ago
Dave Syer df476bed1f Ensure local repository cache is always used 11 years ago
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`.
11 years ago
Phillip Webb f56318e9b8 Polish embedded REPL shell 11 years ago
Phillip Webb 1bcd3de7b5 Polish 11 years ago
Phillip Webb 0f9c705980 Rework OptionHandler '-cp' argument support
Change OptionHandler to support '-cp' instead of '--cp'. This update
to the original fix (045088e8b) renders `help` output correctly and
should prevent potential issues if a `-p` command is added in the future.

Fixes gh-178
11 years ago
Dave Syer 045088e8b3 Add -cp to option help for compiler commands
Fixes gh-178
11 years ago
Dave Syer 4cfc7b6ad9 Make sure integration still works in CLI 11 years ago
Dave Syer aa2b020660 Refactor metrics to expose richer feature set
Main user-facing interface is still Counter/GaugeService but the
back end behind that has more options. The Default*Services write
metrics to a MetricWriter and there are some variants of that, and
also variants of MetricReader (basic read-only actions).

MetricRepository is now a combination of MetricReader, MetricWriter
and some more methods that make it a bit more repository like.

There is also a MultiMetricReader and a MultiMetricRepository for
the common case where metrics are stored in related (often open
ended) groups. Examples would be complex metrics like histograms
and "rich" metrics with averages and statistics attached (which
are both closed) and "field counters" which count the occurrences
of values of a particular named field or slot in an incoming message
(e.g. counting Twitter hastags, open ended).

In memory and redis implementations are provided for the repositories.
Generally speaking the in memory repository should be used as a
local buffer and then scheduled "exports" can be executed to copy
metric values accross to a remote repository for aggregation.
There is an Exporter interface to support this and a few implementations
dealing with different strategies for storing the results (singly or
grouped).

Codahale metrics are also supported through the MetricWriter interface.
Currently implemented through a naming convention (since Codahale has
a fixed object model this makes sense): metrics beginning with "histogram"
are Histograms, "timer" for Timers, "meter" for Meters etc.

Support for message driven metric consumption and production are provided
through a MetricWriterMessageHandler and a MessageChannelMetricWriter.

No support yet for pagination in the repositories, or for HATEOAS style
HTTP endpoints.
11 years ago
Dave Syer 5d8e58d12c Remove support for Integration DSL (milestone only) 11 years ago
Dave Syer de82557bd8 Change command set when entering shell
Fixes gh-147
11 years ago
Dave Syer d50d378c33 Prevent more than one app at a time from running 11 years ago
Dave Syer 0bca416d3b Remove CLI_APP name if in shell 11 years ago
Dave Syer cc8aa753da Add basic Banner to CLI Shell 11 years ago
Dave Syer cccb5d4610 Add ShellCommand and friends 11 years ago
Dave Syer 75af18df7d Add support for beans{} in CLI scripts
User can add (a single) beans{} DSL declaration (see GroovyBeanDefinitionReader
in Spring 4 for more detail) anywhere at the top level of an application source
file. It will be compiled to a closure and fed in to the application context
through a GroovyBeanDefinitionReader. Cool!

The example spring-boot-cli/samples/beans.groovy runs in an integration test
and passes (see SampleIntegrationTests).
11 years ago
Dave Syer e2c962ac28 Switch to thymeleaf-spring4 11 years ago
Phillip Webb d04248a845 Use SHA1 checksum for homebrew 11 years ago
Phillip Webb 1931d6eb9d Fix broken homebrew 11 years ago
Phillip Webb 513c6a1de2 Polish 11 years ago
Dave Syer f2cdb8c69f Change interface of CommandFactory slightly
It's super useful to get a reference to the current SpringCli
instance in the CommandFactory. Potentially implementations can
react to the properties of the Cli, or wrap it into something
more complex.

...supports the likely implementation of the REPL use
case that @jbrisbin has been working on.
11 years ago
Andy Wilkinson b0c5d3254a Make "." be the CLI's default classpath
Previously, the default classpath was empty. Now, in the absence of the
user providing a classpath via the -cp option, the default classpath
will be ".". If the user does specify a classpath, the classpath that's
used will be exactly what they have specified, i.e. "." will no longer
be on the classpath unless specified by the user.

The app sample integration test has been updated to verify that "." is
only the classpath by default.

Fixes #115
11 years ago
Dave Syer f1026b1202 Add JreProxySelector to handle global proxy configuration
The JreProxySelector is used it to adjust the repositories
as they are added to the GrapeEngine. It looks at standard
System proeprties like http.proxyHost and http.proxyPort
and in addition consults standard JRE Authenticator features
for credentials (falling back to System properties
http.proxyUser and http.proxyPassword).

Fixes gh-136
11 years ago
Dave Syer 47d079d937 Add default proxy settings from System proerties
Aether apparently doesn't use the java.net.* APIs for
TCP connections so it doesn't notice when a user sets
-Dhttp.Proxy*. To fix it is painful, and leads me to
suspect that actually we might want to parse a
settings.xml at some point (however unpalatable that
is).

For now I have added a Proxy to all RemoteRepository
instances that we create in the CLI if the user
has set -Dhttp.proxyHost (and/or -Dhttps.proxyHost for
a secure repository).

TODO: authentication. Is there a standard way to specify
that globally via system properties.

TODO: maybe use per-repository settings if provided
(e.g. in settings.xml).
11 years ago
Phillip Webb f4f668a52b Polish 11 years ago
Dave Syer bd26b28aa5 Extract actuator security into separate classes
So spring-security + a web app is secure by default
(you don't need the actuator).
11 years ago
Dave Syer 89332e230e Speed up grab command test
The autoconfiguration transformations (and loads of grabs
of spring-boot snapshots) were making the grab command
tests run really slowly. Snapshots are particularly bad.

Fixed by adding a --autoconfigure=false option to the
compiler configuration and using it in that test.
11 years ago
Dave Syer a7368fcd33 Move grab-sample to resources dir 11 years ago
Andy Wilkinson 820f43d3bc Add grab command to collect script's dependencies
Previously, run --local could be used to collect a script's
dependencies in ./repository. However, with this mechanism it wasn't
possible to collect the dependencies without running the application.

This commit adds a new command, grab, that can be used to collect
a script's dependencies in ./repository without having to run it.
run is configured with ./repository as a location in which it can find
its dependencies so that the previously collected dependencies
can be used when subsequently running the app.

As part of this work RunCommand and TestCommand have been refactored
to use common code for their common options:

	--no-guess-imports
	--no-guess-dependencies
	--classpath

Previously, the declaration and handling of the options was duplicated
in the two classes. GrabCommand also has these three options and uses
the same common code.
11 years ago
Andy Wilkinson fd2583ed28 Support concise @Grab on all types of imports
Previously, the automatic addition of the group and version to a
@Grab annotation based on the module name would only work on standard
import statements. This commit adds support for this functionality
on wildcard imports, static imports and wildcard static imports.

All of the following are now supported:

@Grab('spring-core')
import org.springframework.util.Assert

@Grab('spring-core')
import org.springframework.util.*

@Grab('spring-core')
import static org.springframework.util.Assert.isTrue

@Grab('spring-core')
import static org.springframework.util.Assert.*
11 years ago
Phillip Webb 64f32893bb Source format and clean-up 11 years ago