-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.gradle
129 lines (108 loc) · 3.21 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
import java.text.SimpleDateFormat
def globalVersion = new Version(version)
task wrapper(type: Wrapper) {
gradleVersion = '4.0'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1'
}
}
// configures all sub-projects consistently
subprojects {
apply plugin: 'java'
apply plugin: 'findbugs'
version = globalVersion
status = version.status
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
jcenter()
}
// code quality
findbugs {
effort = "max"
reportLevel = "medium"
includeFilter = file("$rootProject.projectDir/findBugsIncludeFilter.xml")
excludeFilter = file("$rootProject.projectDir/findBugsExcludeFilter.xml")
}
tasks.withType(FindBugs) {
reports {
xml.enabled false
html.enabled true
}
}
check.dependsOn test
build.dependsOn check
// artifacts
task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// publishing artifacts to Bintray JCenter
configurations {
published
}
// upload to JCenter
artifacts {
published sourceJar
published javadocJar
}
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven'
ext.publish = true
bintray {
// grab credentials from environment variables
user = "$System.env.BINTRAY_USER"
key = "$System.env.BINTRAY_API_KEY"
configurations = ['published', 'archives']
dryRun = false //Whether to run this as dry-run, without deploying
publish = true //If version should be auto published after an upload
pkg {
repo = 'structlog4j'
name = project.name
desc = 'Structured logging for Java on top of the SLF4jAPI'
websiteUrl = 'https://github.com/jacek99/structlog4j'
issueTrackerUrl = 'https://github.com/jacek99/structlog4j'
vcsUrl = 'https://github.com/jacek99/structlog4j'
licenses = ['MIT']
publicDownloadNumbers = true
}
}
// ensure code quality for published artifacts
install.dependsOn check
}
class Version {
String originalVersion
String thisVersion
String status
Date buildTime
Version(String versionValue) {
buildTime = new Date()
originalVersion = versionValue
if (originalVersion.endsWith('-SNAPSHOT')) {
status = 'integration'
thisVersion = originalVersion.substring(0, originalVersion.length() - 'SNAPSHOT'.length()) + getTimestamp()
} else {
status = 'release'
thisVersion = versionValue
}
}
String getTimestamp() {
// Convert local file timestamp to UTC
def format = new SimpleDateFormat('yyyyMMddHHmmss')
format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));
return format.format(buildTime)
}
String toString() {
thisVersion
}
}