Skip to content

Commit c811f63

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent bac8920 commit c811f63

9 files changed

+112
-75
lines changed

.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 & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
11
plugins {
2-
id "java-library"
3-
id "idea"
2+
id "viaproxy.plugin-conventions"
43
id "net.lenni0451.repackager" version "1.0.0"
54
}
65

7-
base {
8-
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
9-
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
10-
11-
group = project.maven_group ?: rootProject.maven_group
12-
archivesName = project.maven_name ?: rootProject.maven_name
13-
version = project.maven_version ?: rootProject.maven_version
14-
}
15-
166
configurations {
17-
include
187
repackagedInclude
198

20-
include.extendsFrom repackagedInclude
21-
implementation.extendsFrom include
22-
api.extendsFrom include
9+
include.extendsFrom(repackagedInclude)
2310
}
2411

2512
repositories {
26-
mavenCentral()
27-
maven {
28-
name = "ViaVersion"
29-
url = "https://repo.viaversion.com"
30-
}
3113
maven {
3214
name = "Jitpack"
3315
url = "https://jitpack.io"
@@ -55,62 +37,10 @@ dependencies {
5537
}
5638
}
5739

58-
processResources {
59-
inputs.property "version", project.version
60-
61-
filesMatching("viaproxy.yml") {
62-
expand "version": project.version
63-
}
64-
}
65-
66-
jar {
67-
dependsOn configurations.include
68-
from {
69-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
70-
configurations.include.collect {
71-
zipTree(it)
72-
}
73-
} {
74-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
75-
}
76-
77-
from("LICENSE") {
78-
rename { "${it}_${project.name ?: rootProject.name}" }
79-
}
80-
}
81-
82-
idea {
83-
module {
84-
["run"].each {
85-
excludeDirs << file("$it")
86-
}
87-
}
88-
}
89-
9040
dependencyRepackager {
9141
configuration = configurations.repackagedInclude
9242
relocations = [
9343
"org.cloudburstmc.netty": "dev.kastle.netty"
9444
]
9545
removeEmptyDirs = true
9646
}
97-
98-
tasks.register("runViaProxy", JavaExec) {
99-
dependsOn tasks.jar
100-
101-
mainClass = "net.raphimc.viaproxy.ViaProxy"
102-
classpath = sourceSets.main.compileClasspath
103-
workingDir = file("run")
104-
jvmArgs = ["-DskipUpdateCheck"]
105-
106-
doFirst {
107-
def pluginsDir = file("$workingDir/plugins")
108-
pluginsDir.mkdirs()
109-
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
110-
}
111-
112-
doLast {
113-
file("$workingDir/plugins/${project.name}.jar").delete()
114-
file("$workingDir/logs").deleteDir()
115-
}
116-
}

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=17
55
maven_group=net.raphimc
66
maven_name=ViaProxyRakNetProviders
77
maven_version=1.0.0

0 commit comments

Comments
 (0)