-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
195 lines (178 loc) · 6.16 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
195
/*
*
* AstralFlow - Storage utilities for spigot servers.
* Copyright (C) 2022 iceBear67
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
plugins {
id 'java'
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'java-library'
id 'io.franzbecker.gradle-lombok' version '5.0.0'
id("me.him188.maven-central-publish") version "1.0.0"
}
apply plugin: "maven-publish"
group = 'io.ib67.astralflow'
version = properties.get("version")
allprojects {
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
maven {
url = "https://jitpack.io"
}
maven { url "https://repo.dmulloy2.net/repository/public/" }
}
}
mavenCentralPublish {
useCentralS01()
// If different from that from project, specify manually:
projectName = "AstralFlow"
artifactId = project.name
groupId = this.group
///this.
//projectName = "Kiwi"
// archivesBaseName("Kiwi-${this.name}-${this.version}")
// description from project.description by default
description("AstralFlow allows you to create custom block/item/machines in Spigot Servers.")
projectUrl("https://codeberg.org/InlinedLambdas/AstralFlow")
workingDir = file("/tmp/a")
connection = "scm:git:git://codeberg.org/InlinedLambdas/AstralFlow"
license("LGPLv2.1", "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html")
developer("InlinedLambdas")
}
def getCheckedOutGitCommitHash() {
def gitFolder = "$projectDir/.git/"
def takeFromHash = 7
/*
* '.git/HEAD' contains either
* in case of detached head: the currently checked out commit hash
* otherwise: a reference to a file containing the current commit hash
*/
def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd
// def isRef = head.length > 1 // ref: refs/heads/master
if (isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb
def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master
refHead.text.trim().take takeFromHash
}
def buildDate = new Date().toGMTString()
def buildBy = System.getProperty("user.name")
def commitHash = getCheckedOutGitCommitHash()
dependencies {
compileOnly 'io.netty:netty-all:4.1.75.Final'
implementation 'io.ib67.kiwi:core:0.3.0'
compileOnly 'org.jetbrains:annotations:24.0.0'
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit:3.0.0'
}
dependencies {
testRuntimeOnly 'io.netty:netty-all:4.1.68.Final'
testCompileOnly 'org.jetbrains:annotations:24.0.0'
testImplementation 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.18:1.26.1'
compileOnly 'org.spongepowered:configurate-hocon:4.1.2'
testRuntimeOnly 'org.spongepowered:configurate-hocon:4.1.2' // mockbukkit doesn't support loadlibraries yet.
}
lombok {
version = "1.18.24"
}
import io.franzbecker.gradle.lombok.task.DelombokTask
task delombok(type: DelombokTask, dependsOn: compileJava) {
ext.outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
sourceSets.main.java.srcDirs.each {
inputs.dir(it)
args(it, "-d", outputDir)
}
doFirst {
outputDir.deleteDir()
}
}
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
javadoc {
title("${project.name} JavaDoc v${project.version}")
exclude Set.of('**/internal/**', '**/impl/**', '**Impl', 'Simple**', '**/test-plugin/**')
dependsOn delombok
source = delombok.outputDir
failOnError = false
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
test {
useJUnitPlatform()
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [
version : version,
buildTime : buildDate,
buildBy : (buildBy.equals("runner") || buildBy.equals("icybear")) ? buildBy : "Unknown / $buildBy",
commitHash: commitHash
]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('*') {
expand props
}
}
sourceSets {
main {
//compileClasspath += sourceSets.storageModule.output
//runtimeClasspath += sourceSets.storageModule.output
}
}
shadowJar {
relocate 'io.ib67.kiwi', 'io.ib67.astralflow.relocate.kiwi'
relocate 'org.bstats', 'io.ib67.astralflow.relocate.bstats'
}
/*
* I18N
*/
task generateI18NBundle(type: Zip, dependsOn: processResources) {
from 'translations'
archiveName 'locale.zip'
destinationDir file('build/resources/i18n/')
}
jar.dependsOn generateI18NBundle
shadowJar.dependsOn generateI18NBundle
jar {
from("build/resources/i18n")
}
shadowJar {
from("build/resources/i18n")
}