@@ -15,6 +15,7 @@ import org.eclipse.aether.spi.connector.RepositoryConnectorFactory
1515import org.eclipse.aether.spi.connector.transport.TransporterFactory
1616import org.eclipse.aether.transport.http.HttpTransporterFactory
1717import org.eclipse.aether.version.Version
18+ import org.gradle.api.GradleException
1819import org.gradle.api.Plugin
1920import org.gradle.api.Project
2021import org.objectweb.asm.ClassReader
@@ -138,41 +139,41 @@ class VersionScanPlugin implements Plugin<Project> {
138139 if (! verifyPresent. isEmpty() || ! verifyMissing. isEmpty()) {
139140 def verifyVersionScan = project. task(' verifyVersionScan' ) {
140141 description = " Validates that the configured classes and methods are only present where expected."
141- doLast {
142- // This may already be done by the report task, but repeating for good measure.
143- keyPresent. get(). removeAll(allExclude)
144- keyMissing. get(). removeAll(allInclude)
145-
146- assert keyPresent. get() != [] || keyMissing. get() != []
147-
148- def errors = []
149- for (String className : verifyPresent. keySet()) {
150- if (project. versionScan. scanMethods && verifyPresent. get(className) == null ) {
151- throw new AssertionError (" When 'scanMethods' is enabled, a method must be configured for '$className '" )
152- } else if (! project. versionScan. scanMethods && verifyPresent. get(className) != null ) {
153- throw new AssertionError (" When 'scanMethods' is not enabled, configured method must be null for '$className '" )
154- }
155-
156- String identifier = project. versionScan. scanMethods ? " $className |${ verifyPresent.get(className)} " : className
157- if (! keyPresent. get(). contains(identifier)) {
158- errors << " not a 'keyPresent' identifier: $identifier "
159- }
160- }
161- for (String className : verifyMissing) {
162- if (! keyMissing. get(). contains(className)) {
163- errors << " not a 'keyMissing' identifier: $className "
164- }
142+ }
143+ verifyVersionScan. doLast {
144+ // This may already be done by the report task, but repeating for good measure.
145+ keyPresent. get(). removeAll(allExclude)
146+ keyMissing. get(). removeAll(allInclude)
147+
148+ assert keyPresent. get() != [] || keyMissing. get() != []
149+
150+ def errors = []
151+ for (String className : verifyPresent. keySet()) {
152+ if (project. versionScan. scanMethods && verifyPresent. get(className) == null ) {
153+ throw new AssertionError (" When 'scanMethods' is enabled, a method must be configured for '$className '" )
154+ } else if (! project. versionScan. scanMethods && verifyPresent. get(className) != null ) {
155+ throw new AssertionError (" When 'scanMethods' is not enabled, configured method must be null for '$className '" )
165156 }
166- errors. each {
167- System . err. println " Error for $group :$module - $it "
157+
158+ String identifier = project. versionScan. scanMethods ? " $className |${ verifyPresent.get(className)} " : className
159+ if (! keyPresent. get(). contains(identifier)) {
160+ errors << " not a 'keyPresent' identifier: $identifier "
168161 }
169- if (! errors. isEmpty()) {
170- throw new AssertionError (" Version scan verification failed.\n " +
171- " Errors listed above are likely the result of a new module " +
172- " being published to Maven, not a code change in this repo.\n " +
173- " This does mean a fix should be made though to 'dd-trace-supported-framework.yaml'." )
162+ }
163+ for (String className : verifyMissing) {
164+ if (! keyMissing. get(). contains(className)) {
165+ errors << " not a 'keyMissing' identifier: $className "
174166 }
175167 }
168+ errors. each {
169+ logger. error " Error for $group :$module - $it "
170+ }
171+ if (! errors. isEmpty()) {
172+ throw new GradleException (" Version scan verification failed.\n " +
173+ " Errors listed above are likely the result of a new module " +
174+ " being published to Maven, not a code change in this repo.\n " +
175+ " This does mean a fix should be made though to 'dd-trace-supported-framework.yaml'." )
176+ }
176177 }
177178
178179 if (project. gradle. startParameter. taskNames. contains(' scanVersions' )) {
0 commit comments