Skip to content

Commit 1750350

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent d3fc38e commit 1750350

13 files changed

+179
-109
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: 6 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
11
plugins {
22
id "java"
3-
id "application"
4-
id "maven-publish"
5-
id "idea"
3+
id "base.base-conventions"
4+
id "base.application-conventions"
5+
id "base.fill-build-constants"
6+
id "viaproxy.publishing-conventions"
67
id "net.raphimc.class-token-replacer" version "1.1.4"
78
id "xyz.wagyourtail.jvmdowngrader" version "1.2.2"
89
}
910

10-
base {
11-
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
12-
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
13-
14-
group = project.maven_group ?: rootProject.maven_group
15-
archivesName = project.maven_name ?: rootProject.maven_name
16-
version = project.maven_version ?: rootProject.maven_version
17-
}
18-
1911
configurations {
20-
include
2112
includeJ8
22-
23-
implementation.extendsFrom include
24-
api.extendsFrom include
2513
}
2614

2715
repositories {
28-
mavenCentral()
2916
maven {
3017
name = "ViaVersion"
3118
url = "https://repo.viaversion.com"
@@ -113,102 +100,20 @@ dependencies {
113100
includeJ8 "xyz.wagyourtail.jvmdowngrader:jvmdowngrader-java-api:1.2.2:downgraded-8"
114101
}
115102

116-
sourceSets {
117-
main {
118-
classTokenReplacer {
119-
property("\${version}", project.version)
120-
property("\${impl_version}", "git-${project.name}-${project.version}:${project.latestCommitHash().get()}")
121-
}
122-
}
123-
}
124-
125-
java {
126-
withSourcesJar()
127-
}
128-
129103
application {
130104
mainClass = "net.raphimc.viaproxy.ViaProxy"
131105
}
132106

133107
jar {
134-
dependsOn configurations.include
135-
from {
136-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
137-
configurations.include.collect {
138-
zipTree(it)
139-
}
140-
} {
141-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
142-
}
143-
144108
manifest {
145109
attributes(
146-
"Main-Class": application.mainClass,
147-
"Multi-Release": "true",
148110
"Launcher-Agent-Class": application.mainClass
149111
)
150112
}
151-
152-
from("LICENSE") {
153-
rename { "${it}_${project.name ?: rootProject.name}" }
154-
}
155-
}
156-
157-
publishing {
158-
repositories {
159-
maven {
160-
name = "Via"
161-
url = "https://repo.viaversion.com/"
162-
163-
credentials(PasswordCredentials)
164-
authentication {
165-
basic(BasicAuthentication)
166-
}
167-
}
168-
}
169-
publications {
170-
maven(MavenPublication) {
171-
groupId = project.maven_group
172-
artifactId = project.maven_name
173-
version = project.maven_version
174-
175-
from components.java
176-
177-
pom {
178-
name = "ViaProxy"
179-
description = "Standalone proxy which allows players to join EVERY Minecraft server version (Classic, Alpha, Beta, Release, Bedrock)"
180-
url = "https://github.com/ViaVersion/ViaProxy"
181-
licenses {
182-
license {
183-
name = "GPL-3.0 License"
184-
url = "https://github.com/ViaVersion/ViaProxy/blob/main/LICENSE"
185-
}
186-
}
187-
developers {
188-
developer {
189-
id = "RK_01"
190-
}
191-
}
192-
scm {
193-
connection = "scm:git:git://github.com/ViaVersion/ViaProxy.git"
194-
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaProxy.git"
195-
url = "https://github.com/ViaVersion/ViaProxy.git"
196-
}
197-
}
198-
}
199-
}
200-
}
201-
202-
idea {
203-
module {
204-
["run"].each {
205-
excludeDirs << file("$it")
206-
}
207-
}
208113
}
209114

210115
downgradeJar {
211-
dependsOn configurations.includeJ8
116+
dependsOn(configurations.includeJ8)
212117
from {
213118
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
214119
configurations.includeJ8.collect {
@@ -225,8 +130,4 @@ downgradeJar {
225130
}
226131
build.finalizedBy("downgradeJar")
227132

228-
Provider<String> latestCommitHash() {
229-
return providers.exec {
230-
commandLine = ["git", "rev-parse", "--short", "HEAD"]
231-
}.standardOutput.getAsText().map(String::trim)
232-
}
133+
tasks.javadoc.enabled = false

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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id "net.raphimc.class-token-replacer"
3+
}
4+
5+
sourceSets.configureEach {
6+
it.classTokenReplacer {
7+
property("\${version}", project.version)
8+
property("\${commit_hash}", latestCommitHash().get())
9+
}
10+
}
11+
12+
Provider<String> latestCommitHash() {
13+
return providers.exec {
14+
commandLine = ["git", "rev-parse", "--short", "HEAD"]
15+
}.standardOutput.getAsText().map(String::trim)
16+
}
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
plugins {
2+
id "maven-publish"
3+
id "signing"
4+
}
5+
6+
java {
7+
withSourcesJar()
8+
withJavadocJar()
9+
}
10+
11+
publishing {
12+
publications {
13+
mavenJava(MavenPublication) {
14+
from(components.java)
15+
16+
groupId = project.maven_group
17+
artifactId = project.maven_name
18+
version = project.maven_version
19+
}
20+
}
21+
}
22+
23+
signing {
24+
setRequired(false)
25+
sign(publishing.publications.mavenJava)
26+
}
27+
28+
tasks.withType(PublishToMavenRepository).configureEach {
29+
it.dependsOn(tasks.withType(Sign))
30+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
publishing {
2+
repositories {
3+
maven {
4+
name = "Via"
5+
url = "https://repo.viaversion.com/"
6+
7+
credentials(PasswordCredentials)
8+
authentication {
9+
basic(BasicAuthentication)
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)