Skip to content

Commit 0e8aed4

Browse files
committed
Migrated to gradle conventions
1 parent 59bc291 commit 0e8aed4

21 files changed

+350
-31
lines changed

build.gradle

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
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
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
1310
}
1411

1512
repositories {
16-
mavenCentral()
1713
maven {
1814
name = "viaversion"
19-
url = "https://repo.viaversion.com/everything"
15+
url = "https://repo.viaversion.com"
2016
}
2117
}
2218

2319
dependencies {
24-
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
25-
compileOnly "org.jetbrains:annotations:26.0.2"
26-
compileOnly(annotationProcessor("org.projectlombok:lombok:1.18.38"))
27-
compileOnly "net.raphimc:ViaProxy:3.4.5-SNAPSHOT"
20+
compileOnly libs.viaproxy
21+
22+
compileOnly libs.findbugs
23+
compileOnly libs.jetbrainsAnnotations
24+
compileOnly libs.lombok
25+
annotationProcessor libs.lombok
2826
}
2927

3028
processResources {
29+
var projectMavenVersion = project.maven_version
30+
3131
//Config file: "version: ${version}"
3232
inputs.properties(
33-
"version": project.maven_version
33+
"version": projectMavenVersion
3434
)
3535

3636
filesMatching("viaproxy.yml") {
3737
expand(
38-
"version": project.maven_version
38+
"version": projectMavenVersion
3939
)
4040
}
4141
}
42-
43-
checkstyle {
44-
toolVersion = "10.16.0" //Latest version for Java 8: 9.3
45-
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
46-
}
47-
48-
build.dependsOn(check)

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)