Skip to content

Commit e611fcd

Browse files
authored
(3.0.2) checkForUnresolvablePackages task & bukkit serverversion fix (#116)
* Create checkForUnresolvablePackages task * Use compileOnly for bukkit serverVersion * Bump version to 3.0.2
1 parent c232fa2 commit e611fcd

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

build.gradle

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111

1212
allprojects {
1313
group = "com.dumbdogdiner"
14-
version = "3.0.1"
14+
version = "3.0.2"
1515

1616
// java plugin is applied in subprojects
1717
apply plugin: "jacoco"
@@ -67,6 +67,44 @@ allprojects {
6767
// Include private and protected in the javadocs
6868
options.memberLevel = JavadocMemberLevel.PRIVATE
6969
}
70+
71+
// -------------------------
72+
// Check for unresolvable packages (works on root and subprojects)
73+
// -------------------------
74+
// Define unresolvable packages here
75+
def unresolvablePackages = ["serverversion"]
76+
// Define the default configuration to check (in this case the one from the "java" plugin used in our subprojects)
77+
def configurationToCheck = "runtimeClasspath"
78+
// Define the task itself
79+
task checkForUnresolvablePackages {
80+
// Set metadata
81+
description = "Check that no unresolvable packages are in the given configuration"
82+
group = "verification"
83+
doLast {
84+
println("Checking project '$project.name' for unresolvable packages...")
85+
// Root project: "runtimeClasspath" not available, use "classpath" configuration instead
86+
if (project.name == rootProject.name) configurationToCheck = "classpath"
87+
println("Using configuration '$configurationToCheck'")
88+
// Iterate through each dependency in the given configuration
89+
configurations[configurationToCheck].allDependencies.each {
90+
println("[debug] Checking '$it.group:$it.name:$it.version'")
91+
// Check if it's in our list AND has the same group as the root project
92+
// (To make sure it's actually from this codebase)
93+
if (unresolvablePackages.contains(it.name) && it.group == rootProject.group) {
94+
// Print to console, and also call ant.fail to fail the entire build.
95+
def errMsg = "Found unresolvable dependency '$it.group:$it.name' in project '$project.name'!"
96+
println(errMsg)
97+
ant.fail(errMsg)
98+
}
99+
}
100+
// Otherwise, the check passed!
101+
println("Unresolvable packages check for project '$name' completed successfully!")
102+
}
103+
}
104+
105+
// Finalize the build task with this task on every project.
106+
build.finalizedBy checkForUnresolvablePackages
107+
// -------------------------
70108
}
71109

72110
subprojects {

bukkit/build.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
plugins {
2+
// for "api" in dependencies { }
3+
id "java-library"
4+
}
5+
16
dependencies {
27
implementation project(":common")
38
testImplementation project(":common").sourceSets.test.output
49

5-
// 3.0.1: serverversion is not transistive from common
6-
implementation project(":common:serverversion")
10+
// 3.0.2: serverversion is not transistive from common
11+
// Since we depend on common, the class is still available at runtime
12+
// -------------------------
13+
// Why: "compileOnly" | This typically includes dependencies which are shaded when found at runtime.
14+
// Source: https://docs.gradle.org/6.8.3/userguide/java_library_plugin.html
15+
compileOnly project(":common:serverversion")
716

817
compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"
918

0 commit comments

Comments
 (0)