-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
158 lines (128 loc) · 4.78 KB
/
build.gradle
File metadata and controls
158 lines (128 loc) · 4.78 KB
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
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
buildscript {
//-------VERSIONING-------
def versionPropsFile = file('version.properties')
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def version_active = versionProps['version.active'].toBoolean()
def isSnapshot = versionProps['version.snapshot'].toBoolean()
def version_specified= versionProps['version.specified'].toString()
def version_major = versionProps['version.major'].toInteger()
def version_minor = versionProps['version.minor'].toInteger()
def version_patch = versionProps['version.patch'].toInteger()
def version_build = versionProps['version.build'].toInteger()
if (isSnapshot) {
if(version_active){
version_build += 1
}
version = "${version_major}.${version_minor}.${version_patch}${version_specified}-snapshot#${version_build}"
System.out.println("VERSIONING-SNAPSHOT")
} else {
version = "${version_major}.${version_minor}.${version_patch}${version_specified}"
System.out.println("VERSIONING-RELEASE")
}
project.version = version
//-------VERSIONING END-------
}
plugins{
id 'java'
id 'java-library'
id "com.github.johnrengelman.shadow" version "7.1.0"
id 'maven-publish'
}
archivesBaseName = project_name
group = project_group
//------VERSION UPDATE IN FILE------
task updateVersion{
def versionPropsFile = file('version.properties')
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def version_active = versionProps['version.active'].toBoolean()
def isSnapshot = versionProps['version.snapshot'].toBoolean()
def version_build = isSnapshot?
project.version.toString().split("#")[1] : 0
if(version_active){
def propsFilePath = file('version.properties').absolutePath
def lines = Files.readAllLines(Paths.get(propsFilePath))
def updatedLines = []
lines.each { line ->
if (line.startsWith("version.build=")) {
line = "version.build=$version_build"
} else if (line.startsWith("version.snapshot=")) {
line = "version.snapshot=true"
}
updatedLines.add(line)
}
Files.write(Paths.get(propsFilePath), updatedLines, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)
System.out.println("UPDATING BUILD VERSION")
}
}
shadowJar.dependsOn(updateVersion)
//------VERSION UPDATE FINISH------
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
}
allprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://redempt.dev' }
maven { url = 'https://jitpack.io' }
}
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core:5.5.0'
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testCompileOnly 'org.jetbrains:annotations:23.0.0'
//annotations
compileOnly("org.projectlombok:lombok:1.18.30")
compileOnly("org.jetbrains:annotations:23.0.0")
annotationProcessor("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.jetbrains:annotations:23.0.0")
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
}
//TESTS. Go through all config types
test {
useJUnitPlatform()
systemProperty 'test.configType', 'JSON'
}
tasks.register('testYaml', Test) {
useJUnitPlatform()
description = "Runs the full test suite with CONFIG_TYPE=YAML"
group = 'verification'
testClassesDirs = test.testClassesDirs
classpath = test.classpath
// flip to YAML
systemProperty 'test.configType', 'YAML'
// carry over any logging / JVM settings
testLogging.events = test.testLogging.events
testLogging.exceptionFormat = test.testLogging.exceptionFormat
}
check.dependsOn testYaml
java{
withSourcesJar()
}
build{
dependsOn(shadowJar)
}
shadowJar{
archiveClassifier.set('')
}
compileJava{
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
dependsOn(clean)
}
}
dependencies {
implementation(project('atumconfig-api'))
implementation(project('atumconfig-core'))
}