Skip to content

Commit 19e3122

Browse files
committed
Split monolithic gradle files into modular gradle snippets
1 parent 0c5e6fc commit 19e3122

11 files changed

+177
-82
lines changed

.gitignore

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

build.gradle

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
plugins {
22
id "java-library"
3-
id "maven-publish"
3+
id "base.base-conventions"
4+
id "base.fill-build-constants"
5+
id "vialoader.publishing-conventions"
6+
id "via.run-with-viaproxy-task"
47
id "net.raphimc.class-token-replacer" version "1.1.4"
58
}
69

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.name ?: rootProject.name
13-
version = project.maven_version ?: rootProject.maven_version
14-
}
15-
1610
repositories {
17-
mavenCentral()
1811
maven {
1912
name = "ViaVersion"
2013
url = "https://repo.viaversion.com"
@@ -61,71 +54,3 @@ dependencies {
6154
api "com.google.guava:guava:33.4.8-jre"
6255
api "org.slf4j:slf4j-api:2.0.17"
6356
}
64-
65-
sourceSets {
66-
main {
67-
classTokenReplacer {
68-
property("\${version}", project.version)
69-
}
70-
}
71-
}
72-
73-
java {
74-
withSourcesJar()
75-
}
76-
77-
jar {
78-
from("LICENSE") {
79-
rename { "${it}_${project.name ?: rootProject.name}" }
80-
}
81-
}
82-
83-
publishing {
84-
repositories {
85-
maven {
86-
name = "Via"
87-
url = "https://repo.viaversion.com/"
88-
89-
credentials(PasswordCredentials)
90-
authentication {
91-
basic(BasicAuthentication)
92-
}
93-
}
94-
}
95-
publications {
96-
maven(MavenPublication) {
97-
groupId = project.maven_group
98-
artifactId = project.maven_name
99-
version = project.maven_version
100-
101-
from components.java
102-
103-
pom {
104-
name = "ViaLoader"
105-
description = "Implementation of a ViaVersion based protocol translator platform"
106-
url = "https://github.com/ViaVersion/ViaLoader"
107-
licenses {
108-
license {
109-
name = "GPL-3.0 License"
110-
url = "https://github.com/ViaVersion/ViaLoader/blob/main/LICENSE"
111-
}
112-
}
113-
developers {
114-
developer {
115-
id = "RK_01"
116-
}
117-
developer {
118-
id = "FlorianMichael"
119-
name = "EnZaXD"
120-
121-
}
122-
}
123-
scm {
124-
connection = "scm:git:git://github.com/ViaVersion/ViaLoader.git"
125-
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaLoader.git"
126-
url = "https://github.com/ViaVersion/ViaLoader.git"
127-
}
128-
}
129-
}
130-
}
131-
}

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: 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: 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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id "base.exclude-run-folder"
3+
}
4+
5+
tasks.register("runViaProxy", JavaExec) {
6+
dependsOn(tasks.jar)
7+
8+
def viaProxyConfiguration = configurations.create("viaProxy")
9+
viaProxyConfiguration.dependencies.add(dependencies.create("net.raphimc:ViaProxy:3.4.1") {
10+
transitive = false
11+
})
12+
13+
mainClass = "net.raphimc.viaproxy.ViaProxy"
14+
classpath = viaProxyConfiguration
15+
workingDir = file("run")
16+
jvmArgs = ["-DskipUpdateCheck"]
17+
18+
doFirst {
19+
def jarsDir = file("$workingDir/jars")
20+
jarsDir.mkdirs()
21+
file("$jarsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
22+
}
23+
24+
doLast {
25+
file("$workingDir/jars/${project.name}.jar").delete()
26+
file("$workingDir/logs").deleteDir()
27+
}
28+
}
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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
plugins {
2+
id "base.publishing-conventions"
3+
id "via.viaversion-maven-publishing"
4+
}
5+
6+
publishing {
7+
publications {
8+
mavenJava {
9+
pom {
10+
name = "ViaLoader"
11+
description = "Implementation of a ViaVersion based protocol translator platform"
12+
url = "https://github.com/ViaVersion/ViaLoader"
13+
licenses {
14+
license {
15+
name = "GPL-3.0 License"
16+
url = "https://github.com/ViaVersion/ViaLoader/blob/main/LICENSE"
17+
}
18+
}
19+
developers {
20+
developer {
21+
id = "RK_01"
22+
}
23+
developer {
24+
id = "FlorianMichael"
25+
name = "EnZaXD"
26+
27+
}
28+
}
29+
scm {
30+
connection = "scm:git:git://github.com/ViaVersion/ViaLoader.git"
31+
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaLoader.git"
32+
url = "https://github.com/ViaVersion/ViaLoader.git"
33+
}
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)