Add JavaVersion feature

This commit is contained in:
Dave Syer 2014-05-30 06:18:33 +01:00
parent d6c77bb9ef
commit ba480960c3
5 changed files with 24 additions and 1 deletions

View File

@ -30,6 +30,7 @@ class MainController {
model['styles'] = projects.styles.sort { it.name } model['styles'] = projects.styles.sort { it.name }
model['types'] = projects.types.sort { it.name } model['types'] = projects.types.sort { it.name }
model['packagings'] = projects.packagings.sort { it.name } model['packagings'] = projects.packagings.sort { it.name }
model['javaVersions'] = projects.javaVersions
template 'home.html', model template 'home.html', model
} }
@ -178,6 +179,7 @@ class MainController {
model.description = request.description model.description = request.description
model.packageName = request.packageName model.packageName = request.packageName
model.packaging = request.packaging model.packaging = request.packaging
model.javaVersion = request.javaVersion
if (style==null || style.size()==0) { if (style==null || style.size()==0) {
style = [''] style = ['']
@ -236,6 +238,7 @@ class PomRequest {
String version = '0.0.1-SNAPSHOT' String version = '0.0.1-SNAPSHOT'
String packaging = 'jar' String packaging = 'jar'
String packageName String packageName
String javaVersion = '1.7'
String getArtifactId() { String getArtifactId() {
artifactId == null ? name : artifactId artifactId == null ? name : artifactId
} }
@ -250,6 +253,11 @@ class Projects {
List<Map<String,Object>> styles List<Map<String,Object>> styles
List<Type> types List<Type> types
List<Packaging> packagings List<Packaging> packagings
List<JavaVersion> javaVersions
static class JavaVersion {
String value
boolean selected
}
static class Packaging { static class Packaging {
String name String name
String value String value

View File

@ -80,3 +80,10 @@ projects:
- name: War - name: War
value: war value: war
selected: false selected: false
javaVersions:
- value: 1.6
selected: false
- value: 1.7
selected: true
- value: 1.8
selected: false

View File

@ -58,6 +58,12 @@
<input type="radio" name="packaging" value="${it.value}"${it.selected==true ? ' checked="true"' : ''}/> <input type="radio" name="packaging" value="${it.value}"${it.selected==true ? ' checked="true"' : ''}/>
${it.name} ${it.name}
</label><% } %> </label><% } %>
<label>Java Version:</label>
<% javaVersions.each { %>
<label class="radio">
<input type="radio" name="packaging" value="${it.value}"${it.selected==true ? ' checked="true"' : ''}/>
${it.value}
</label><% } %>
<button type="submit" class="btn">Generate</button> <button type="submit" class="btn">Generate</button>
</form> </form>
</div> </div>

View File

@ -24,6 +24,8 @@ apply plugin: 'war'
baseName = '${artifactId}' baseName = '${artifactId}'
version = '${version}' version = '${version}'
} }
sourceCompatibility = ${javaVersion}
targetCompatibility = ${javaVersion}
repositories { repositories {
mavenCentral()<% if (!bootVersion.contains("RELEASE")) { %> mavenCentral()<% if (!bootVersion.contains("RELEASE")) { %>

View File

@ -33,7 +33,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>${packageName}.Application</start-class> <start-class>${packageName}.Application</start-class>
<java.version>1.7</java.version> <java.version>${javaVersion}</java.version>
</properties> </properties>
<build> <build>