This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
build.gradle
176 lines (144 loc) · 3.88 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.114'
}
}
plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'signing'
id "org.cadixdev.licenser" version "0.5.0"
id "fabric-loom" version "0.6-SNAPSHOT"
id "com.matthewprenger.cursegradle" version "1.4.0"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = "4.7.3"
group = 'RebornCore'
def ENV = System.getenv()
def build_number = ENV.BUILD_NUMBER ?: "local"
version = "${version}+build.$build_number"
license {
header file('HEADER')
include '**/*.java'
ignoreFailures = true //Stops the build from failing if a file does not have a license header
}
dependencies {
minecraft "com.mojang:minecraft:1.16.5"
mappings "net.fabricmc:yarn:1.16.5+build.4:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.1"
//Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.30.0+1.16"
modApi 'teamreborn:energy:0.1.1'
include 'teamreborn:energy:0.1.1'
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = 8
}
}
java {
withSourcesJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
repositories {
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
}
}
if (ENV.SIGNING_KEY) {
signing {
useInMemoryPgpKeys(ENV.SIGNING_KEY, ENV.SIGNING_PASSWORD)
sign publishing.publications.mavenJava
sign remapJar
}
task signAll(dependsOn: [signMavenJavaPublication, signRemapJar, remapJar])
}
curseforge {
if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}
project {
id = "237903"
changelog = "A changelog can be found at https://github.com/TechReborn/RebornCore"
releaseType = ENV.RELEASE_CHANNEL ?: "release"
addGameVersion "1.16.5"
addGameVersion "Fabric"
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
afterEvaluate {
uploadTask.dependsOn("remapJar")
}
}
options {
forgeGradleIntegration = false
}
}
def getBranch() {
def ENV = System.getenv()
if (ENV.GITHUB_REF) {
def branch = ENV.GITHUB_REF
return branch.substring(branch.lastIndexOf("/") + 1)
}
return "unknown"
}
import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub
task github(dependsOn: remapJar) {
onlyIf {
ENV.GITHUB_TOKEN
}
doLast {
def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String)
def repository = github.getRepository(ENV.GITHUB_REPOSITORY)
def releaseBuilder = new GHReleaseBuilder(repository, version as String)
releaseBuilder.name("${archivesBaseName}-${version}")
releaseBuilder.body("A changelog can be found at https://github.com/TechReborn/RebornCore")
releaseBuilder.commitish(getBranch())
def ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
}
}
// A task to ensure that the version being released has not already been released.
task checkVersion {
doFirst {
def xml = new URL("http://maven.modmuss50.me/RebornCore/RebornCore-1.16/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
}
}
if (ENV.SIGNING_KEY) {
publish.dependsOn signAll
}
github.mustRunAfter checkVersion
publish.mustRunAfter checkVersion
project.tasks.curseforge.mustRunAfter checkVersion