Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
99 lines (77 loc) · 2.8 KB
/
Copy pathbuild.gradle
File metadata and controls
99 lines (77 loc) · 2.8 KB
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
plugins {
id 'java'
id 'application'
id 'com.gradleup.shadow' version '9.0.0'
}
group = 'gg.playit.gg'
version = '0.2.0'
def playitConstantsFile = file("src/main/java/gg/playit/minecraft/PlayitConstants.java")
tasks.register('generatePlayitConstants') {
def versionStr = project.version.toString()
def baseVersion = versionStr.split('-')[0]
def parts = baseVersion.split('\\.')
def major = parts.length > 0 ? (parts[0].replaceAll('[^0-9]', '') ?: '0') : '0'
def minor = parts.length > 1 ? (parts[1].replaceAll('[^0-9]', '') ?: '0') : '0'
def patch = parts.length > 2 ? (parts[2].replaceAll('[^0-9].*', '') ?: '0') : '0'
outputs.file(playitConstantsFile)
doLast {
playitConstantsFile.text = """package gg.playit.minecraft;
import gg.playit.api.model.request.AgentVersion;
/** Generated by build - version is injected from build.gradle. */
public final class PlayitConstants {
private PlayitConstants() {}
public static final AgentVersion MINECRAFT_AGENT_VERSION =
new AgentVersion("f4e73f52-f35c-4f18-9ab2-3aaa5c4488c1", ${major}, ${minor}, ${patch});
/** Version string for ReqClaimSetup (e.g. "0.2.0") */
public static final String VERSION_STRING = "${versionStr}";
}
"""
}
}
compileJava.dependsOn generatePlayitConstants
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
processResources {
expand(version: project.version)
}
application {
mainClass = 'gg.playit.api.example.ApiExample'
}
tasks.register('runApiExample', JavaExec) {
group = 'application'
description = 'Run the API example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'gg.playit.api.example.ApiExample'
}
tasks.register('runControlExample', JavaExec) {
group = 'application'
description = 'Run the control channel example'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'gg.playit.control.example.ControlExample'
}
repositories {
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
}
jar {
enabled = false
}
dependencies {
implementation 'jakarta.validation:jakarta.validation-api:3.0.2'
implementation 'commons-io:commons-io:2.11.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0-rc1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0-rc1'
compileOnly 'io.netty:netty-all:4.1.82.Final'
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
}
shadowJar {
archiveBaseName.set('playit-minecraft-plugin')
archiveClassifier.set('')
archiveVersion.set(project.version as String)
exclude('META-INF/LICENSE*')
exclude('META-INF/NOTICE*')
}
build.dependsOn shadowJar