From 1e324dae15f12367bd84ea5b7b1bbde0c6d270d8 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 17 Nov 2019 00:18:31 +0800 Subject: [PATCH] Init commit --- .gitignore | 35 +++++++--------------- build.gradle | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ build.json | 21 +++++++++++++ 3 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 build.gradle create mode 100644 build.json diff --git a/.gitignore b/.gitignore index 84adb3f..94b7950 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,10 @@ -# ---> Java -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - +build +classes +.DS_Store +.gradle +.classpath +.project +.settings +*.iml +*.ipr +*.iws \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..c8c0cdc --- /dev/null +++ b/build.gradle @@ -0,0 +1,85 @@ +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) + +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 ?: 'me.hatter.sample.SampleMain' + +archivesBaseName = buildJSON?.project?.archiveName ?: baseProjectName +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + // mavenCentral() + maven() { url 'https://maven.aliyun.com/repository/central' } + maven() { url new File(System.getProperty("user.home") + "/.hatter_repo.url").text.trim() } +} + +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// '-x test' skip unit test +defaultTasks 'build' + +buildscript { + repositories { + mavenLocal() + 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/=utf-8') +} diff --git a/build.json b/build.json new file mode 100644 index 0000000..9c8d488 --- /dev/null +++ b/build.json @@ -0,0 +1,21 @@ +{ + "project": { + "name": "sample-reflections", + "main": "me.hatter.sample.Main", + "archiveName": "sample" + }, + "java": "1.8", + "builder": { + "name": "gradle", + "version": "3.1" + }, + "repo": { + "dependencies": [ + "me.hatter:commons:3.0", + "org.reflections:reflections:0.9.11" + ], + "testDependencies": [ + "junit:junit:4.12" + ] + } +}