Make dexMethodCount task incremental unless teamcity output is required
Declare details file as output, circumvent task up-to-date check if teamcity statistics output is required.
This commit is contained in:
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import com.jakewharton.dex.*
|
||||
@@ -30,6 +19,10 @@ open class DexMethodCount : DefaultTask() {
|
||||
val byClass: Map<String, Int>
|
||||
)
|
||||
|
||||
init {
|
||||
outputs.upToDateWhen { !shouldPrintTeamCityStatistics } // always execute when teamCityStatistics output is required
|
||||
}
|
||||
|
||||
@InputFile
|
||||
lateinit var jarFile: File
|
||||
|
||||
@@ -42,6 +35,9 @@ open class DexMethodCount : DefaultTask() {
|
||||
@Optional
|
||||
var teamCityStatistics: Boolean? = null
|
||||
|
||||
private val shouldPrintTeamCityStatistics = teamCityStatistics ?: project.hasProperty("teamcity")
|
||||
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
var artifactName: String? = null
|
||||
@@ -54,8 +50,12 @@ open class DexMethodCount : DefaultTask() {
|
||||
dependsOn(jar)
|
||||
}
|
||||
|
||||
@Internal // plain output properties are not supported, mark as internal to suppress warning from validateTaskProperties
|
||||
lateinit var counts: Counts
|
||||
|
||||
@get:OutputFile
|
||||
val detailOutputFile: File get() = project.buildDir.resolve("$artifactOrArchiveName-method-count.txt")
|
||||
|
||||
@TaskAction
|
||||
fun invoke() {
|
||||
val methods = dexMethods(jarFile)
|
||||
@@ -96,7 +96,7 @@ open class DexMethodCount : DefaultTask() {
|
||||
}
|
||||
|
||||
private fun printTCStats(counts: Counts) {
|
||||
if (teamCityStatistics ?: project.hasProperty("teamcity")) {
|
||||
if (shouldPrintTeamCityStatistics) {
|
||||
println("##teamcity[buildStatisticValue key='DexMethodCount_${artifactOrArchiveName}' value='${counts.total}']")
|
||||
counts.totalOwnPackages?.let { value ->
|
||||
println("##teamcity[buildStatisticValue key='DexMethodCount_${artifactOrArchiveName}_OwnPackages' value='$value']")
|
||||
@@ -108,8 +108,7 @@ open class DexMethodCount : DefaultTask() {
|
||||
}
|
||||
|
||||
private fun outputDetails(counts: Counts) {
|
||||
val detailFile = project.buildDir.resolve("$artifactOrArchiveName-method-count.txt")
|
||||
detailFile.printWriter().use { writer ->
|
||||
detailOutputFile.printWriter().use { writer ->
|
||||
writer.println("${counts.total.padRight()}\tTotal methods")
|
||||
ownPackages?.let { packages ->
|
||||
writer.println("${counts.totalOwnPackages?.padRight()}\tTotal methods from packages ${packages.joinToString { "$it.*" }}")
|
||||
|
||||
Reference in New Issue
Block a user