-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
147 lines (129 loc) · 3.65 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
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
classpath 'org.eclipse.jgit:org.eclipse.jgit:3.5.0.201409260305-r'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'com.jfrog.bintray'
repositories.addAll rootProject.buildscript.repositories
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
javadoc {
options.encoding = 'UTF-8'
}
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.1'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
}
def determineVersion() {
def repo = new org.eclipse.jgit.storage.file.FileRepositoryBuilder()
.setGitDir(file("$projectDir/.git"))
.findGitDir()
.setMustExist(true)
.build()
def commitid = repo.getRef('HEAD').objectId.name
def branchName = System.getenv("CI_COMMIT_REF_NAME") ?: commitid
if (branchName.startsWith('release/')) {
return [
branch : branchName,
name : branchName.substring('release/'.length()),
commitid: commitid,
release : true
]
} else {
return [
branch : branchName,
name : '0.0.1-SNAPSHOT',
commitid: commitid,
release : false
]
}
}
def versionInfo = determineVersion()
println "Version info: ${versionInfo}"
group "com.dajudge.color-diff"
version versionInfo.name
task sourceJar(type: Jar) {
from sourceSets.main.allJava
classifier "sources"
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
build.dependsOn sourceJar, javadocJar
if (versionInfo.release) {
println "Artifacts will be released to bintray."
build.finalizedBy bintrayUpload
}
bintray {
user = System.getenv('BINTRAY_API_USER')
key = System.getenv('BINTRAY_API_KEY')
publications = ['mavenJava']
pkg {
version {
name = versionInfo.name
desc = "color-diff $versionInfo.name"
released = new Date()
vcsTag = versionInfo.commitid
}
repo = 'color-diff'
name = 'color-diff'
licenses = ['BSD 3-Clause']
vcsUrl = 'https://github.com/dajudge/color-diff.git'
}
}
def pomConfig = {
licenses {
license {
name "3-Clause BSD License"
url "https://opensource.org/licenses/BSD-3-Clause"
distribution "repo"
}
}
developers {
developer {
id "alexstockinger"
name "Alex Stockinger"
email "[email protected]"
}
}
scm {
url "https://github.com/dajudge/color-diff"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar
artifact javadocJar
groupId project.group
artifactId project.name
version versionInfo.name
pom.withXml {
def root = asNode()
root.appendNode('description', 'A library for comparing colors.')
root.appendNode('name', 'color-diff')
root.appendNode('url', 'https://github.com/dajudge/color-diff')
root.children().last() + pomConfig
}
}
}
}