From 1fd8e2c0470fe9df16393e5b4e17f9ef379980c8 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 30 Jun 2016 16:06:44 +0200 Subject: [PATCH] Migrate application to Maven This commit migrates the `initializr-service` to a regular Maven project. Closes gh-252 --- .gitignore | 8 --- README.adoc | 66 ++++-------------- initializr-service/app.groovy | 39 ----------- initializr-service/logback.xml | 10 --- initializr-service/manifest.yml | 7 -- initializr-service/pom.xml | 49 ++++++++++++++ .../service/InitializrService.groovy | 67 +++++++++++++++++++ .../main/resources}/application-cloud.yml | 0 .../{ => src/main/resources}/application.yml | 5 ++ pom.xml | 9 +++ 10 files changed, 144 insertions(+), 116 deletions(-) delete mode 100644 initializr-service/app.groovy delete mode 100644 initializr-service/logback.xml delete mode 100644 initializr-service/manifest.yml create mode 100644 initializr-service/pom.xml create mode 100644 initializr-service/src/main/groovy/io/spring/initializr/service/InitializrService.groovy rename initializr-service/{ => src/main/resources}/application-cloud.yml (100%) rename initializr-service/{ => src/main/resources}/application.yml (99%) diff --git a/.gitignore b/.gitignore index 5b76f167..c0fc9bd5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,12 +13,4 @@ build target .springBeans tmp* -initializer-service/spring grapes -spring.zip -repository/ -*.jar -*.jar.orig -*.jar.original -.idea -*.iml diff --git a/README.adoc b/README.adoc index 77834939..6687509a 100644 --- a/README.adoc +++ b/README.adoc @@ -31,6 +31,10 @@ many environments (including embedded in your own project) * `initializr-actuator`: optional module to provide statistics and metrics on project generation +`initializr-service` is an additional module that represents the production instance that +is available at link:https://start.spring.io[]. It is not enabled by default but you can +enable the `full` profile in your IDE to easily run it locally. + == Supported interfaces Spring Initializr can be used as follows: @@ -91,7 +95,7 @@ $ curl https://start.spring.io/starter.tgz -d dependencies=web,actuator \ -d language=groovy -d type=gradle-project -d baseDir=another-project | tar -xzvf - ---- -NOTE: The `/starter.tgz` endpoint offers the same feature as `/starter.zip` but generates +NOTE: The `/starter.tgz` endpoint offers the same feature as `/starter.zip` but generates a compressed tarball instead. You could use this infrastructure to create your own client since the project is generated @@ -177,43 +181,7 @@ You may also want to <>. [[build]] == Building from Source -You need Java (1.6 or better) and a bash-like shell. - -If you are on a Mac and using http://brew.sh/[homebrew], all you need to do to install it is: - -[indent=0] ----- - $ brew tap pivotal/tap - $ brew install springboot ----- - -It will install `/usr/local/bin/spring`. You can jump right to <>. - -An alternative way to install the `spring` command line interface can be installed like this: - -[indent=0] ----- - $ curl start.spring.io/install.sh | bash ----- - -After running that command you should see a `spring` directory: - -[indent=0] ----- - $ ./spring/bin/spring --help - - usage: spring [--help] [--version] - [] - ... ----- - -You could add that `bin` directory to your `PATH` (the examples below -assume you did that). - -If you don't have `curl` or `zip` you can probably get them (for -Windows users we recommend http://cygwin.org[cygwin]), or you can -download the http://start.spring.io/spring.zip[zip file] and unpack -it yourself. +You need Java (1.7 or better), Maven 3.2+ and a bash-like shell. [[building]] === Building @@ -237,13 +205,13 @@ If you want to run the smoke tests using Geb, you need to enable the [[run-app]] === Running the app locally -Once you have <>, you can easily start the app using the `spring` command -from the `initializr-service` directory: +Once you have <>, you can easily start the app as any other +Spring Boot app from the `initializr-service` directory: [indent=0] ---- $ cd initializr-service - $ spring run app.groovy + $ mvn spring-boot:run ---- ## Deploying to Cloud Foundry @@ -258,29 +226,23 @@ If you are on a Mac and using http://brew.sh/[homebrew], install the Cloud Found Alternatively, download a suitable binary for your platform from https://console.run.pivotal.io/tools[Pivotal Web Services]. -An example Cloud Foundry `manifest.yml` file is provided. You should ensure that -the application name and URL (name and host values) are suitable for your environment -before running `cf push`. +You should ensure that the application name and URL (name and host values) are suitable for +your environment before running `cf push`. -You can jar up the app and make it executable in any environment. +Make sure first that the jar has been created: [indent=0] ---- - $ spring jar start.jar app.groovy + $ mvn package ---- Once the jar has been created, you can push the application: [indent=0] ---- - $ cf push start -p start.jar -n start- + $ cf push your-initializr -p target/initializr-service-1.0.0.BUILD-SNAPSHOT ---- -Where `` is the name of the space. As a failsafe, and a -reminder to be explicit, the deployment will fail in production -without the `-n`. It is needed to select the route because there is a -manifest that defaults it to `start-development`. - == License Spring Initializr is Open Source software released under the http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license]. \ No newline at end of file diff --git a/initializr-service/app.groovy b/initializr-service/app.groovy deleted file mode 100644 index 9ee7fc60..00000000 --- a/initializr-service/app.groovy +++ /dev/null @@ -1,39 +0,0 @@ -package app - -import java.util.concurrent.Executor - -import org.springframework.context.annotation.Configuration -import org.springframework.scheduling.annotation.AsyncConfigurerSupport -import org.springframework.scheduling.annotation.EnableAsync -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - -import io.spring.initializr.web.project.LegacyStsController - -@Grab('io.spring.initializr:initializr-actuator:1.0.0.BUILD-SNAPSHOT') -@Grab('io.spring.initializr:initializr-web:1.0.0.BUILD-SNAPSHOT') -@Grab('spring-boot-starter-web') -@Grab('spring-boot-starter-redis') -class InitializerService { - - @Bean - @SuppressWarnings("deprecation") - LegacyStsController legacyStsController() { - new LegacyStsController() - } - - @Configuration - @EnableAsync - static class AsyncConfiguration extends AsyncConfigurerSupport { - - @Override - Executor getAsyncExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor() - executor.setCorePoolSize(1) - executor.setMaxPoolSize(5) - executor.setThreadNamePrefix("initializr-") - executor.initialize() - executor - } - - } -} \ No newline at end of file diff --git a/initializr-service/logback.xml b/initializr-service/logback.xml deleted file mode 100644 index abe7cce7..00000000 --- a/initializr-service/logback.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/initializr-service/manifest.yml b/initializr-service/manifest.yml deleted file mode 100644 index c54389ab..00000000 --- a/initializr-service/manifest.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -applications: -- name: start - memory: 1024M - host: start-development - domain: cfapps.io - path: . diff --git a/initializr-service/pom.xml b/initializr-service/pom.xml new file mode 100644 index 00000000..3d7f54e9 --- /dev/null +++ b/initializr-service/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + io.spring.initializr + initializr + 1.0.0.BUILD-SNAPSHOT + + initializr-service + Spring Initializr :: Service + + + + org.springframework.boot + spring-boot-starter-web + + + + io.spring.initializr + initializr-web + + + io.spring.initializr + initializr-actuator + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/initializr-service/src/main/groovy/io/spring/initializr/service/InitializrService.groovy b/initializr-service/src/main/groovy/io/spring/initializr/service/InitializrService.groovy new file mode 100644 index 00000000..3eb01540 --- /dev/null +++ b/initializr-service/src/main/groovy/io/spring/initializr/service/InitializrService.groovy @@ -0,0 +1,67 @@ +/* + * Copyright 2012-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.spring.initializr.service + +import java.util.concurrent.Executor + +import io.spring.initializr.web.project.LegacyStsController + +import org.springframework.boot.SpringApplication +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.scheduling.annotation.AsyncConfigurerSupport +import org.springframework.scheduling.annotation.EnableAsync +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor + +/** + * Initializr service application. Enables legacy STS support for older + * clients. + * + * @author Stephane Nicoll + * @since 1.0 + */ +@SpringBootApplication +class InitializrService { + + public static void main(String[] args) { + SpringApplication.run(InitializrService, args) + } + + @Bean + @SuppressWarnings("deprecation") + LegacyStsController legacyStsController() { + new LegacyStsController() + } + + @Configuration + @EnableAsync + static class AsyncConfiguration extends AsyncConfigurerSupport { + + @Override + Executor getAsyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor() + executor.setCorePoolSize(1) + executor.setMaxPoolSize(5) + executor.setThreadNamePrefix("initializr-") + executor.initialize() + executor + } + + } + +} diff --git a/initializr-service/application-cloud.yml b/initializr-service/src/main/resources/application-cloud.yml similarity index 100% rename from initializr-service/application-cloud.yml rename to initializr-service/src/main/resources/application-cloud.yml diff --git a/initializr-service/application.yml b/initializr-service/src/main/resources/application.yml similarity index 99% rename from initializr-service/application.yml rename to initializr-service/src/main/resources/application.yml index 85a42ca5..dd906086 100644 --- a/initializr-service/application.yml +++ b/initializr-service/src/main/resources/application.yml @@ -6,6 +6,11 @@ info: spring-boot: version: 1.3.6.RELEASE +logging: + level: + org.springframework.core.env: warn + org.springframework.jndi: warn + server: compression: enabled: true diff --git a/pom.xml b/pom.xml index fa1709c4..033d61dc 100644 --- a/pom.xml +++ b/pom.xml @@ -194,4 +194,13 @@ + + + full + + initializr-service + + + +