-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.gradle
More file actions
151 lines (124 loc) · 4.54 KB
/
build.gradle
File metadata and controls
151 lines (124 loc) · 4.54 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
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
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'
}
configurations {
compileOnly_v1_17 {
extendsFrom compileOnly
canBeResolved = true
}
compileOnly_v1_21 {
extendsFrom compileOnly
canBeResolved = true
}
compileOnly_v1_21_4 {
extendsFrom compileOnly
canBeResolved = true
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
maven { url = 'https://maven.elmakers.com/repository/' }
maven { url = 'https://repo.codemc.io/repository/nms/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
maven { url = 'https://repo.screamingsandals.org/public' }
}
jar {
enabled = false
}
sourceSets {
v1_17 {
java { srcDirs = ['src/v1_17/java'] }
compileClasspath += sourceSets.main.output
compileClasspath += configurations.compileOnly_v1_17
}
v1_21 {
java { srcDirs = ['src/v1_21/java'] }
compileClasspath += sourceSets.main.output
compileClasspath += configurations.compileOnly_v1_21
}
v1_21_4 {
java { srcDirs = ['src/v1_21_4/java'] }
compileClasspath += sourceSets.main.output
compileClasspath += configurations.compileOnly_v1_21_4
}
}
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.21.1-R0.1-SNAPSHOT'
compileOnly_v1_17('org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:remapped-mojang') { transitive = false }
compileOnly_v1_21('org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:remapped-mojang') { transitive = false }
compileOnly_v1_21_4('org.spigotmc:spigot:1.21.4-R0.1-SNAPSHOT:remapped-mojang') { transitive = false }
}
shadowJar {
archiveBaseName.set('playit-minecraft-plugin')
archiveClassifier.set('')
archiveVersion.set(project.version as String)
from sourceSets.v1_17.output
from sourceSets.v1_21.output
from sourceSets.v1_21_4.output
exclude('META-INF/LICENSE')
exclude('META-INF/LICENSE*')
exclude('META-INF/NOTICE')
exclude('META-INF/NOTICE*')
}
tasks.named('compileV1_17Java') { dependsOn compileJava }
tasks.named('compileV1_21Java') { dependsOn compileJava }
tasks.named('compileV1_21_4Java') { dependsOn compileJava }
shadowJar.dependsOn compileV1_17Java, compileV1_21Java, compileV1_21_4Java
build.dependsOn shadowJar