changeset 253:46064f36ae31

remove old jaranalyzer and replace with stub to avoid breaking projects
author smith@nwoca.org
date Thu, 01 Feb 2018 21:17:20 +0000
parents 01c6387bc240
children 4e57e2edb2ad
files metrics.gradle
diffstat 1 files changed, 92 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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<Project> {
+
+    @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<String> jarFilter = []
+
+    String jarPrefix = ""
+
+    List<String> 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
+    }
+
+}