-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle
More file actions
61 lines (48 loc) · 1.45 KB
/
build.gradle
File metadata and controls
61 lines (48 loc) · 1.45 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
import java.util.regex.Matcher
plugins {
id 'java'
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation files("libs/craftbukkit-1060.jar")
implementation files("libs/Essentials.jar")
implementation 'com.github.zavdav:ZCore:1.0.0-rc1'
}
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 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()) {
version = versionMatcher.group(1)
} else {
throw new GradleException("The 'version' attribute wasn't found in the 'plugin.yml' file.")
}
if (!nameMatcher.find()) {
throw new GradleException("The 'name' attribute wasn't found in the 'plugin.yml' file.")
}
tasks.named('build') {
mustRunAfter 'clean'
}
tasks.register('cleanBuild') {
dependsOn 'clean', 'build'
group = 'custom'
}
jar {
manifest {
attributes(
'Implementation-Title': "${project.name}",
'Implementation-Version': "${project.version}"
)
}
archiveFileName = "${project.name}-${project.version}.jar"
}