forked from Querz/mcaselector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
126 lines (110 loc) · 3.25 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
plugins {
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'com.eriwen.gradle.css' version '2.14.0'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'css'
group 'net.querz.mcaselector'
version '1.9.3'
sourceCompatibility = 1.8
idea {
module.downloadSources = true
}
repositories {
mavenCentral()
maven {
url 'https://jitpack.io/'
}
}
dependencies {
compile 'com.github.Querz:NBT:b56ad64dd9'
shadow 'com.github.Querz:NBT:b56ad64dd9'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
manifest {
attributes 'Main-Class': 'net.querz.mcaselector.Main', 'Application-Version': project.version
}
}
shadowJar {
manifest {
attributes 'Main-Class': 'net.querz.mcaselector.Main'
}
configurations = [project.configurations.shadow]
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
minifyCss {
source = "${sourceSets.main.resources.srcDirs[0]}/style.css"
dest = "${sourceSets.main.output.resourcesDir}/style.css"
}
task updateReadme {
doLast {
ant.replaceregexp(
match: '(?:Download Version )\\d+\\.\\d+(?:\\.\\d+)?',
replace: "Download Version ${version}",
flags: 'g',
byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(
match: '(?:download/)\\d+\\.\\d+(?:\\.\\d+)?',
replace: "download/${version}",
flags: 'g',
byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(
match: '(?:mcaselector-)\\d+\\.\\d+(?:\\.\\d+)?',
replace: "mcaselector-${version}",
flags: 'g',
byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(
match: '<!--toc-start-->[\\s\\S]*<!--toc-end-->',
replace: createTOC('README.md', '<!--toc-start-->', '<!--toc-end-->', true, true),
flags: 'g') {
fileset(dir: '.', includes: 'README.md')
}
}
}
import java.nio.file.Files
/**
* Creates a Table Of Contents from headings in a markdown file.
*
* @param f The file to be checked for headings
* @param st The prefix to the TOC
* @param en The suffix of the TOC
* @param it Whether to ignore the title
* @param is Whether to ignore the subtitle: a subtitle is a level 4 heading prefixed by ####
* @return The TOC as a string with prefix and suffix
* @throws IOException If the input file could not be read
* @throws IllegalArgumentException If the input file is not a file
*/
static String createTOC(String f, String st, String en, boolean it, boolean is) throws IOException {
File e = new File(f)
if (!e.isFile())
throw new IllegalArgumentException('file doesn\'t exist or is not a file')
StringBuilder b = new StringBuilder(st + '\n' as String)
int l, s = 0
for (String n in Files.lines(e.toPath())) {
String t
if ((t = n.trim()).startsWith('#')) {
for (l = 0; l < t.length() && t.charAt(l) == '#' as char; l++) {/**/}
s += l == 4 ? 1 : 0
if (t.length() == l || t.charAt(l) != ' ' as char || it && l == 1 || is && l == 4 && s == 1)
continue
for (int i = it ? 2 : 1; i < l; i++)
b.append(' ')
String x = t.substring(l + 1)
String k = x.toLowerCase().replaceAll('[^a-z0-9 \\-_]', '').replace(' ', '-')
b.append('* [').append(x).append('](#').append(k).append(')\n')
}
}
return b.append(en).toString()
}