-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.gradle
163 lines (138 loc) · 5.89 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
import java.text.SimpleDateFormat
plugins {
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'java-library'
id "org.sonarqube" version "4.0.0.2929"
id "net.nemerosa.versioning" version "3.0.0"
}
def version = SemVer.of(version.toString())
project.group = 'com.spinyowl'
processResources {
filesMatching('**/version.properties') {
filteringCharset = 'UTF-8'
expand "version_major": version.major,
"version_minor": version.minor,
"version_patch": version.patch,
"version_revision": versioning.info.build,
"version_full": project.version
}
}
printProjectInfo()
idea { module { downloadJavadoc = true; downloadSources = true } }
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
javadoc.options.encoding = 'UTF-8'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://raw.githubusercontent.com/SpinyOwl/repo/releases" }
}
dependencies {
//@formatter:off
api group: 'org.projectlombok', name: 'lombok', version: lombok_version
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombok_version
testCompileOnly group: 'org.projectlombok', name: 'lombok', version: lombok_version
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombok_version
api group: "org.joml", name: "joml", version: joml_version
api group: 'org.apache.commons', name: 'commons-lang3', version: commons_version, changing: false
api group: 'com.google.guava', name: 'guava', version: guava_version, changing: false
// https://mvnrepository.com/artifact/com.squareup.moshi/moshi
api group: 'com.squareup.moshi', name: 'moshi', version: moshi_version
api("com.spinyowl:cbchain:${cbchain_version}") {
exclude group: 'org.lwjgl'
}
api group: 'org.lwjgl', name: 'lwjgl-stb', version: lwjgl_version
api group: 'org.lwjgl', name: 'lwjgl-glfw', version: lwjgl_version
api group: 'org.lwjgl', name: 'lwjgl-nanovg', version: lwjgl_version
api group: 'org.lwjgl', name: 'lwjgl-opengl', version: lwjgl_version
api group: 'org.lwjgl', name: 'lwjgl', version: lwjgl_version
api group: 'org.lwjgl', name: 'lwjgl-yoga', version: lwjgl_version
def classifiers = ["natives-windows", "natives-linux", "natives-macos"]
for (c in classifiers) {
api group: 'org.lwjgl', name: 'lwjgl-stb', version: lwjgl_version, classifier: c
api group: 'org.lwjgl', name: 'lwjgl-glfw', version: lwjgl_version, classifier: c
api group: 'org.lwjgl', name: 'lwjgl-nanovg', version: lwjgl_version, classifier: c
api group: 'org.lwjgl', name: 'lwjgl-opengl', version: lwjgl_version, classifier: c
api group: 'org.lwjgl', name: 'lwjgl', version: lwjgl_version, classifier: c
api group: 'org.lwjgl', name: 'lwjgl-yoga', version: lwjgl_version, classifier: c
}
//@formatter:on
}
// PUBLISH SECTION
java {
withJavadocJar()
withSourcesJar()
modularity.inferModulePath = true
}
jar {
exclude("com/spinyowl/legui/demo/**")
manifest.attributes('Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Revision': versioning.info.commit,
'Created-By': "Gradle ${gradle.gradleVersion}",
'Build-Jdk': "${System.properties.getProperty('java.version')} (${System.properties.getProperty('java.vendor')} ${System.properties.getProperty('java.vm.version')})",
'Build-OS': "${System.properties.getProperty('os.name')} ${System.properties.getProperty('os.arch')} ${System.properties.getProperty('os.version')}",
'Full-Version': project.version)
}
def mavenLocalRepo = new File(project.buildDir.path, 'publish').toURI().toURL()
publishing {
repositories {
maven {
url mavenLocalRepo
}
}
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
// SONARQUBE CONFIGURATION
sonarqube {
properties {
property "sonar.projectKey", "SpinyOwl_legui"
property "sonar.java.source", "17"
property "sonar.organization", "spinyowl"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.branch.name", versioning.info.branch
}
}
// utility methods
private void printProjectInfo() {
println "##################################################"
println "# Project info: #"
println sprintf("# group: %-33s#", project.group)
println sprintf("# name: %-33s#", project.name)
println sprintf("# version: %-33s#", project.version)
println "##################################################"
}
class SemVer implements Serializable {
enum PatchLevel {
MAJOR, MINOR, PATCH
}
public final int major, minor, patch
static SemVer of(String version) {
def versionParts = version.split('\\.')
if (versionParts.length != 3) {
throw new IllegalArgumentException("Wrong version format - expected MAJOR.MINOR.PATCH - got ${version}")
}
return new SemVer(Integer.parseInt(versionParts[0]), Integer.parseInt(versionParts[1]), Integer.parseInt(versionParts[2]))
}
SemVer(int major, int minor, int patch) {
this.major = major
this.minor = minor
this.patch = patch
}
SemVer bump(PatchLevel patchLevel) {
switch (patchLevel) {
case PatchLevel.MAJOR: return new SemVer(major + 1, 0, 0); break
case PatchLevel.MINOR: return new SemVer(major, minor + 1, 0); break
case PatchLevel.PATCH: return new SemVer(major, minor, patch + 1); break
}
return new SemVer()
}
String toString() { return "${major}.${minor}.${patch}" }
}