Skip to content

Commit fd4915f

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent 3eb0185 commit fd4915f

9 files changed

+111
-78
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 & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,12 @@
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
2+
id "viaproxy.plugin-conventions"
203
}
214

225
repositories {
23-
mavenCentral()
246
maven {
257
name = "Sonatype Snapshots"
268
url = "https://oss.sonatype.org/content/repositories/snapshots"
279
}
28-
maven {
29-
name = "ViaVersion"
30-
url = "https://repo.viaversion.com"
31-
}
3210
maven {
3311
name = "lucko"
3412
url = "https://repo.lucko.me"
@@ -40,55 +18,3 @@ dependencies {
4018

4119
include "me.lucko:spark-common:1.10.134-SNAPSHOT"
4220
}
43-
44-
processResources {
45-
inputs.property "version", project.version
46-
47-
filesMatching("viaproxy.yml") {
48-
expand "version": project.version
49-
}
50-
}
51-
52-
jar {
53-
dependsOn configurations.include
54-
from {
55-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
56-
configurations.include.collect {
57-
zipTree(it)
58-
}
59-
} {
60-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
61-
}
62-
63-
from("LICENSE") {
64-
rename { "${it}_${project.name ?: rootProject.name}" }
65-
}
66-
}
67-
68-
idea {
69-
module {
70-
["run"].each {
71-
excludeDirs << file("$it")
72-
}
73-
}
74-
}
75-
76-
tasks.register("runViaProxy", JavaExec) {
77-
dependsOn tasks.jar
78-
79-
mainClass = "net.raphimc.viaproxy.ViaProxy"
80-
classpath = sourceSets.main.compileClasspath
81-
workingDir = file("run")
82-
jvmArgs = ["-DskipUpdateCheck"]
83-
84-
doFirst {
85-
def pluginsDir = file("$workingDir/plugins")
86-
pluginsDir.mkdirs()
87-
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
88-
}
89-
90-
doLast {
91-
file("$workingDir/plugins/${project.name}.jar").delete()
92-
file("$workingDir/logs").deleteDir()
93-
}
94-
}

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=ViaProxySpark
77
maven_version=1.0.1-SNAPSHOT

0 commit comments

Comments
 (0)