2929package io.spine.tools.core.jvm.gradle.plugins
3030
3131import io.spine.tools.compiler.gradle.api.CompilerSettings
32- import io.spine.tools.compiler.gradle.api.Names
3332import io.spine.tools.compiler.gradle.api.Names.GRADLE_PLUGIN_ID
33+ import io.spine.tools.compiler.gradle.api.addUserClasspathDependency
3434import io.spine.tools.compiler.gradle.api.compilerSettings
3535import io.spine.tools.compiler.gradle.api.compilerWorkingDir
3636import io.spine.tools.compiler.gradle.plugin.LaunchSpineCompiler
@@ -42,7 +42,6 @@ import io.spine.tools.core.jvm.entity.EntityPlugin
4242import io.spine.tools.core.jvm.gradle.coreJvmOptions
4343import io.spine.tools.core.jvm.gradle.generatedGrpcDirName
4444import io.spine.tools.core.jvm.gradle.generatedJavaDirName
45- import io.spine.tools.core.jvm.gradle.plugins.CompilerConfigPlugin.Companion.VALIDATION_PLUGIN_CLASS
4645import io.spine.tools.core.jvm.gradle.plugins.CompilerConfigPlugin.Companion.WRITE_COMPILER_PLUGINS_SETTINGS
4746import io.spine.tools.core.jvm.gradle.settings.CoreJvmCompilerSettings
4847import io.spine.tools.core.jvm.marker.MarkerPlugin
@@ -53,10 +52,8 @@ import io.spine.tools.core.jvm.uuid.UuidPlugin
5352import io.spine.tools.fs.DirectoryName
5453import io.spine.tools.gradle.task.JavaTaskName.Companion.processResources
5554import io.spine.tools.gradle.task.JavaTaskName.Companion.sourcesJar
56- import io.spine.tools.meta.MavenArtifact
5755import org.gradle.api.Plugin
5856import org.gradle.api.Project
59- import org.gradle.api.artifacts.Dependency
6057import org.gradle.api.provider.Provider
6158import org.gradle.kotlin.dsl.register
6259import org.gradle.kotlin.dsl.withType
@@ -144,7 +141,7 @@ private fun Project.configureCompilerPlugins() {
144141 val compiler = compilerSettings
145142 compiler.setSubdirectories()
146143
147- configureValidation(compiler)
144+ // configureValidation(compiler)
148145 configureSignals(compiler)
149146
150147 compiler.run {
@@ -174,29 +171,6 @@ private fun CompilerSettings.setSubdirectories() {
174171 )
175172}
176173
177- private fun Project.configureValidation (compiler : CompilerSettings ) {
178- val validationConfig = messageOptions.validation
179- val version = validationConfig.version.get()
180- if (validationConfig.enabled.get()) {
181- addUserClasspathDependency(ValidationSdk .javaCodegenBundle(version))
182- compiler.plugins(
183- VALIDATION_PLUGIN_CLASS
184- )
185- } else {
186- addUserClasspathDependency(ValidationSdk .configuration(version))
187- }
188-
189- // We add the dependency on runtime anyway for the following reasons:
190- // 1. We do not want users to change their Gradle build files when they turn on or off
191- // code generation for the validation code.
192- //
193- // 2. We have run-time validation rules that are going to be used in parallel with
194- // the generated code. This includes current and new implementation for validation
195- // rules for the already existing generated Protobuf code.
196- //
197- addDependency(" implementation" , ValidationSdk .jvmRuntime(version))
198- }
199-
200174private fun Project.configureSignals (compiler : CompilerSettings ) {
201175 compiler.addPlugin<SignalPlugin >()
202176
@@ -206,25 +180,6 @@ private fun Project.configureSignals(compiler: CompilerSettings) {
206180 }
207181}
208182
209- private fun Project.addUserClasspathDependency (vararg artifacts : MavenArtifact ) =
210- artifacts.forEach {
211- addDependency(Names .USER_CLASSPATH_CONFIGURATION , it)
212- }
213-
214- private fun Project.addDependency (configuration : String , artifact : MavenArtifact ) {
215- val dependency = findDependency(artifact) ? : artifact.coordinates
216- dependencies.add(configuration, dependency)
217- }
218-
219- private fun Project.findDependency (artifact : MavenArtifact ): Dependency ? {
220- val dependencies = configurations.flatMap { c -> c.dependencies }
221- val found = dependencies.firstOrNull { d ->
222- artifact.group == d.group // `d.group` could be `null`.
223- && artifact.name == d.name
224- }
225- return found
226- }
227-
228183private inline fun <reified T : CompilerPlugin > CompilerSettings.addPlugin () {
229184 plugins(T ::class .java.name)
230185}
0 commit comments