Mercurial > public > develkit
comparison metrics.gradle @ 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 | 969e33b82a99 |
children | 2f6d25a71778 |
comparison
equal
deleted
inserted
replaced
252:01c6387bc240 | 253:46064f36ae31 |
---|---|
1 import org.gradle.api.Plugin | |
2 import org.gradle.api.Project | |
3 import org.gradle.api.tasks.bundling.Jar | |
4 | |
5 import org.gradle.api.DefaultTask | |
6 import org.gradle.api.tasks.OutputDirectory | |
7 import org.gradle.api.tasks.OutputFile | |
8 import org.gradle.api.tasks.TaskAction | |
9 | |
10 import java.util.jar.JarFile | |
11 | |
12 | |
1 final GradleVersion gradleCurrent = GradleVersion.current() | 13 final GradleVersion gradleCurrent = GradleVersion.current() |
2 final GradleVersion gradleV31 = GradleVersion.version('3.1') | 14 final GradleVersion gradleV31 = GradleVersion.version('3.1') |
3 | 15 |
4 final boolean legacySonar = gradleCurrent < gradleV31 | 16 final boolean legacySonar = gradleCurrent < gradleV31 |
5 final boolean newSonar = !legacySonar | 17 final boolean newSonar = !legacySonar |
15 classpath 'me.davesmith:jaranalyzerplugin:0.2.0-SNAPSHOT' | 27 classpath 'me.davesmith:jaranalyzerplugin:0.2.0-SNAPSHOT' |
16 classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${GradleVersion.current() >= gradleV421 ? '2.6' : '2.2'}" | 28 classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${GradleVersion.current() >= gradleV421 ? '2.6' : '2.2'}" |
17 } | 29 } |
18 } | 30 } |
19 | 31 |
32 apply plugin: JarAnalyzerPlugin | |
33 | |
34 /* | |
20 apply plugin: me.davesmith.gradle.plugins.jaranalyzer.JarAnalyzerPlugin | 35 apply plugin: me.davesmith.gradle.plugins.jaranalyzer.JarAnalyzerPlugin |
21 | 36 |
22 jaranalyzer { | 37 task("jaranalyzer") { |
23 dot = true | 38 dot = true |
24 packageFilter += 'org.slf4j*' | 39 packageFilter += 'org.slf4j*' |
25 packageFilter += 'groovyx.*' | 40 packageFilter += 'groovyx.*' |
26 } | 41 } |
27 | 42 |
43 */ | |
28 | 44 |
29 if (newSonar) { | 45 if (newSonar) { |
30 | 46 |
31 apply plugin: org.sonarqube.gradle.SonarQubePlugin | 47 apply plugin: org.sonarqube.gradle.SonarQubePlugin |
32 | 48 |
52 task('sonar') << { | 68 task('sonar') << { |
53 println "legacy sonar disabled" | 69 println "legacy sonar disabled" |
54 } | 70 } |
55 | 71 |
56 } | 72 } |
73 | |
74 | |
75 /** | |
76 * this is a stub plugin to replace old jaranalyzer until all projects remove the jaranalyzer task. | |
77 */ | |
78 class JarAnalyzerPlugin implements Plugin<Project> { | |
79 | |
80 @Override | |
81 void apply(Project project) { | |
82 | |
83 project.extensions.create("jaranalyzer", JarAnalyzerExtension) | |
84 | |
85 project.tasks.create("jarAnalyzerReport",JarAnalyzerReportTask) | |
86 | |
87 project.afterEvaluate { Project p -> | |
88 p.tasks.getByName('jarAnalyzerReport').dependsOn p.subprojects.collect { Project targetProject -> | |
89 targetProject.tasks.withType(Jar) | |
90 }.flatten() | |
91 | |
92 } | |
93 } | |
94 | |
95 } | |
96 | |
97 class JarAnalyzerExtension { | |
98 | |
99 /** Generate dot report? */ | |
100 boolean dot = false | |
101 /** Generate xml report? */ | |
102 boolean xml = true | |
103 /** Generate html report? */ | |
104 boolean html = true | |
105 /** Generate osgi report? */ | |
106 boolean osgi = false | |
107 | |
108 /** list of jars to exclude from analysis. */ | |
109 List<String> jarFilter = [] | |
110 | |
111 String jarPrefix = "" | |
112 | |
113 List<String> packageFilter = [ ] | |
114 | |
115 String configuration = 'runtime' | |
116 | |
117 } | |
118 | |
119 | |
120 class JarAnalyzerReportTask extends DefaultTask { | |
121 | |
122 | |
123 @OutputDirectory | |
124 File outputDir = new File(project.buildDir, "reports/jaranalyzer") | |
125 | |
126 File jarDir = new File("${project.buildDir.path}", "jars") | |
127 | |
128 @OutputFile | |
129 File xmlReport = new File(outputDir, 'jaranalyzer.xml') | |
130 | |
131 @OutputFile | |
132 File htmlReport = new File(outputDir, 'jaranalyzer.html') | |
133 | |
134 @OutputFile | |
135 File dotReport = new File(outputDir, 'jaranalyzer.dot') | |
136 | |
137 @OutputFile | |
138 File osgiReport = new File(outputDir, 'osgi-report.txt') | |
139 | |
140 @TaskAction | |
141 def analyze() { | |
142 println "jar analyser is obsolete, please remove it." | |
143 | |
144 //NOOP | |
145 } | |
146 | |
147 } |