generated from OroArmor/oro-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
194 lines (163 loc) · 5.13 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.kohsuke:github-api:1.114"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
}
}
plugins {
id 'java-library'
id 'org.cadixdev.licenser' version '0.5.0'
id 'signing'
id 'maven-publish'
}
apply plugin: 'io.codearte.nexus-staging'
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
archivesBaseName = project.archives_base_name
version = project.version
group = project.maven_group
repositories {
mavenCentral()
maven {
url "https://libraries.minecraft.net"
}
}
ext.changelog = ""
license {
header = rootProject.file("LICENSE")
}
dependencies {
api "com.google.code.gson:gson:2.8.7"
api "com.mojang:brigadier:1.0.17"
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standard-out", "standard-error"
}
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
java {
withSourcesJar()
}
javadoc {
options {
links("https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.7",
"https://docs.oracle.com/en/java/javase/16/docs/api/")
}
failOnError false
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
pom {
name = 'Json to Brigadier'
packaging = 'jar'
description = 'This is a library that converts JSON to brigadier arguments.'
url = 'https://github.com/OroArmor/json-to-brigadier'
scm {
connection = 'scm:git:git://github.com/OroArmor/json-to-brigadier.git'
developerConnection = 'scm:git:ssh://github.com:OroArmor/json-to-brigadier.git'
url = 'https://github.com/OroArmor/json-to-brigadier'
}
licenses {
license {
name = 'MIT'
url = 'https://mit-license.org/'
}
}
developers {
developer {
id = 'OroArmor'
name = 'Eli Orona'
email = 'eliorona@live.com'
url = "oroarmor.com"
}
}
}
}
}
repositories {
def ossrhUsername = "OroArmor"
def ossrhPassword = (project.hasProperty("ossrhPassword") ? project.property("ossrhPassword") : System.getenv("OSSRH_PASSWORD")) as String
mavenLocal()
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials(PasswordCredentials) {
username = ossrhUsername
password = ossrhPassword
}
name = "mavenCentral"
}
}
}
tasks.withType(Sign) {
onlyIf { project.hasProperty("sign") }
}
if (project.hasProperty("sign")) {
signing {
useGpgCmd()
sign publishing.publications.getByName("mavenJava")
}
}
nexusStaging {
username = "OroArmor"
password = project.hasProperty("ossrhPassword") ? project.property("ossrhPassword") : System.getenv("OSSRH_PASSWORD")
}
import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub
task github {
onlyIf {
System.getenv().GITHUB_TOKEN
}
doLast {
def github = GitHub.connectUsingOAuth(System.getenv().GITHUB_TOKEN as String)
def repository = github.getRepository("OroArmor/json-to-brigadier")
def releaseBuilder = new GHReleaseBuilder(repository, project.version)
releaseBuilder.name("$project.project_name $project.version")
releaseBuilder.body(project.ext.changelog)
releaseBuilder.commitish("master")
def ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(file("${project.rootDir}/build/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
}
}
task generateChangelog {
def changelogFile = file("CHANGELOG.md")
def contents = ""
changelogFile.withReader { reader ->
def line
while ((line = reader.readLine()) != null)
contents += line + "\n"
}
def changelogs = contents.split("----")
project.ext.changelog = changelogs.find { log -> log.contains(project.version) }
println project.ext.changelog
}