|
1 | | -import java.io.IOException |
2 | | -import java.util.concurrent.TimeoutException |
3 | | - |
4 | 1 | plugins { |
5 | | - java |
6 | | - `java-library` |
7 | | - `maven-publish` |
8 | | - id("com.diffplug.spotless") version "6.1.2" |
9 | | -} |
10 | | - |
11 | | -fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex())) |
12 | | - .directory(projectDir) |
13 | | - .redirectOutput(ProcessBuilder.Redirect.PIPE) |
14 | | - .redirectError(ProcessBuilder.Redirect.PIPE) |
15 | | - .start() |
16 | | - .apply { |
17 | | - if (!waitFor(10, TimeUnit.SECONDS)) { |
18 | | - throw TimeoutException("Failed to execute command: '" + this@runCommand + "'") |
19 | | - } |
20 | | - } |
21 | | - .run { |
22 | | - val error = errorStream.bufferedReader().readText().trim() |
23 | | - if (error.isNotEmpty()) { |
24 | | - throw IOException(error) |
25 | | - } |
26 | | - inputStream.bufferedReader().readText().trim() |
27 | | - } |
28 | | - |
29 | | -val gitHash = "git rev-parse --verify HEAD".runCommand() |
30 | | -val clean = "git status --porcelain".runCommand().isEmpty() |
31 | | -val lastTag = "git describe --tags --abbrev=0".runCommand() |
32 | | -val lastVersion = lastTag.substring(1) // remove the leading 'v' |
33 | | -val commits = "git rev-list --count $lastTag..HEAD".runCommand() |
34 | | -println("Git hash: $gitHash" + if (clean) "" else " (dirty)") |
35 | | - |
36 | | -group = "de.bluecolored.bluemap" |
37 | | -version = lastVersion + |
38 | | - (if (commits == "0") "" else "-$commits") + |
39 | | - (if (clean) "" else "-dirty") |
40 | | - |
41 | | -println("Version: $version") |
42 | | - |
43 | | -val javaTarget = 16 |
44 | | -java { |
45 | | - sourceCompatibility = JavaVersion.toVersion(javaTarget) |
46 | | - targetCompatibility = JavaVersion.toVersion(javaTarget) |
47 | | - |
48 | | - withSourcesJar() |
49 | | - withJavadocJar() |
50 | | -} |
51 | | - |
52 | | -repositories { |
53 | | - mavenCentral() |
| 2 | + bluemap.base |
54 | 3 | } |
55 | 4 |
|
56 | 5 | dependencies { |
57 | | - api ("com.flowpowered:flow-math:1.0.3") |
58 | | - api ("com.google.code.gson:gson:2.8.0") |
59 | | - |
60 | | - compileOnly ("org.jetbrains:annotations:23.0.0") |
61 | | -} |
62 | | - |
63 | | -spotless { |
64 | | - java { |
65 | | - target ("src/*/java/**/*.java") |
| 6 | + api ( libs.flow.math ) |
| 7 | + api ( libs.gson ) |
66 | 8 |
|
67 | | - licenseHeaderFile("LICENSE_HEADER") |
68 | | - indentWithSpaces() |
69 | | - trimTrailingWhitespace() |
70 | | - } |
71 | | -} |
72 | | - |
73 | | -tasks.withType(JavaCompile::class).configureEach { |
74 | | - options.apply { |
75 | | - encoding = "utf-8" |
76 | | - } |
77 | | -} |
| 9 | + compileOnly ( libs.jetbrains.annotations ) |
| 10 | + compileOnly ( libs.lombok ) |
78 | 11 |
|
79 | | -tasks.withType(AbstractArchiveTask::class).configureEach { |
80 | | - isReproducibleFileOrder = true |
81 | | - isPreserveFileTimestamps = false |
82 | | -} |
83 | | - |
84 | | -tasks.javadoc { |
85 | | - options { |
86 | | - (this as? StandardJavadocDocletOptions)?.apply { |
87 | | - links( |
88 | | - "https://docs.oracle.com/en/java/javase/16/docs/api/", |
89 | | - "https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/", |
90 | | - "https://javadoc.io/doc/com.google.code.gson/gson/2.8.0/", |
91 | | - ) |
92 | | - addStringOption("Xdoclint:none", "-quiet") |
93 | | - addBooleanOption("html5", true) |
94 | | - } |
95 | | - } |
96 | | -} |
97 | | - |
98 | | -tasks.processResources { |
99 | | - from("src/main/resources") { |
100 | | - include("de/bluecolored/bluemap/api/version.json") |
101 | | - duplicatesStrategy = DuplicatesStrategy.INCLUDE |
102 | | - |
103 | | - expand ( |
104 | | - "version" to project.version, |
105 | | - "gitHash" to gitHash + if (clean) "" else " (dirty)" |
106 | | - ) |
107 | | - } |
| 12 | + annotationProcessor ( libs.lombok ) |
108 | 13 | } |
109 | 14 |
|
110 | 15 | publishing { |
111 | | - repositories { |
112 | | - maven { |
113 | | - name = "bluecolored" |
114 | | - |
115 | | - val releasesRepoUrl = "https://repo.bluecolored.de/releases" |
116 | | - val snapshotsRepoUrl = "https://repo.bluecolored.de/snapshots" |
117 | | - url = uri(if (version == lastVersion) releasesRepoUrl else snapshotsRepoUrl) |
118 | | - |
119 | | - credentials { |
120 | | - username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME") |
121 | | - password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD") |
122 | | - } |
123 | | - } |
124 | | - } |
125 | 16 | publications { |
126 | 17 | create<MavenPublication>("maven") { |
127 | 18 | groupId = project.group.toString() |
128 | | - artifactId = project.name |
| 19 | + artifactId = "bluemap-${project.name}" |
129 | 20 | version = project.version.toString() |
130 | 21 |
|
131 | 22 | from(components["java"]) |
|
0 commit comments