Skip to content

Commit

Permalink
Refactor build scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Melnik committed Apr 17, 2024
1 parent 20a1c2b commit bad4066
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 91 deletions.
45 changes: 0 additions & 45 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
standardSpineSdkRepositories()

val spine = io.spine.internal.dependency.Spine
val validation = io.spine.internal.dependency.Validation
val protoData = io.spine.internal.dependency.ProtoData
val logging = io.spine.internal.dependency.Spine.Logging

doForceVersions(configurations)
configurations {
all {
exclude(group = "io.spine", module = "spine-logging-backend")

resolutionStrategy {
force(
io.spine.internal.dependency.Grpc.api,
spine.reflect,
spine.base,
spine.toolBase,
spine.server,
protoData.pluginLib,
logging.lib,
validation.runtime
)
}
}
}
dependencies {
classpath(io.spine.internal.dependency.Spine.McJava.pluginLib)
}
Expand Down Expand Up @@ -94,30 +72,7 @@ allprojects {
// Define the repositories universally for all modules, including the root.
repositories.standardToSpineSdk()

val spine = io.spine.internal.dependency.Spine
val validation = io.spine.internal.dependency.Validation
val protoData = io.spine.internal.dependency.ProtoData
val logging = io.spine.internal.dependency.Spine.Logging

doForceVersions(configurations)
configurations {
all {
exclude(group = "io.spine", module = "spine-logging-backend")

resolutionStrategy {
force(
io.spine.internal.dependency.Grpc.api,
spine.reflect,
spine.base,
spine.toolBase,
spine.server,
protoData.pluginLib,
logging.lib,
validation.runtime
)
}
}
}
}

// It is assumed that every module in the project requires
Expand Down
26 changes: 26 additions & 0 deletions buildSrc/src/main/kotlin/DependencyResolution.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,39 @@ import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.artifacts.ResolutionStrategy
import org.gradle.kotlin.dsl.exclude
import org.gradle.kotlin.dsl.invoke

/**
* The function to be used in `buildscript` when a fully-qualified call must be made.
*/
@Suppress("unused")
fun doForceVersions(configurations: ConfigurationContainer) {
configurations.forceVersions()

val spine = io.spine.internal.dependency.Spine
val validation = io.spine.internal.dependency.Validation
val protoData = io.spine.internal.dependency.ProtoData
val logging = io.spine.internal.dependency.Spine.Logging

configurations {
all {
exclude(group = "io.spine", module = "spine-logging-backend")

resolutionStrategy {
force(
io.spine.internal.dependency.Grpc.api,
spine.reflect,
spine.base,
spine.toolBase,
spine.server,
protoData.pluginLib,
logging.lib,
validation.runtime
)
}
}
}
}

/**
Expand Down
50 changes: 4 additions & 46 deletions integration-tests/src/test/resources/test-project/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
*/

import Build_gradle.Module
import io.spine.internal.dependency.ErrorProne
import io.spine.internal.dependency.HelloProtoData
import io.spine.internal.dependency.Protobuf
import io.spine.internal.dependency.Spine
import io.spine.internal.gradle.javac.configureErrorProne
import io.spine.internal.gradle.javac.configureJavac
import io.spine.internal.gradle.kotlin.applyJvmToolchain
import io.spine.internal.gradle.kotlin.setFreeCompilerArgs
Expand All @@ -37,30 +40,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
standardSpineSdkRepositories()

val spine = io.spine.internal.dependency.Spine
val validation = io.spine.internal.dependency.Validation
val protoData = io.spine.internal.dependency.ProtoData
val logging = io.spine.internal.dependency.Spine.Logging

doForceVersions(configurations)
configurations {
all {
exclude(group = "io.spine", module = "spine-logging-backend")

resolutionStrategy {
force(
io.spine.internal.dependency.Grpc.api,
spine.reflect,
spine.base,
spine.toolBase,
spine.server,
protoData.pluginLib,
logging.lib,
validation.runtime
)
}
}
}

dependencies {
classpath(io.spine.internal.dependency.Spine.McJava.pluginLib)
}
Expand All @@ -84,30 +65,7 @@ allprojects {
// Define the repositories universally for all modules, including the root.
repositories.standardToSpineSdk()

val spine = io.spine.internal.dependency.Spine
val validation = io.spine.internal.dependency.Validation
val protoData = io.spine.internal.dependency.ProtoData
val logging = io.spine.internal.dependency.Spine.Logging

doForceVersions(configurations)
configurations {
all {
exclude(group = "io.spine", module = "spine-logging-backend")

resolutionStrategy {
force(
io.spine.internal.dependency.Grpc.api,
spine.reflect,
spine.base,
spine.toolBase,
spine.server,
protoData.pluginLib,
logging.lib,
validation.runtime
)
}
}
}
}

// It is assumed that every module in the project requires
Expand Down

0 comments on commit bad4066

Please sign in to comment.