-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
55 lines (43 loc) · 1.27 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
import java.util.regex.Matcher
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation files("libs/craftbukkit-1060.jar")
}
File ymlFile = file('src/main/resources/plugin.yml') as File
if (!ymlFile.exists()) {
throw new GradleException("The 'plugin.yml' file does not exist in 'src/main/resources'!")
}
String pluginVersion
String pluginName
String ymlText = ymlFile.text
Matcher mainMatcher = (ymlText =~ /main:\s*(\S+)/)
Matcher versionMatcher = (ymlText =~ /version:\s*(\S+)/)
Matcher nameMatcher = (ymlText =~ /name:\s*(\S+)/)
if (!mainMatcher.find()) {
throw new GradleException("The 'main' attribute wasn't found in the 'plugin.yml' file!")
}
if (versionMatcher.find()) {
pluginVersion = versionMatcher.group(1)
} else {
throw new GradleException("The 'version' attribute wasn't found in the 'plugin.yml' file!")
}
if (nameMatcher.find()) {
pluginName = nameMatcher.group(1)
} else {
throw new GradleException("The 'name' attribute wasn't found in the 'plugin.yml' file!")
}
jar {
manifest {
attributes(
'Implementation-Title': pluginName,
'Implementation-Version': pluginVersion
)
}
archiveVersion.set(pluginVersion)
archiveBaseName.set(pluginName)
}