411 Commits

Author SHA1 Message Date
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.
2014-01-08 13:14:54 +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
Dave Syer
4e1245d9ee Restore changes from 0332501 (fix class loader test failure) 2014-01-08 07:30:09 +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
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).
2014-01-06 11:40:20 +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
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
2014-01-02 11:42:59 -08:00
Dave Syer
045088e8b3 Add -cp to option help for compiler commands
Fixes gh-178
2013-12-31 12:24:49 +00:00
Dave Syer
4cfc7b6ad9 Make sure integration still works in CLI 2013-12-30 11:19:52 +00:00
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.
2013-12-30 10:32:42 +00:00
Dave Syer
5d8e58d12c Remove support for Integration DSL (milestone only) 2013-12-30 07:39:36 +00:00
Dave Syer
de82557bd8 Change command set when entering shell
Fixes gh-147
2013-12-24 07:45:48 +00:00
Dave Syer
d50d378c33 Prevent more than one app at a time from running 2013-12-23 22:13:50 +00:00
Dave Syer
0bca416d3b Remove CLI_APP name if in shell 2013-12-23 22:13:50 +00:00
Dave Syer
cc8aa753da Add basic Banner to CLI Shell 2013-12-23 22:13:50 +00:00
Dave Syer
cccb5d4610 Add ShellCommand and friends 2013-12-23 22:13:50 +00:00
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).
2013-12-19 17:11:01 +00:00
Dave Syer
e2c962ac28 Switch to thymeleaf-spring4 2013-12-19 13:40:24 +00:00
Phillip Webb
d04248a845 Use SHA1 checksum for homebrew 2013-12-18 23:19:24 -08:00
Phillip Webb
1931d6eb9d Fix broken homebrew 2013-12-18 23:09:34 -08:00
Phillip Webb
513c6a1de2 Polish 2013-12-16 14:38:52 -08:00
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.
2013-12-10 13:38:52 +00:00
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
2013-12-04 11:13:49 +00:00
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
2013-11-29 10:12:08 +00:00
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).
2013-11-28 10:10:57 +00:00
Phillip Webb
f4f668a52b Polish 2013-11-25 17:12:56 -08:00
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).
2013-11-21 16:47:29 +00:00
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.
2013-11-20 09:58:09 +00:00
Dave Syer
a7368fcd33 Move grab-sample to resources dir 2013-11-20 08:58:29 +00:00
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.
2013-11-19 15:20:27 +00:00
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.*
2013-11-18 12:40:57 +00:00
Phillip Webb
64f32893bb Source format and clean-up 2013-11-16 00:08:18 -08:00
Phillip Webb
127da15c3c Add homebrew formula as generated artifact 2013-11-16 00:08:17 -08:00
Phillip Webb
077cd662e7 Add zsh shell completion script 2013-11-16 00:08:14 -08:00
Phillip Webb
fe0dd8e08f Don't provide hints for the hint command 2013-11-15 16:39:29 -08:00
Phillip Webb
ff635cf75b Move shell completion logic to Java
Refactor bash shell completion to move the majority of the logic into
the Java code. This commit also removes the need for the '--' prefix on
every command.
2013-11-09 09:31:38 -08:00
Phillip Webb
e6597e6f33 Fix broken tests 2013-11-07 10:30:18 -08:00
Dave Syer
0c1aa1942e Add tests for loading dependencies in starters without parent 2013-11-07 16:05:01 +00:00