Skip to content

Commit ff6f4ec

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent 667d74f commit ff6f4ec

9 files changed

+111
-81
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: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,7 @@
11
plugins {
2-
id "java-library"
3-
id "idea"
4-
}
5-
6-
base {
7-
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
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
20-
}
21-
22-
repositories {
23-
mavenCentral()
24-
maven {
25-
name = "ViaVersion"
26-
url = "https://repo.viaversion.com"
27-
}
2+
id "viaproxy.plugin-conventions"
283
}
294

305
dependencies {
316
implementation "net.raphimc:ViaProxy:3.4.1"
327
}
33-
34-
processResources {
35-
inputs.property "version", project.version
36-
37-
filesMatching("viaproxy.yml") {
38-
expand "version": project.version
39-
}
40-
}
41-
42-
jar {
43-
dependsOn configurations.include
44-
from {
45-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
46-
configurations.include.collect {
47-
zipTree(it)
48-
}
49-
} {
50-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
51-
}
52-
53-
from("LICENSE") {
54-
rename { "${it}_${project.name ?: rootProject.name}" }
55-
}
56-
}
57-
58-
idea {
59-
module {
60-
["run"].each {
61-
excludeDirs << file("$it")
62-
}
63-
}
64-
}
65-
66-
tasks.register("runViaProxy", JavaExec) {
67-
dependsOn tasks.jar
68-
69-
mainClass = "net.raphimc.viaproxy.ViaProxy"
70-
classpath = sourceSets.main.compileClasspath
71-
workingDir = file("run")
72-
jvmArgs = ["-DskipUpdateCheck"]
73-
74-
doFirst {
75-
def pluginsDir = file("$workingDir/plugins")
76-
pluginsDir.mkdirs()
77-
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
78-
}
79-
80-
doLast {
81-
file("$workingDir/plugins/${project.name}.jar").delete()
82-
file("$workingDir/logs").deleteDir()
83-
}
84-
}

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=ViaProxyOpenAuthMod
77
maven_version=1.0.3-SNAPSHOT

0 commit comments

Comments
 (0)