Skip to content

Commit 09a727f

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent 3e2ca90 commit 09a727f

11 files changed

Lines changed: 114 additions & 86 deletions

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ hs_err_pid*
1212
/.idea/*
1313
!/.idea/copyright/
1414
/.gradle/
15-
/build/
16-
/out/
15+
/buildSrc/.gradle/
16+
build/
17+
out/
1718
/run/

build.gradle

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,8 @@
11
plugins {
2-
id "java-library"
3-
id "idea"
4-
}
5-
6-
base {
7-
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
8-
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
9-
10-
group = project.maven_group ?: rootProject.maven_group
11-
archivesName = project.maven_name ?: rootProject.maven_name
12-
version = project.maven_version ?: rootProject.maven_version
13-
}
14-
15-
configurations {
16-
include
17-
18-
implementation.extendsFrom include
19-
api.extendsFrom include
2+
id "viaproxy.plugin-conventions"
203
}
214

225
repositories {
23-
mavenCentral()
24-
maven {
25-
name = "ViaVersion"
26-
url = "https://repo.viaversion.com"
27-
}
28-
maven {
29-
name = "Lenni0451"
30-
url = "https://maven.lenni0451.net/everything"
31-
}
326
maven {
337
name = "DirtPowered Releases"
348
url = "https://repo.mzga.dev/releases"
@@ -48,59 +22,7 @@ repositories {
4822
}
4923

5024
dependencies {
51-
implementation "net.raphimc:ViaProxy:3.3.7"
25+
implementation "net.raphimc:ViaProxy:3.4.1"
5226

5327
include "dev.mzga:Beta2Release:1.0.6-SNAPSHOT"
5428
}
55-
56-
processResources {
57-
inputs.property "version", project.version
58-
59-
filesMatching("viaproxy.yml") {
60-
expand "version": project.version
61-
}
62-
}
63-
64-
jar {
65-
dependsOn configurations.include
66-
from {
67-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
68-
configurations.include.collect {
69-
zipTree(it)
70-
}
71-
} {
72-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA", "io/netty/", "org/apache/logging/"
73-
}
74-
75-
from("LICENSE") {
76-
rename { "${it}_${project.name ?: rootProject.name}" }
77-
}
78-
}
79-
80-
idea {
81-
module {
82-
["run"].each {
83-
excludeDirs << file("$it")
84-
}
85-
}
86-
}
87-
88-
tasks.register("runViaProxy", JavaExec) {
89-
dependsOn tasks.jar
90-
91-
mainClass = "net.raphimc.viaproxy.ViaProxy"
92-
classpath = sourceSets.main.compileClasspath
93-
workingDir = file("run")
94-
jvmArgs = ["-DskipUpdateCheck"]
95-
96-
doFirst {
97-
def pluginsDir = file("$workingDir/plugins")
98-
pluginsDir.mkdirs()
99-
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
100-
}
101-
102-
doLast {
103-
file("$workingDir/plugins/${project.name}.jar").delete()
104-
file("$workingDir/logs").deleteDir()
105-
}
106-
}

buildSrc/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id "groovy-gradle-plugin"
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
base {
2+
java.toolchain.languageVersion = JavaLanguageVersion.of(project.java_version)
3+
4+
group = project.maven_group
5+
archivesName = project.maven_name
6+
version = project.maven_version
7+
}
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
jar {
14+
var projectName = project.name
15+
from("LICENSE") {
16+
rename { "${it}_${projectName}" }
17+
}
18+
}
19+
20+
tasks.withType(JavaCompile).configureEach {
21+
it.options.encoding = "UTF-8"
22+
}
23+
24+
tasks.withType(Javadoc).configureEach {
25+
it.options.encoding = "UTF-8"
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
id "idea"
3+
}
4+
5+
idea {
6+
module {
7+
["run"].each {
8+
excludeDirs << file("$it")
9+
}
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
configurations {
2+
include
3+
4+
implementation.extendsFrom(include)
5+
api.extendsFrom(include)
6+
}
7+
8+
jar {
9+
dependsOn(configurations.include)
10+
from {
11+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
12+
configurations.include.collect {
13+
zipTree(it)
14+
}
15+
} {
16+
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
17+
}
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
id "java-library"
3+
id "base.base-conventions"
4+
id "base.include-configuration"
5+
id "viaproxy.run-with-viaproxy-task"
6+
}
7+
8+
repositories {
9+
maven {
10+
name = "ViaVersion"
11+
url = "https://repo.viaversion.com"
12+
}
13+
}
14+
15+
processResources {
16+
inputs.property("version", project.version)
17+
18+
filesMatching("viaproxy.yml") {
19+
expand("version": project.version)
20+
}
21+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
plugins {
2+
id "base.exclude-run-folder"
3+
}
4+
5+
tasks.register("runViaProxy", JavaExec) {
6+
dependsOn(tasks.jar)
7+
8+
mainClass = "net.raphimc.viaproxy.ViaProxy"
9+
classpath = sourceSets.main.compileClasspath
10+
workingDir = file("run")
11+
jvmArgs = ["-DskipUpdateCheck"]
12+
13+
doFirst {
14+
def pluginsDir = file("$workingDir/plugins")
15+
pluginsDir.mkdirs()
16+
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
17+
}
18+
19+
doLast {
20+
file("$workingDir/plugins/${project.name}.jar").delete()
21+
file("$workingDir/logs").deleteDir()
22+
}
23+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
org.gradle.daemon=true
22
org.gradle.parallel=true
3-
org.gradle.configureondemand=true
43

4+
java_version=21
55
maven_group=net.raphimc
66
maven_name=ViaProxyBeta2Release
77
maven_version=1.0.0

src/main/java/net/raphimc/b2rplugin/Beta2ReleasePlugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import com.github.dirtpowered.betatorelease.network.session.BetaPlayer;
2121
import com.mojang.authlib.GameProfile;
22-
import com.mojang.util.UUIDTypeAdapter;
2322
import io.netty.buffer.ByteBuf;
2423
import io.netty.channel.ChannelHandlerContext;
2524
import io.netty.channel.SimpleChannelInboundHandler;
@@ -101,7 +100,7 @@ private void onShouldVerifyOnlineModeEvent(final ShouldVerifyOnlineModeEvent eve
101100

102101
final BetaPlayer player = this.b2rPlayers.stream().filter(p -> p.getSession().getPlayerName().equals(username)).findFirst().orElse(null);
103102
if (player != null && player.getUuid() != null) {
104-
event.getProxyConnection().setGameProfile(new GameProfile(UUIDTypeAdapter.fromString(player.getUuid()), username));
103+
event.getProxyConnection().setGameProfile(new GameProfile(player.getUuid(), username));
105104
event.setCancelled(true);
106105
}
107106
}

0 commit comments

Comments
 (0)