@@ -11,7 +11,7 @@ plugins {
1111
1212allprojects {
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
72110subprojects {
0 commit comments