-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
131 lines (107 loc) · 2.62 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
plugins {
id 'java'
id 'maven'
id 'maven-publish'
id 'com.jfrog.bintray' version '1.7.2'
}
group = 'pw.aru.api'
version = new Version(major: 1, minor: 0, revision: 0)
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
//HTTP
compile 'com.github.natanbc:reliqua:2.3.2'
//JSON parser
compile 'org.json:json:20170516'
//Logging
compile 'org.slf4j:slf4j-api:1.7.25'
//Code safety
compile 'com.google.code.findbugs:jsr305:3.0.2'
}
import org.apache.tools.ant.filters.ReplaceTokens
task sourcesForRelease(type: Copy) {
from 'src/main/java'
into 'build/filteredSrc'
filter(ReplaceTokens, tokens: [
VERSION_MAJOR : version.getMajor(),
VERSION_MINOR : version.getMinor(),
VERSION_REVISION: version.getRevision(),
COMMIT_HASH : getCommitHash()
])
}
compileJava {
source = sourcesForRelease.destinationDir
classpath = sourceSets.main.compileClasspath
options.encoding = 'UTF-8'
dependsOn sourcesForRelease
}
jar {
baseName = project.name
manifest {
attributes 'Implementation-Version': version
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from "${buildDir}/filteredSrc"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
failOnError = false
options.memberLevel = JavadocMemberLevel.PUBLIC
options.author()
options.encoding = 'UTF-8'
options.addStringOption('-html5')
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
BintrayRelease(MavenPublication) {
from components.java
groupId group
artifactId project.name
version project.version
artifact javadocJar
artifact sourcesJar
}
}
}
bintray {
user = bintrayUsername
key = bintrayApiKey
publications = ['BintrayRelease']
pkg {
repo = 'maven'
name = project.name
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/arubot/Nekos4J.git'
publish = true
version {
name = project.version
}
}
}
bintrayUpload {
dependsOn build
dependsOn 'publishBintrayReleasePublicationToMavenLocal'
}
static def getCommitHash() {
def p = Runtime.getRuntime().exec("git rev-parse HEAD")
p.waitFor()
p.getIn().text.trim()
}
class Version {
String major, minor, revision
String toString() {
"${major}.${minor}" + (revision == "0" ? "" : ".${revision}")
}
}