feat: init commit
This commit is contained in:
24
template.toml
Normal file
24
template.toml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name = "Java template"
|
||||||
|
description = "Java application template"
|
||||||
|
kickstart_version = 1
|
||||||
|
ignore = [
|
||||||
|
".gitignore",
|
||||||
|
"README.md",
|
||||||
|
"LICENSE",
|
||||||
|
]
|
||||||
|
|
||||||
|
cleanup = [
|
||||||
|
]
|
||||||
|
|
||||||
|
[[variables]]
|
||||||
|
name = "project_name"
|
||||||
|
default = "Sample-App"
|
||||||
|
prompt = "What's the name of the project?"
|
||||||
|
validation = "^([a-zA-Z][a-zA-Z0-9_-]+)$"
|
||||||
|
|
||||||
|
[[variables]]
|
||||||
|
name = "archive_name"
|
||||||
|
default = "sampleapp"
|
||||||
|
prompt = "What's the archive name of the project?"
|
||||||
|
validation = "^([a-zA-Z][a-zA-Z0-9_-]+)$"
|
||||||
|
|
||||||
92
{{project_name}}/build.gradle
Normal file
92
{{project_name}}/build.gradle
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'eclipse'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
|
||||||
|
def JsonSlurper = Class.forName('groovy.json.JsonSlurper');
|
||||||
|
def buildJSON = JsonSlurper.newInstance().parseText(new File("build.json").text)
|
||||||
|
|
||||||
|
if (buildJSON.application) { apply plugin: 'application' }
|
||||||
|
|
||||||
|
def baseProjectName = buildJSON?.project?.name ?: '__project_name__';
|
||||||
|
def shellCommandName = baseProjectName
|
||||||
|
def eclipseProjectName = baseProjectName
|
||||||
|
def eclipseProjectComment = buildJSON?.project?.comment ?: '__project_name_comment__'
|
||||||
|
def jarManifestMainClass = buildJSON?.project?.main ?: 'SampleMain'
|
||||||
|
|
||||||
|
if (buildJSON.application) { mainClassName = jarManifestMainClass }
|
||||||
|
archivesBaseName = buildJSON?.project?.archiveName ?: baseProjectName
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
def addRepo = new File(System.getProperty("user.home"), ".build_add.repo")
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
// mavenCentral()
|
||||||
|
maven() { url 'https://maven.aliyun.com/repository/central' }
|
||||||
|
if (addRepo.exists()) { maven() { url addRepo.text.trim() } }
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
// '-x test' skip unit test
|
||||||
|
defaultTasks 'build'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
maven() { url 'https://maven.aliyun.com/repository/central' }
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.11.RELEASE")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply plugin: 'org.springframework.boot'
|
||||||
|
springBoot {
|
||||||
|
mainClass = jarManifestMainClass
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile files(fileTree(dir: 'lib', includes: ['*.jar'], excludes: ['*-sources.jar', '*-javadoc.jar']))
|
||||||
|
|
||||||
|
if (buildJSON.repo != null && buildJSON.repo.dependencies != null) {
|
||||||
|
buildJSON.repo.dependencies.each {
|
||||||
|
compile("${it}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buildJSON.repo != null && buildJSON.repo.testDependencies != null) {
|
||||||
|
buildJSON.repo.testDependencies.each {
|
||||||
|
testCompile("${it}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eclipse {
|
||||||
|
project {
|
||||||
|
name = eclipseProjectName
|
||||||
|
comment = eclipseProjectComment
|
||||||
|
}
|
||||||
|
classpath {
|
||||||
|
defaultOutputDir = file('classes')
|
||||||
|
downloadSources = true
|
||||||
|
file {
|
||||||
|
whenMerged { classpath ->
|
||||||
|
classpath.entries.findAll { it.kind=='lib' }.each {
|
||||||
|
if ((it.path != null) && (it.sourcePath == null) && file(it.path.replace(".jar", "-sources.jar")).exists()) {
|
||||||
|
it.sourcePath = getFileReferenceFactory().fromPath(it.path.replace(".jar", "-sources.jar"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eclipseJdt << {
|
||||||
|
File f = file('.settings/org.eclipse.core.resources.prefs')
|
||||||
|
f.write('eclipse.preferences.version=1\n')
|
||||||
|
f.append('encoding/<project>=utf-8')
|
||||||
|
}
|
||||||
21
{{project_name}}/build.json
Normal file
21
{{project_name}}/build.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"project": {
|
||||||
|
"name": "{{project_name}}",
|
||||||
|
"main": "SampleMain",
|
||||||
|
"archiveName": "{{archive_name}}"
|
||||||
|
},
|
||||||
|
"application": false,
|
||||||
|
"java": "1.8",
|
||||||
|
"builder": {
|
||||||
|
"name": "gradle",
|
||||||
|
"version": "3.1"
|
||||||
|
},
|
||||||
|
"repo": {
|
||||||
|
"dependencies": [
|
||||||
|
"me.hatter:commons:3.0"
|
||||||
|
],
|
||||||
|
"testDependencies": [
|
||||||
|
"junit:junit:4.12"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
0
{{project_name}}/main/java/.keep
Normal file
0
{{project_name}}/main/java/.keep
Normal file
0
{{project_name}}/main/resources/.keep
Normal file
0
{{project_name}}/main/resources/.keep
Normal file
0
{{project_name}}/test/java/.keep
Normal file
0
{{project_name}}/test/java/.keep
Normal file
0
{{project_name}}/test/resources/.keep
Normal file
0
{{project_name}}/test/resources/.keep
Normal file
Reference in New Issue
Block a user