Compare commits

...

1 Commits

Author SHA1 Message Date
Ilia Ravin 30954fc643 add detekt server support 2022-09-27 14:52:57 +03:00
1 changed files with 27 additions and 2 deletions

View File

@ -2,8 +2,10 @@ apply plugin: 'cpd'
apply plugin: 'io.gitlab.arturbosch.detekt'
def getCpdTask
def getCpdTaskForServer
def getLintTask
def getKotlinDetektTasks
def getKotlinDetektTasksForServer
def appendError
def appendCpdErrors
@ -51,8 +53,8 @@ ext.getIdeaFormatTask = { isAndroidProject, sources ->
ext.getStaticAnalysisTaskNames = { isAndroidProject, sources, buildVariant ->
def tasksNames = new ArrayList<String>()
try {
tasksNames.add(getCpdTask(isAndroidProject, sources))
tasksNames.addAll(getKotlinDetektTasks())
tasksNames.add(isAndroidProject?getCpdTask(isAndroidProject, sources):getCpdTaskForServer(sources))
tasksNames.addAll(isAndroidProject?getKotlinDetektTasks(): getKotlinDetektTasksForServer())
if (isAndroidProject) {
tasksNames.add(getLintTask(buildVariant))
}
@ -192,6 +194,25 @@ getCpdTask = { isAndroidProject, sources ->
return task.path
}
getCpdTaskForServer = { sources ->
def taskName = "server_cpd_${project.name}"
def task = tasks.findByName(taskName)
if (task == null) {
task = tasks.create(taskName, tasks.findByName('cpdCheck').getClass().getSuperclass()) {
minimumTokenCount = 60
source = files(sources)
ignoreFailures = true
reports {
xml {
enabled = true
destination = file("${project.buildDir}/reports/cpd.xml")
}
}
}
}
return task.path
}
getLintTask = { buildVariant ->
def appProject = subprojects.find { it.plugins.hasPlugin("com.android.application") }
def lintTaskPath
@ -213,6 +234,10 @@ getKotlinDetektTasks = {
.findAll { !it.contains(":libs") }
}
getKotlinDetektTasksForServer = {
tasks.findByName("detekt")?.path
}
task optimizePng {
doFirst {
def jarArgs = new ArrayList<String>()