forked from bolcom/jcollectd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
190 lines (157 loc) · 5.46 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import static org.gradle.api.JavaVersion.*
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'net.researchgate.release'
group = 'com.hardis.collectd'
archivesBaseName = "jcollectd"
repositories { jcenter() }
sourceCompatibility = VERSION_1_6
targetCompatibility = VERSION_1_6
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task generateHtmlFromMarkdown {
inputs.file 'README.markdown'
outputs.file "$buildDir/README.html"
doLast() {
file(buildDir).mkdir() // Not sure why we need this (outputs.file should do this for us) but we do
new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'markdown'
args = ['README.markdown']
standardOutput = os
}
outputs.files.singleFile.text = os.toString()
}
}
}
task assembleBinaryDistro(type: Tar) {
compression 'gzip'
from (projectDir) {
include 'build.gradle'
include 'LICENSE'
include 'README.markdown'
include 'etc/*.xml'
}
from generateHtmlFromMarkdown.outputs
into('lib') {
from jar.outputs
from sourcesJar.outputs
}
into('javadoc') { from javadoc.outputs }
into('src/main') { from sourceSets.main.allJava }
into('src/test') { from sourceSets.test.allJava }
}
task wrapper(type: Wrapper) {
gradleVersion = '3.3' //version required
}
afterReleaseBuild.dependsOn uploadArchives
artifacts {
archives sourcesJar
archives javadocJar
}
signing {
sign configurations.archives
}
jar {
manifest {
attributes ('Main-Class': 'org.collectd.mx.MBeanReceiver',
'Premain-Class': 'org.collectd.mx.RemoteMBeanSender')
}
// Get the git commit hash (and add it to the manifest) in a doFirst (instead of a config block) so it only actually
// runs if the task is run (and not if the task is UP-TO-DATE)
// doFirst() { jar.manifest.attributes('Commit': getGitCommitHash()) }
from (projectDir) {
include 'etc/*.xml'
}
}
javadoc {
project.configure(options) {
author = "false"
bottom = "Copyright © 2009 <a target=\"_top\" href=\"http://www.hyperic.com/\">Hyperic, Inc.</a>. All Rights Reserved."
charSet = "UTF-8"
docTitle = "Jcollectd"
header = "<b>Java collectd API</b>"
use = "true"
version = "false"
windowTitle = "Java collectd API"
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.ext.mavenUser, password: project.ext.mavenPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: project.ext.mavenUser, password: project.ext.mavenPassword)
}
pom.project {
name 'jcollectd'
packaging 'jar'
// optionally artifactId can be defined here
description 'The jcollectd package implements the collectd protocol in Java, making it possible for Java applications to push data into collectd over the wire.'
url 'https://github.com/hardisgroupcom/jcollectd'
scm {
connection 'scm:git:https://github.com/hardisgroupcom/jcollectd.git'
developerConnection 'scm:git:https://github.com/hardisgroupcom/jcollectd.git'
url 'https://github.com/hardisgroupcom/jcollectd'
}
licenses {
license {
name 'GNU GENERAL PUBLIC LICENSE Version 2, June 1991'
url 'https://www.gnu.org/licenses/old-licenses/gpl-2.0.fr.html'
}
}
developers {
developer {
name 'Doug MacEachern'
organization 'Hyperic'
}
}
}
}
}
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile files(org.gradle.internal.jvm.Jvm.current().toolsJar)
testCompile "junit:junit:4.11"
}
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.researchgate:gradle-release:2.4.0'
}
}
// Get the git commit hash for the current tree using the system git executable.
// The executable must but on the PATH for this to work. If there is any type of error
// the method will return "unknown"
def getGitCommitHash() {
def hashOutput = new ByteArrayOutputStream()
def hashError = new ByteArrayOutputStream()
def result = exec {
executable = 'git'
args = ['describe', '--tags', '--always', 'HEAD']
standardOutput = hashOutput
errorOutput = hashError
ignoreExitValue = true
}
if(result.getExitValue() != 0) {
logger.warn "Something with wrong while getting the git commit hash. See error output below. Using 'unknown' as the commit hash value."
logger.warn hashError.toString()
return "unknown"
}
return hashOutput.toString()
}