generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
68 lines (57 loc) · 1.79 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
import java.util.concurrent.TimeUnit
plugins {
id 'java'
id "io.freefair.lombok" version "8.0.1"
id "run.halo.plugin.devtools" version "0.0.7"
}
group 'me.chenhe.halo'
version = extractVersionFromGit()
sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/releases' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
implementation platform('run.halo.tools.platform:plugin:2.11.0-SNAPSHOT')
compileOnly 'run.halo.app:api'
testImplementation 'run.halo.app:api'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}
halo {
version = '2.11'
}
tasks.register('version') {
doLast {
println(extractVersionFromGit())
}
}
String extractVersionFromGit() {
def process = "git describe --tags --match=v[0-9]*.[0-9]*.[0-9]* --long --abbrev=7".execute()
def timeout = !process.waitFor(10, TimeUnit.SECONDS)
if (timeout || process.exitValue() != 0) {
// failed to find matched tag
logger.warn("Could not find a valid version tag through git, use default version.")
return "0.0.1-SNAPSHOT"
}
def outputs = process.text =~ /v(\d+\.\d+.\d+)-(\d+)-(\w+)/
if (!outputs) {
logger.warn("Malformed version tag , use default version.")
return "0.0.1-SNAPSHOT"
}
var sb = new StringBuilder(30)
sb.append(outputs.group(1))
if (Integer.parseInt(outputs.group(2)) != 0) {
sb.append('-')
sb.append(outputs.group(3))
sb.append('-SNAPSHOT')
}
return sb.toString()
}