mirror of
https://github.com/jht5945/springbootswaggersample.git
synced 2025-12-27 18:10:04 +08:00
80 lines
2.1 KiB
Groovy
80 lines
2.1 KiB
Groovy
apply plugin: 'java'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'idea'
|
|
|
|
|
|
def buildJSON = new groovy.json.JsonSlurper().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' }
|
|
}
|
|
|
|
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}")
|
|
}
|
|
}
|
|
}
|
|
|
|
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')
|
|
}
|