-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
91 lines (76 loc) · 2.93 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
/**
* As best practice, define here all plugins with their version and `apply false` and reuse them in submodules.
* Also, each module shall import its dependencies separately.
*/
plugins {
id('org.jetbrains.kotlin.jvm') version "$kotlin_version" apply false
// Apply to all projects, used to check unused dependencies, run `./gradlew lintGradle` to check dependencies.
// Be aware that automatic fixing with `fixLintGradle` might break something.
id('nebula.lint') version "17.1.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
}
// Do not delete, this will get updated automatically when running the version command
version '0.0.1'
// Do not add dependencies here! Bad practice
allprojects {
group 'eu.miaplatform'
gradleLint.rules = ['all-dependency']
gradleLint.alwaysRun = false
}
subprojects {
apply plugin: "org.jlleitschuh.gradle.ktlint"
// setup junit5 and remove all api imports of junit 4
configurations {
implementation {
exclude group: 'junit', module: 'junit'
}
testImplementation {
exclude group: 'junit', module: 'junit'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = "17"
}
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
}
}
}
class UpdateVersion extends DefaultTask {
private String tag
@Option(option = "tag", description = "Updates the project version with specified tag (when supplying the tag do not include the initial v).")
void setTag(String tag) {
this.tag = tag
}
@Input
String getTag() {
return tag
}
@TaskAction
void print() {
getLogger().quiet("Updating files to version $tag")
String oldTag = project.version
getLogger().quiet("Updating build.gradle file, updating from version $oldTag to $tag")
String updatedBuildGradle = project.buildFile.getText().replaceFirst("version '$oldTag'", "version '$tag'")
project.buildFile.setText(updatedBuildGradle)
getLogger().quiet("Updating Changelog and Dockerfile")
runCommand("./scripts/update-changelog.sh", tag)
getLogger().quiet("Commit and tag creation on local repository")
String tagName = "v${tag}"
runCommand("git", "commit", "-a", "-m", tagName)
runCommand("git", "tag", tagName)
}
static String runCommand(String... commands) {
Process process = new ProcessBuilder(commands).redirectErrorStream(true).start()
process.waitFor()
String result = ''
process.inputStream.eachLine { result += it + '\n' }
boolean error = process.exitValue() != 0
if (error) {
println(result)
}
return result
}
}
//to execute the task: ./gradlew version --tag=[version]
task version(type: UpdateVersion)