forked from bdclark/elasticsearch-consul-discovery
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
149 lines (126 loc) · 3.79 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import com.github.mgk.gradle.*
buildscript {
dependencies {
classpath group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
classpath group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
classpath group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
classpath group: 'javax.activation', name: 'activation', version: '1.1.1'
}
}
plugins {
id "java"
id "checkstyle"
id "co.riiid.gradle" version "0.4.2"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
println "Host: " + java.net.InetAddress.getLocalHost()
println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion()
println "Build: group: '${project.group}', name: '${project.name}', version: '${project.version}'"
println "Timestamp: " + java.time.Instant.now().atZone(java.time.ZoneId.systemDefault()).toString()
repositories {
mavenCentral()
mavenLocal()
}
ext {
versions = [
"elasticsearch": version.replaceAll(/\.[0-9]+(|-SNAPSHOT)$/, ""),
"gson": "2.3.1",
"log4j": "2.6.2",
"junit": "4.12"
]
}
configurations {
releaseJars {
extendsFrom runtime
exclude group: "org.elasticsearch"
exclude group: "com.fasterxml.jackson.core", module: "jackson-core"
exclude group: "org.apache.logging.log4j"
}
}
dependencies {
compile "org.elasticsearch:elasticsearch:${versions.elasticsearch}"
compile "com.google.code.gson:gson:${versions.gson}"
compile "org.apache.logging.log4j:log4j-api:${versions.log4j}"
testCompile "junit:junit:${versions.junit}"
releaseJars "${project.group}:${project.name}:${project.version}"
}
compileJava {
options.encoding = "UTF-8"
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked,deprecation"
}
task javadocJar(type: Jar, dependsOn: classes) {
from javadoc
into "build/tmp"
classifier "javadoc"
}
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
into "build/tmp/sources"
classifier "sources"
}
task copyPluginFiles(type: Copy) {
from "src/main/templates"
into "build/tmp/plugin"
expand([
"descriptor": [
"name" : pluginName,
"classname" : pluginClassname,
"description" : pluginDescription,
"version" : project.property("version"),
"javaVersion" : project.property("targetCompatibility"),
"elasticsearchVersion": versions.elasticsearch
]
])
outputs.upToDateWhen { false }
}
task buildPluginZip(type: Zip, dependsOn: [":jar", "copyPluginFiles"]) {
from configurations.releaseJars
from "build/tmp/plugin"
}
artifacts {
archives javadocJar, sourcesJar, buildPluginZip
}
checkstyle {
configFile = new File(rootDir, "checkstyle.xml")
toolVersion = "8.2"
}
def getGitCommitHash() {
def gitFolderPath = "$projectDir/.git/"
def gitFolder = new File(gitFolderPath + "HEAD");
if (!gitFolder.exists()) {
return null
}
def head = gitFolder.text.split(":")
def isCommit = (head.length == 1)
if (isCommit) {
return head[0].trim()
}
def refHead = new File(gitFolderPath + head[1].trim())
return refHead.text.trim()
}
github {
owner = github_owner
repo = github_repo
token = github_token
tagName = version
targetCommitish = getGitCommitHash()
name = version
assets = [
"build/distributions/${project.name}-${version}.zip"
]
}
githubRelease {
dependsOn("buildPluginZip")
}
task release() {
if (version.endsWith("-SNAPSHOT")) {
doLast {
println("SNAPSHOT: Nothing to release !")
}
} else {
dependsOn(["githubRelease"])
}
}