My gradle build script as below.
buildscript {
ext {
springBootVersion = '1.5.8.RELEASE'
startClass='xxxx.xxx.xxx'
buildType='sandbox'
depotInfo='none'
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE")
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.ajoberstar:gradle-git-publish:0.3.2'
classpath 'org.springframework.cloud:spring-cloud-contract-gradle-plugin:1.1.3.RELEASE'
}
}
apply from: 'gradle/utils.gradle'
apply from: 'gradle/properties.gradle'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'org.ajoberstar.git-publish'
apply plugin: 'war'
apply plugin: 'groovy'
apply plugin: 'spring-cloud-contract'
apply from: 'gradle/jacoco.gradle'
apply from: 'gradle/dependency-report.gradle'
def grgit = Grgit.open(dir: projectDir)
task generateGitProperties {
def branchName = grgit.branch.current.name
def gitHash = grgit.head().id
def buildTime = new Date().toString()
delete 'src/main/resources/git.properties'
def text = "git.commit.id=${gitHash}\ngit.build.time=${buildTime}\ngit.branch=${branchName}"
def git = new File('/Users/yiogao/code/epc-review-notification-service/src/main/resources/git.properties')
git.text = text
def active = new File('active.txt')
active.text = "${gitHash}"
version = gitHash
}
project.tasks.classes.dependsOn(generateGitProperties)
group = 'xxx.xxxx.xxx'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url "xxx.xxx.xxx" }
}
configurations.all {
exclude group: 'com.netflix.feign', module: 'feign-core'
exclude group: 'com.netflix.feign', module: 'feign-jackson'
exclude group: 'com.netflix.feign', module: 'feign-gson'
exclude group: 'com.netflix.feign', module: 'feign-hystrix'
exclude group: 'com.netflix.feign', module: 'feign-slf4j'
exclude (module: 'spring-boot-starter-logging')
exclude (module: "logback-classic")
exclude (module: 'commons-logging')
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
xxx
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:1.1.3.RELEASE"
}
}
contracts {
testMode = 'MockMvc'
packageWithBaseClasses = 'xxx.xxx.xxx'
contractsDslDir = file("${project.projectDir}/src/test/resources/contracts/")
}
asciidoctor {
sourceDir = file('src/main/docs')
outputDir "$projectDir/src/main/resources/public"
backends 'html5'
attributes 'source-highlighter' : 'prettify'
}
task cleanTempDir(type: Delete) {
delete fileTree(dir: 'src/main/resources/public')
}
clean {
dependsOn cleanTempDir
}
build {
dependsOn asciidoctor
}
task publish(type: GradleBuild) {
dependsOn asciidoctor
tasks = ['publishGhPages']
}
task wrapper(type: Wrapper) {
gradleVersion = '4.2.1'
}
task contractTest(type: Test) {
configure {
systemProperty "contractTest.environment", System.getProperty("contractTest.environment")
systemProperty "apiToken", System.getProperty("apiToken")
systemProperty "remoteDriver", System.getProperty("remoteDriver")
}
}
bootRun {
dependsOn asciidoctor
configure {
systemProperty "AWS_REGION", System.getProperty("AWS_REGION")
systemProperty "application.environment", "dev"
systemProperty "spring.profiles.active", "dev"
systemProperty "application.home", "."
}
jvmArgs=["-Dproject.name=${project.name}",
"-Dapplication.name=${project.name}",
'-Dapplication.environment=dev',
'-Dapplication.home=.',
'-Xdebug',
'-Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=n']
}
war {
manifest {
attributes("Application-Name": "${project.name}",
"Application-Version": "${project.version}",
"Application-Description": "${project.description}",
"Implementation-Title": "${project.name}",
"Implementation-Version": "${grgit.head().id}",
"Implementation-Vendor": "Expedia",
"Built-By": System.getProperty("user.name"),
"Build-Jdk": System.getProperty("java.version"),
"Build-Time": new Date(),
"Build": "${buildType}",
"Branch": "${grgit.branch.current.name}",
"Depot": "${depotInfo}",
"mainClass": "${startClass}")
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>