Skip to content

Commit

Permalink
Added shadow for diktat-runner (#1834)
Browse files Browse the repository at this point in the history
- added shadow artifact for diktat-runner to resolve issue with guava in spotless
  • Loading branch information
nulls authored Nov 30, 2023
1 parent 3ebe006 commit 137b4f7
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private val loggingListener = object : DiktatProcessorListener {
}

fun main(args: Array<String>) {
val properties = DiktatProperties.parse(diktatRunnerFactory.diktatReporterFactory, args)
val properties = DiktatProperties.parse(diktatReporterFactory, args)
properties.configureLogger()

log.debug {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ data class DiktatProperties(
files = getFiles(sourceRootDir),
baselineFile = null,
reporterArgsList = listOf(reporterCreationArguments),
loggingListener = loggingListener
loggingListener = loggingListener,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.VerificationTask
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.language.base.plugins.LifecycleBasePlugin
import java.nio.file.Files

import java.nio.file.Files
import java.nio.file.Path

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ abstract class DiktatBaseMojo : AbstractMojo() {
* @param args arguments for [DiktatRunner]
* @return count of errors
*/
@Suppress("TOO_MANY_PARAMETERS")
abstract fun runAction(
runner: DiktatRunner,
args: DiktatRunnerArguments,
Expand Down
30 changes: 29 additions & 1 deletion diktat-runner/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import com.saveourtool.diktat.buildutils.configurePublications
import com.saveourtool.diktat.buildutils.configurePublishing
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

@Suppress("DSL_SCOPE_VIOLATION", "RUN_IN_SCRIPT") // https://github.com/gradle/gradle/issues/22797
plugins {
id("com.saveourtool.diktat.buildutils.kotlin-jvm-configuration")
id("com.saveourtool.diktat.buildutils.code-quality-convention")
id("com.saveourtool.diktat.buildutils.publishing-default-configuration")
id("com.saveourtool.diktat.buildutils.publishing-configuration")
alias(libs.plugins.shadow)
}

project.description = "This module contains runner for diktat"
Expand All @@ -13,3 +19,25 @@ dependencies {
implementation(projects.diktatKtlintEngine)
implementation(projects.diktatRules)
}

tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set("shadow")
duplicatesStrategy = DuplicatesStrategy.FAIL
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
// it creates a publication for shadowJar
create<MavenPublication>("shadow") {
// https://github.com/johnrengelman/shadow/issues/417#issuecomment-830668442
project.extensions.configure<ShadowExtension> {
component(this@create)
}
}
}
}
configurePublications()
configurePublishing()
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Contains only initialized factories
*/

package com.saveourtool.diktat

import com.saveourtool.diktat.api.DiktatBaselineFactory
import com.saveourtool.diktat.api.DiktatReporterFactory
import com.saveourtool.diktat.api.DiktatRuleConfigReader
import com.saveourtool.diktat.api.DiktatRuleSetFactory
import com.saveourtool.diktat.ktlint.DiktatBaselineFactoryImpl
import com.saveourtool.diktat.ktlint.DiktatProcessorFactoryImpl
import com.saveourtool.diktat.ktlint.DiktatReporterFactoryImpl
import com.saveourtool.diktat.ruleset.rules.DiktatRuleConfigReaderImpl
import com.saveourtool.diktat.ruleset.rules.DiktatRuleSetFactoryImpl
import generated.KTLINT_VERSION

/**
* Info about engine
*/
const val ENGINE_INFO: String = "Ktlint: $KTLINT_VERSION"

/**
* @return initialized [DiktatRuleConfigReader]
*/
val diktatRuleConfigReader: DiktatRuleConfigReader = DiktatRuleConfigReaderImpl()

/**
* @return initialized [DiktatRuleSetFactory]
*/
val diktatRuleSetFactory: DiktatRuleSetFactory = DiktatRuleSetFactoryImpl()

/**
* @return initialized [DiktatProcessorFactory]
*/
val diktatProcessorFactory: DiktatProcessorFactory = DiktatProcessorFactoryImpl()

/**
* @return initialized [DiktatBaselineFactory]
*/
val diktatBaselineFactory: DiktatBaselineFactory = DiktatBaselineFactoryImpl()

/**
* @return initialized [DiktatReporterFactory]
*/
val diktatReporterFactory: DiktatReporterFactory = DiktatReporterFactoryImpl()

/**
* @return initialized [DiktatRunnerFactory]
*/
val diktatRunnerFactory: DiktatRunnerFactory = DiktatRunnerFactory(
diktatRuleConfigReader,
diktatRuleSetFactory,
diktatProcessorFactory,
diktatBaselineFactory,
diktatReporterFactory,
)

This file was deleted.

0 comments on commit 137b4f7

Please sign in to comment.