Skip to content

Commit d827e7b

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent e2385a0 commit d827e7b

12 files changed

+132
-92
lines changed

.gitignore

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

Agent/build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
plugins {
2-
id("net.lenni0451.repackager") version "1.0.0"
3-
}
4-
5-
base {
6-
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
2+
id "java"
3+
id "base.base-conventions"
4+
id "base.application-conventions"
5+
id "net.lenni0451.repackager" version "1.0.0"
76
}
87

98
dependencies {
@@ -14,7 +13,6 @@ dependencies {
1413
jar {
1514
manifest {
1615
attributes(
17-
"Multi-Release": "true",
1816
"Premain-Class": "net.lenni0451.authhook.Agent",
1917
"PreMain-Class": "net.lenni0451.authhook.Agent",
2018
"Can-Redefine-Classes": "true",

Agent/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
java_version=8
12
maven_name=ViaProxyAuthHook-Agent

build.gradle

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,7 @@
1-
allprojects {
2-
apply plugin: "java"
3-
4-
base {
5-
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
6-
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
7-
8-
group = project.maven_group ?: rootProject.maven_group
9-
archivesName = project.maven_name ?: rootProject.maven_name
10-
version = project.maven_version ?: rootProject.maven_version
11-
}
12-
13-
repositories {
14-
mavenCentral()
15-
}
16-
17-
configurations {
18-
include
19-
20-
implementation.extendsFrom include
21-
api.extendsFrom include
22-
}
23-
24-
jar {
25-
dependsOn configurations.include
26-
from {
27-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
28-
configurations.include.collect {
29-
zipTree(it)
30-
}
31-
} {
32-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
33-
}
34-
35-
from("LICENSE") {
36-
rename { "${it}_${project.name ?: rootProject.name}" }
37-
}
38-
}
39-
}
40-
41-
apply plugin: "idea"
42-
43-
repositories {
44-
maven {
45-
name = "ViaVersion"
46-
url = "https://repo.viaversion.com"
47-
}
1+
plugins {
2+
id "viaproxy.plugin-conventions"
483
}
494

505
dependencies {
516
implementation "net.raphimc:ViaProxy:3.4.2-SNAPSHOT"
527
}
53-
54-
processResources {
55-
inputs.property "version", project.version
56-
57-
filesMatching("viaproxy.yml") {
58-
expand "version": project.version
59-
}
60-
}
61-
62-
idea {
63-
module {
64-
["run"].each {
65-
excludeDirs << file("$it")
66-
}
67-
}
68-
}
69-
70-
tasks.register("runViaProxy", JavaExec) {
71-
dependsOn tasks.jar
72-
73-
mainClass = "net.raphimc.viaproxy.ViaProxy"
74-
classpath = sourceSets.main.compileClasspath
75-
workingDir = file("run")
76-
jvmArgs = ["-DskipUpdateCheck"]
77-
78-
doFirst {
79-
def pluginsDir = file("$workingDir/plugins")
80-
pluginsDir.mkdirs()
81-
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
82-
}
83-
84-
doLast {
85-
file("$workingDir/plugins/${project.name}.jar").delete()
86-
file("$workingDir/logs").deleteDir()
87-
}
88-
}

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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
id "application"
3+
id "base.include-configuration"
4+
id "base.exclude-run-folder"
5+
}
6+
7+
jar {
8+
manifest {
9+
attributes(
10+
"Main-Class": application.mainClass,
11+
"Multi-Release": "true",
12+
"Enable-Native-Access": "ALL-UNNAMED"
13+
)
14+
}
15+
}
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+
}

0 commit comments

Comments
 (0)