-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
137 lines (119 loc) · 3.58 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
plugins {
id 'eclipse'
id 'java-library'
id 'maven-publish'
id 'signing'
}
repositories {
mavenCentral()
}
dependencies {
api 'com.jakewharton.picnic:picnic:0.5.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
}
test {
useJUnitPlatform()
}
version readVersionFile()
ext {
gitCommit = getGitCommit()
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
}
java {
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
jar {
manifest {
attributes(
'Implementation-Version': archiveVersion,
'Implementation-GitRevision': rootProject.ext.gitCommit,
'Built-Date': rootProject.ext.builtDate,
'Built-JDK': System.getProperty('java.version'),
'Built-Gradle': gradle.gradleVersion,
'Built-By': System.getProperty('user.name'),
)
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'eu.geekplace'
artifactId = 'picnic-table-builder'
from components.java
pom {
name = 'Picnic Table Builder'
description = 'Easy API to create HTML-like tables that look nice when rendered as Unicode / ASCII'
url = 'https://github.com/Flowdalic/picnic-table-builder'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'flow'
name = 'Florian Schmaus'
email = 'flo@geekplace.eu'
}
}
scm {
connection = 'scm:git:https://github.com/Flowdalic/picnic-table-builder.git'
developerConnection = 'scm:git:git@github.com:Flowdalic/picnic-table-builder.git'
url = 'https://github.com/Flowdalic/picnic-table-builder'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
url = version.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
}
signing {
useGpgCmd()
sign publishing.publications.mavenJava
}
def readVersionFile() {
def versionFile = new File(rootDir, 'version')
if (!versionFile.isFile()) {
throw new Exception("Could not find version file")
}
if (versionFile.text.isEmpty()) {
throw new Exception("Version file does not contain a version")
}
versionFile.text.trim()
}
def getGitCommit() {
def projectDirFile = new File("$projectDir")
def dotGit = new File(projectDirFile, ".git")
if (!dotGit.isDirectory()) return 'non-git build'
def cmd = 'git describe --always --tags --dirty=+'
def proc = cmd.execute(null, projectDirFile)
proc.waitForOrKill(10 * 1000)
def gitCommit = proc.text.trim()
assert !gitCommit.isEmpty()
def srCmd = 'git symbolic-ref --short HEAD'
def srProc = srCmd.execute(null, projectDirFile)
srProc.waitForOrKill(10 * 1000)
if (srProc.exitValue() == 0) {
// Only add the information if the git command was
// successful. There may be no symbolic reference for HEAD if
// e.g. in detached mode.
def symbolicReference = srProc.text.trim()
assert !symbolicReference.isEmpty()
gitCommit += "-$symbolicReference"
}
gitCommit
}