mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-16 07:57:19 +08:00
Download starter.zip from home page
This commit is contained in:
parent
a7433b094c
commit
9d4a6bf6c5
14
.cfignore
Normal file
14
.cfignore
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.gradle
|
||||||
|
*.sw?
|
||||||
|
.#*
|
||||||
|
*#
|
||||||
|
*~
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
bin
|
||||||
|
build
|
||||||
|
target
|
||||||
|
.springBeans
|
||||||
|
tmp*
|
||||||
|
spring.zip
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@ bin
|
|||||||
build
|
build
|
||||||
target
|
target
|
||||||
.springBeans
|
.springBeans
|
||||||
|
tmp*
|
||||||
spring
|
spring
|
||||||
grapes
|
grapes
|
||||||
spring.zip
|
spring.zip
|
||||||
|
41
app.groovy
41
app.groovy
@ -50,14 +50,42 @@ class MainController {
|
|||||||
new ResponseEntity<byte[]>(download.bytes, ["Content-Type":"application/zip"] as HttpHeaders, HttpStatus.OK)
|
new ResponseEntity<byte[]>(download.bytes, ["Content-Type":"application/zip"] as HttpHeaders, HttpStatus.OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/starter")
|
||||||
|
@ResponseBody
|
||||||
|
ResponseEntity<byte[]> spring(PomRequest request) {
|
||||||
|
|
||||||
|
def model = [:]
|
||||||
|
String pom = new String(pom(request, model).body)
|
||||||
|
File dir = File.createTempFile("tmp","",new File(tmpdir));
|
||||||
|
dir.delete()
|
||||||
|
dir.mkdirs()
|
||||||
|
new File(dir, "pom.xml").write(pom)
|
||||||
|
|
||||||
|
File src = new File(new File(dir, "src/main/java"),request.packageName.replace(".", "/"))
|
||||||
|
src.mkdirs()
|
||||||
|
|
||||||
|
def body = template "Application.java", model
|
||||||
|
log.info("Creating: " + src + "Application.java")
|
||||||
|
new File(src, "Application.java").write(body)
|
||||||
|
|
||||||
|
File download = new File(tmpdir, dir.name + ".zip")
|
||||||
|
log.info("Creating: " + download)
|
||||||
|
|
||||||
|
new AntBuilder().zip(destfile: download) {
|
||||||
|
zipfileset(dir:dir, includes:"**")
|
||||||
|
}
|
||||||
|
log.info("Downloading: " + download)
|
||||||
|
new ResponseEntity<byte[]>(download.bytes, ["Content-Type":"application/zip"] as HttpHeaders, HttpStatus.OK)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/pom")
|
@RequestMapping("/pom")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
ResponseEntity<byte[]> pom(PomRequest request) {
|
ResponseEntity<byte[]> pom(PomRequest request, Map model) {
|
||||||
|
|
||||||
def style = request.style
|
def style = request.style
|
||||||
log.info("Styles requested: " + style)
|
log.info("Styles requested: " + style)
|
||||||
|
|
||||||
def model = [:]
|
|
||||||
model.groupId = request.groupId
|
model.groupId = request.groupId
|
||||||
model.artifactId = request.artifactId
|
model.artifactId = request.artifactId
|
||||||
model.version = request.version
|
model.version = request.version
|
||||||
@ -68,7 +96,7 @@ class MainController {
|
|||||||
if (style==null || style.size()==0) {
|
if (style==null || style.size()==0) {
|
||||||
style = [""]
|
style = [""]
|
||||||
}
|
}
|
||||||
model["styles"] = style.collect{ it=="" ? "" : it + "-" }
|
model["styles"] = style.collect{ it=="" ? "" : "-" + it }
|
||||||
|
|
||||||
log.info("Model: " + model)
|
log.info("Model: " + model)
|
||||||
|
|
||||||
@ -107,13 +135,8 @@ class MainController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Grab("org.springframework.security:spring-security-config:3.2.0.M2")
|
|
||||||
@Grab(value="org.springframework.security:spring-security-web:3.2.0.M2", transitive=false)
|
|
||||||
import org.springframework.security.config.annotation.web.*
|
|
||||||
import org.springframework.security.authentication.*
|
|
||||||
import org.springframework.security.core.Authentication
|
|
||||||
import org.springframework.security.core.authority.AuthorityUtils
|
|
||||||
import org.springframework.actuate.properties.SecurityProperties
|
import org.springframework.actuate.properties.SecurityProperties
|
||||||
|
@EnableWebSecurity
|
||||||
@Configuration
|
@Configuration
|
||||||
@Log
|
@Log
|
||||||
class SecurityConfiguration {
|
class SecurityConfiguration {
|
||||||
|
@ -6,4 +6,4 @@ applications:
|
|||||||
url: initializr.cfapps.io
|
url: initializr.cfapps.io
|
||||||
path: .
|
path: .
|
||||||
command: java -jar ./spring/lib/*.jar run --local app.groovy -- --server.port=$PORT
|
command: java -jar ./spring/lib/*.jar run --local app.groovy -- --server.port=$PORT
|
||||||
buildpack: https://github.com/cloudfoundry/cloudfoundry-buildpack-java
|
# buildpack: https://github.com/dsyer/cloudfoundry-buildpack-java
|
||||||
|
1
system.properties
Normal file
1
system.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
java.runtime.version=1.6
|
14
templates/Application.java
Normal file
14
templates/Application.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package ${packageName};
|
||||||
|
|
||||||
|
import org.springframework.bootstrap.SpringApplication;
|
||||||
|
import org.springframework.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
|
@ComponentScan
|
||||||
|
@EnableAutoConfiguration
|
||||||
|
public class Application {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(Application.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>Spring Initializr</h1>
|
<h1>Spring Initializr</h1>
|
||||||
<div>
|
<div>
|
||||||
<form action="/pom" method="get">
|
<form action="/starter.zip" method="get">
|
||||||
<label for="groupId">Group:</label> <input id="groupId" type="text" value="org.demo" name="groupId"/>
|
<label for="groupId">Group:</label> <input id="groupId" type="text" value="org.demo" name="groupId"/>
|
||||||
<label for="artifactId">Artifact:</label> <input id="artifactId" type="text" value="demo" name="artifactId"/>
|
<label for="artifactId">Artifact:</label> <input id="artifactId" type="text" value="demo" name="artifactId"/>
|
||||||
<label for="name">Name:</label> <input id="name" type="text" value="demo" name="name"/>
|
<label for="name">Name:</label> <input id="name" type="text" value="demo" name="name"/>
|
||||||
|
@ -19,19 +19,19 @@
|
|||||||
<dependencies><% styles.each { %>
|
<dependencies><% styles.each { %>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.zero</groupId>
|
<groupId>org.springframework.zero</groupId>
|
||||||
<artifactId>spring-starter-${it}</artifactId>
|
<artifactId>spring-starter${it}</artifactId>
|
||||||
</dependency><% } %>
|
</dependency><% } %>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<start-class>${packageName}.ApplicationConfiguration</start-class>
|
<start-class>${packageName}.Application</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.springframework.zero</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>spring-package-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
Loading…
Reference in New Issue
Block a user