forked from Fuzss/easymagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
116 lines (107 loc) · 4.37 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
apply from: './gradle/tasks.gradle'
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()
java.withJavadocJar()
// silence missing javadoc comments, we just don't care
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
repositories {
mavenCentral()
mavenLocal()
maven {
name = 'Sponge / Mixin'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'Jared'
url = 'https://maven.blamejared.com/'
}
maven {
name = 'Jitpack'
url = 'https://jitpack.io'
}
maven {
name = 'Shedaniel'
url = 'https://maven.shedaniel.me/'
}
maven {
name = 'Parchment'
url = 'https://maven.parchmentmc.org'
}
maven {
name = 'Curse Maven'
url = 'https://cursemaven.com'
}
maven {
name = "Fuzs Mod Resources"
url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
}
maven {
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
name = "ModMaven"
url = "https://modmaven.dev"
}
flatDir {
dirs 'libs'
}
}
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = 'UTF-8'
options.release = 17
}
tasks.withType(Jar).configureEach {
from rootProject.file("LICENSE.md")
from rootProject.file("LICENSE-ASSETS.md")
from rootProject.file("CHANGELOG.md")
manifest {
attributes([
"Specification-Title" : modName,
'Specification-Version' : modVersion,
"Specification-Vendor" : modAuthor,
'Implementation-Title' : modName,
'Implementation-Version' : modVersion,
'Implementation-Vendor' : modAuthor,
'Implementation-Timestamp' : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Implementation-Timestamp-Milli' : System.currentTimeMillis(),
'Implementation-URL' : modSourceUrl,
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : minecraftVersion
])
}
group 'jar'
}
tasks.withType(GenerateModuleMetadata) {
// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
enabled = false
}
}
import groovy.json.*
import java.util.regex.Pattern
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
task incrementBuildNumber {
onlyIf { project.hasProperty('uniqueBuildNumber') }
doLast {
def propertiesName = 'gradle.properties'
// build number is stored in global gradle.properties
def propertiesFile = new File(project.gradle.gradleUserHomeDir, propertiesName)
if (!propertiesFile.canRead()) { throw new FileNotFoundException("Could not read file ".concat(propertiesName)) }
def buildNumberMatcher = Pattern.compile("uniqueBuildNumber=(\\d+)").matcher(propertiesFile.getText())
buildNumberMatcher.find()
def versionCode = Integer.parseInt(buildNumberMatcher.group(1))
def propertiesContent = buildNumberMatcher.replaceAll("uniqueBuildNumber=" + ++versionCode)
propertiesFile.write(propertiesContent)
}
}