Skip to content

Commit 29315df

Browse files
committed
Migrated to gradle conventions
1 parent 744533f commit 29315df

22 files changed

Lines changed: 354 additions & 74 deletions

build.gradle

Lines changed: 20 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,42 @@
11
plugins {
2-
id "java"
3-
id "checkstyle"
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-
archivesName = project.maven_name ?: rootProject.maven_name
11-
group = project.maven_group ?: rootProject.maven_group
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 "java-library"
3+
id "base.java"
4+
id "base.checkstyle"
5+
id "configuration.include"
6+
id "idea.exclude_run_dir"
7+
id "viaproxy.run-with-viaproxy-task"
8+
id "extra.fill_build_constants"
9+
alias libs.plugins.classTokenReplacer
2010
}
2111

2212
repositories {
23-
mavenCentral()
24-
maven {
25-
name = "lenni0451"
26-
url = "https://maven.lenni0451.net/everything"
27-
}
2813
maven {
2914
name = "viaversion"
3015
url = "https://repo.viaversion.com"
3116
}
3217
}
3318

3419
dependencies {
35-
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
36-
compileOnly "org.jetbrains:annotations:26.0.2"
37-
compileOnly(annotationProcessor("org.projectlombok:lombok:1.18.38"))
38-
compileOnly "net.raphimc:ViaProxy:3.4.5-SNAPSHOT"
39-
include "net.lenni0451.commons:gson:1.7.1"
20+
compileOnly libs.viaproxy
21+
include libs.commonsGson
22+
23+
compileOnly libs.findbugs
24+
compileOnly libs.jetbrainsAnnotations
25+
compileOnly libs.lombok
26+
annotationProcessor libs.lombok
4027
}
4128

4229
processResources {
30+
var projectMavenVersion = project.maven_version
31+
32+
//Config file: "version: ${version}"
4333
inputs.properties(
44-
"version": project.maven_version
34+
"version": projectMavenVersion
4535
)
4636

4737
filesMatching("viaproxy.yml") {
4838
expand(
49-
"version": project.maven_version
39+
"version": projectMavenVersion
5040
)
5141
}
5242
}
53-
54-
jar {
55-
dependsOn configurations.include
56-
from {
57-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
58-
configurations.include.collect {
59-
zipTree(it)
60-
}
61-
} {
62-
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
63-
}
64-
}
65-
66-
checkstyle {
67-
toolVersion = "10.16.0" //Latest version for Java 8: 9.3
68-
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
69-
}
70-
build.dependsOn(check)
71-
72-
tasks.register("runViaProxy", JavaExec) {
73-
dependsOn tasks.jar
74-
75-
mainClass = "net.raphimc.viaproxy.ViaProxy"
76-
classpath = sourceSets.main.compileClasspath
77-
workingDir = file("run")
78-
jvmArgs = ["-DskipUpdateCheck"]
79-
args = ["config", "viaproxy.yml"]
80-
81-
doFirst {
82-
def pluginsDir = file("$workingDir/plugins")
83-
pluginsDir.mkdirs()
84-
file("$pluginsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
85-
}
86-
87-
doLast {
88-
file("$workingDir/plugins/${project.name}.jar").delete()
89-
file("$workingDir/logs").deleteDir()
90-
}
91-
}

buildSrc/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.gradle/
2+
/build/
3+
/out/

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+
}

buildSrc/settings.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
libs {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id "configuration.include"
3+
}
4+
5+
jar {
6+
manifest {
7+
attributes(
8+
"Main-Class": project.main_class,
9+
"Multi-Release": "true",
10+
"Enable-Native-Access": "ALL-UNNAMED"
11+
)
12+
}
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id "checkstyle"
3+
}
4+
5+
checkstyle {
6+
toolVersion = project.checkstyle_version
7+
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
8+
}
9+
build.dependsOn(check)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
tasks.withType(Javadoc).configureEach {
24+
it.options.encoding = "UTF-8"
25+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
configurations {
2+
testImplementation.extendsFrom(compileOnly)
3+
}
4+
5+
dependencies{
6+
testImplementation(platform(libs.junit.bom))
7+
testImplementation libs.junit.jupiter
8+
testRuntimeOnly libs.junit.platform.launcher
9+
}
10+
11+
test {
12+
useJUnitPlatform()
13+
testLogging {
14+
events "passed", "skipped", "failed"
15+
}
16+
maxParallelForks = Runtime.runtime.availableProcessors()
17+
}
18+
build.dependsOn(test)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
plugins {
2+
id "maven-publish"
3+
id "signing"
4+
}
5+
6+
java {
7+
withSourcesJar()
8+
withJavadocJar()
9+
}
10+
11+
publishing {
12+
publications {
13+
maven(MavenPublication) {
14+
artifactId = project.maven_name
15+
groupId = project.maven_group
16+
version = project.maven_version
17+
18+
from components.java
19+
20+
pom {
21+
name = project.name
22+
description = project.maven_description
23+
url = "https://github.com/" + project.github_repo
24+
licenses {
25+
license {
26+
name = project.license
27+
url = "https://github.com/" + project.github_repo + "/blob/main/LICENSE"
28+
}
29+
}
30+
developers {
31+
developer {
32+
id = "Lenni0451"
33+
}
34+
}
35+
scm {
36+
connection = "scm:git:git://github.com/" + project.github_repo + ".git"
37+
developerConnection = "scm:git:ssh://github.com/" + project.github_repo + ".git"
38+
url = "github.com/" + project.github_repo
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
signing {
46+
setRequired(false)
47+
sign(publishing.publications.maven)
48+
}
49+
50+
tasks.withType(PublishToMavenRepository).configureEach {
51+
it.dependsOn(tasks.withType(Sign))
52+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
plugins {
2+
id "com.gradle.plugin-publish"
3+
id "signing"
4+
}
5+
6+
gradlePlugin {
7+
website = "https://github.com/" + rootProject.github_repo
8+
vcsUrl = "https://github.com/" + rootProject.github_repo
9+
}
10+
11+
java {
12+
withSourcesJar()
13+
withJavadocJar()
14+
}
15+
16+
publishing {
17+
publications {
18+
pluginMaven(MavenPublication) {
19+
pom {
20+
name = project.name
21+
description = project.maven_description
22+
url = "https://github.com/" + project.github_repo
23+
licenses {
24+
license {
25+
name = project.license
26+
url = "https://github.com/" + project.github_repo + "/blob/main/LICENSE"
27+
}
28+
}
29+
developers {
30+
developer {
31+
id = "Lenni0451"
32+
}
33+
}
34+
scm {
35+
connection = "scm:git:git://github.com/" + project.github_repo + ".git"
36+
developerConnection = "scm:git:ssh://github.com/" + project.github_repo + ".git"
37+
url = "github.com/" + project.github_repo
38+
}
39+
}
40+
}
41+
}
42+
}
43+
44+
signing {
45+
setRequired(false)
46+
sign(publishing.publications.pluginMaven)
47+
}
48+
49+
tasks.withType(PublishToMavenRepository).configureEach {
50+
it.dependsOn(tasks.withType(Sign))
51+
}

0 commit comments

Comments
 (0)