@@ -22,6 +22,7 @@ import groovy.transform.TypeCheckingMode
2222import org.gradle.api.DomainObjectSet
2323import org.gradle.api.Project
2424import org.gradle.api.Task
25+ import org.gradle.api.file.CopySpec
2526import org.gradle.api.specs.Specs
2627import org.gradle.api.tasks.Copy
2728import org.gradle.util.GradleVersion
@@ -117,15 +118,6 @@ class AndroidLintConfigurator implements AnalysisConfigurator {
117118
118119 configureLintOptions(project, extension, config, lintTask)
119120
120- if (lintTask. name == GLOBAL_LINT_TASK_NAME ) {
121- // Change output location for consistency with other plugins
122- // we copy as to not tamper with other lint tasks
123- lintTask. finalizedBy(project. tasks. create(' copyLintReport' , Copy ) { Copy it ->
124- it. from lintTask. outputs. files. filter { File f -> f. name. endsWith(' .xml' ) }
125- it. into project. file(" ${ project.buildDir} /reports/android/lint-results.xml" )
126- })
127- }
128-
129121 try {
130122 configureLintInputsAndOutputs(project, lintTask)
131123
@@ -143,6 +135,21 @@ class AndroidLintConfigurator implements AnalysisConfigurator {
143135 false
144136 }
145137 }
138+
139+ if (lintTask. name == GLOBAL_LINT_TASK_NAME ) {
140+ // Change output location for consistency with other plugins
141+ // we copy as to not tamper with other lint tasks
142+ Task copyLintReportTask = project. tasks. create(' copyLintReport' , Copy ) { Copy it ->
143+ it. from(lintTask. outputs. files. filter { File f -> f. name. endsWith(' .xml' ) }. singleFile. parent)
144+ { CopySpec cs ->
145+ cs. include ' *.xml'
146+ }
147+ it. into project. file(" ${ project.buildDir} /reports/android/" )
148+ it. rename ' .*' , ' lint-results.xml'
149+ }
150+ lintTask. finalizedBy copyLintReportTask
151+ copyLintReportTask. onlyIf { extension. androidLint }
152+ }
146153 }
147154
148155 private static void warnUnexpectedException (final Project project , final String message , final Throwable e ) {
0 commit comments