# HG changeset patch # User smith@nwoca.org # Date 1517519840 0 # Node ID 46064f36ae314d991e5c93c284fb40694ea07f07 # Parent 01c6387bc2409914f6606fd69dffcac100a5b743 remove old jaranalyzer and replace with stub to avoid breaking projects diff -r 01c6387bc240 -r 46064f36ae31 metrics.gradle --- a/metrics.gradle Tue Jan 23 17:07:10 2018 +0000 +++ b/metrics.gradle Thu Feb 01 21:17:20 2018 +0000 @@ -1,3 +1,15 @@ +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.bundling.Jar + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + +import java.util.jar.JarFile + + final GradleVersion gradleCurrent = GradleVersion.current() final GradleVersion gradleV31 = GradleVersion.version('3.1') @@ -17,14 +29,18 @@ } } +apply plugin: JarAnalyzerPlugin + +/* apply plugin: me.davesmith.gradle.plugins.jaranalyzer.JarAnalyzerPlugin -jaranalyzer { +task("jaranalyzer") { dot = true packageFilter += 'org.slf4j*' packageFilter += 'groovyx.*' } +*/ if (newSonar) { @@ -54,3 +70,78 @@ } } + + +/** + * this is a stub plugin to replace old jaranalyzer until all projects remove the jaranalyzer task. + */ +class JarAnalyzerPlugin implements Plugin { + + @Override + void apply(Project project) { + + project.extensions.create("jaranalyzer", JarAnalyzerExtension) + + project.tasks.create("jarAnalyzerReport",JarAnalyzerReportTask) + + project.afterEvaluate { Project p -> + p.tasks.getByName('jarAnalyzerReport').dependsOn p.subprojects.collect { Project targetProject -> + targetProject.tasks.withType(Jar) + }.flatten() + + } + } + +} + +class JarAnalyzerExtension { + + /** Generate dot report? */ + boolean dot = false + /** Generate xml report? */ + boolean xml = true + /** Generate html report? */ + boolean html = true + /** Generate osgi report? */ + boolean osgi = false + + /** list of jars to exclude from analysis. */ + List jarFilter = [] + + String jarPrefix = "" + + List packageFilter = [ ] + + String configuration = 'runtime' + +} + + +class JarAnalyzerReportTask extends DefaultTask { + + + @OutputDirectory + File outputDir = new File(project.buildDir, "reports/jaranalyzer") + + File jarDir = new File("${project.buildDir.path}", "jars") + + @OutputFile + File xmlReport = new File(outputDir, 'jaranalyzer.xml') + + @OutputFile + File htmlReport = new File(outputDir, 'jaranalyzer.html') + + @OutputFile + File dotReport = new File(outputDir, 'jaranalyzer.dot') + + @OutputFile + File osgiReport = new File(outputDir, 'osgi-report.txt') + + @TaskAction + def analyze() { + println "jar analyser is obsolete, please remove it." + + //NOOP + } + +}