Skip to content

Commit d3be86c

Browse files
Use addUserClasspathDependency() from the Compiler API
1 parent 10f930e commit d3be86c

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ object Compiler {
7070
* The version of the Compiler dependencies.
7171
*/
7272
val version: String
73-
private const val fallbackVersion = "2.0.0-SNAPSHOT.034"
73+
private const val fallbackVersion = "2.0.0-SNAPSHOT.035"
7474

7575
/**
7676
* The distinct version of the Compiler used by other build tools.
@@ -79,7 +79,7 @@ object Compiler {
7979
* transitive dependencies, this is the version used to build the project itself.
8080
*/
8181
val dogfoodingVersion: String
82-
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.034"
82+
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.035"
8383

8484
/**
8585
* The artifact for the Compiler Gradle plugin.

gradle-plugin/src/main/kotlin/io/spine/tools/validation/gradle/ValidationGradlePlugin.kt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626

2727
package io.spine.tools.validation.gradle
2828

29-
import io.spine.tools.compiler.gradle.api.Names
3029
import io.spine.tools.compiler.gradle.api.compilerSettings
30+
import io.spine.tools.compiler.gradle.api.addUserClasspathDependency
3131
import io.spine.tools.gradle.DslSpec
3232
import io.spine.tools.gradle.lib.LibraryPlugin
3333
import io.spine.tools.gradle.lib.spineExtension
34-
import io.spine.tools.meta.MavenArtifact
3534
import org.gradle.api.Project
36-
import org.gradle.api.artifacts.Dependency
3735

3836
/**
3937
* Gradle plugin that configures the Spine Compiler to run the Validation Compiler in solo mode.
@@ -68,22 +66,3 @@ public class ValidationGradlePlugin : LibraryPlugin<ValidationExtension>(
6866
*/
6967
private val Project.validationExtension: ValidationExtension
7068
get() = spineExtension<ValidationExtension>()
71-
72-
private fun Project.addUserClasspathDependency(vararg artifacts: MavenArtifact) =
73-
artifacts.forEach {
74-
addDependency(Names.USER_CLASSPATH_CONFIGURATION, it)
75-
}
76-
77-
private fun Project.addDependency(configuration: String, artifact: MavenArtifact) {
78-
val dependency = findDependency(artifact) ?: artifact.coordinates
79-
dependencies.add(configuration, dependency)
80-
}
81-
82-
private fun Project.findDependency(artifact: MavenArtifact): Dependency? {
83-
val dependencies = configurations.flatMap { c -> c.dependencies }
84-
val found = dependencies.firstOrNull { d ->
85-
artifact.group == d.group // `d.group` could be `null`.
86-
&& artifact.name == d.name
87-
}
88-
return found
89-
}

0 commit comments

Comments
 (0)