Need build to fail if there are package cycles

@Baron_Roberts mentions over here that jdepend doesn’t support Java 8. It runs, and generates the XML report fine. but ant:jdependreport fails with “Unknown constant: 18” and most significantly, the build doesn’t halt if there are package cycles.

I need a way for my build to fail if it contains package cycles.

I’m tempted to write a plugin that scans the report file to see if the Cycles tag is empty just so I can move on, but I’d prefer to use a supported solution. Has anyone found a workaround to fail on package cycles in gradle in Java 8?


I added this bit of code to my build.gradle as a workaround. But I’d prefer a supported solution if there’s one out there…

    check {
		doLast {
			def infile = "$jdepend.reportsDir/main.xml"
			println "Parsing $infile"
			def inxml = new XmlParser().parse(infile)
			def cycles = inxml.Cycles[0].children().size()
			println "Number of cycles: $cycles"
			if (cycles > 0) {
				throw new GradleException("$cycles package cycles found in $  See $infile for details.")