Skip to content

Commit 58b76ad

Browse files
Apply improvements from CoreJvm Compiler
1 parent d249009 commit 58b76ad

5 files changed

Lines changed: 19 additions & 33 deletions

File tree

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
package io.spine.dependency.local
2828

2929
import io.spine.dependency.Dependency
30-
import io.spine.dependency.local.Compiler.DF_VERSION_ENV
31-
import io.spine.dependency.local.Compiler.VERSION_ENV
32-
import io.spine.dependency.local.Compiler.dogfoodingVersion
33-
import io.spine.dependency.local.Compiler.pluginLib
34-
import io.spine.dependency.local.Compiler.version
3530

3631
/**
3732
* Dependencies on the Spine Compiler modules.

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

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,20 @@ object CoreJvmCompiler {
6161
/**
6262
* The library with the [dogfoodingVersion].
6363
*/
64-
val pluginLib = pluginLibNew(dogfoodingVersion)
64+
val pluginLib = pluginLib(dogfoodingVersion)
6565

6666
/**
67-
* The library with the given [version].
68-
*
69-
* This is the notation before the version `2.0.0-SNAPSHOT.013`
67+
* The name of the published fat JAR artifact.
7068
*/
71-
@Deprecated("Use `pluginLibNew()` instead.")
72-
fun pluginLib(version: String): String = "$group:core-jvm-plugins:$version:all"
69+
const val fatJarArtifact = "core-jvm-plugins"
7370

7471
/**
7572
* The library with the given [version].
76-
*
77-
* @since 2.0.0-SNAPSHOT.013
78-
*/
79-
fun pluginLibNew(version: String): String = "$group:core-jvm-plugins:$version"
80-
81-
/** The artifact reference for forcing in configurations. */
82-
const val pluginsArtifact: String = "$group:core-jvm-plugins:$version"
83-
84-
/**
85-
* The `core-jvm-base` artifact with the [version].
8673
*/
87-
val base = base(version)
74+
fun pluginLib(version: String): String = "$group:core-jvm-plugins:$version"
8875

8976
/**
90-
* The `core-jvm-base` artifact with the given [version].
77+
* The artifact reference for forcing in configurations.
9178
*/
92-
fun base(version: String): String = "$group:core-jvm-base:$version"
79+
val pluginsArtifact: String = pluginLib(version)
9380
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ package io.spine.dependency.local
3333
*/
3434
@Suppress("ConstPropertyName")
3535
object TestLib {
36-
const val version = "2.0.0-SNAPSHOT.212"
36+
const val version = "2.0.0-SNAPSHOT.213"
3737
const val group = Spine.toolsGroup
3838
const val artifact = "base-testlib"
3939
const val lib = "$group:$artifact:$version"

buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,8 @@ import org.gradle.kotlin.dsl.findByType
149149
*/
150150
fun Project.spinePublishing(block: SpinePublishing.() -> Unit): SpinePublishing {
151151
apply<MavenPublishPlugin>()
152-
val name = SpinePublishing::class.java.simpleName
153-
.replaceFirstChar { it.lowercase(Locale.getDefault()) }
154152
val extension = with(extensions) {
155-
findByType<SpinePublishing>() ?: create(name, project)
153+
findByType<SpinePublishing>() ?: create(SpinePublishing.extensionName, project)
156154
}
157155
extension.run {
158156
block()
@@ -192,6 +190,12 @@ open class SpinePublishing(private val project: Project) {
192190
* to a tool module's artifact ID.
193191
*/
194192
const val NONE_PREFIX = "NONE"
193+
194+
/**
195+
* The name of the extension registered in a Gradle project.
196+
*/
197+
public val extensionName: String = SpinePublishing::class.java.simpleName
198+
.replaceFirstChar { it.lowercase(Locale.ROOT) }
195199
}
196200

197201
private val testJar = TestJar()
@@ -346,13 +350,14 @@ open class SpinePublishing(private val project: Project) {
346350
*
347351
* @see modules
348352
*/
349-
private fun projectsToPublish(): Collection<Project> {
353+
fun projectsToPublish(): Set<Project> {
350354
if (project.subprojects.isEmpty()) {
351355
return setOf(project)
352356
}
353357
return modules.union(modulesWithCustomPublishing)
354358
.map { name -> project.project(name) }
355359
.ifEmpty { setOf(project) }
360+
.toSet()
356361
}
357362

358363
/**

buildSrc/src/test/kotlin/io/spine/gradle/publish/SpinePublishingTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,9 @@ class SpinePublishingTest {
156156
// Let's use it instead of creating a second one with a different name.
157157
extension.modules = setOf("sub")
158158

159-
// Subproject's extension must be named 'SpinePublishing'
160-
// to be found by SpinePublishing::class.java.simpleName
161-
val extensionName = SpinePublishing::class.java.simpleName
162-
val subExtension = subproject.extensions.create<SpinePublishing>(extensionName, subproject)
159+
val extensionName = SpinePublishing.extensionName
160+
val subExtension =
161+
subproject.extensions.create<SpinePublishing>(extensionName, subproject)
163162

164163
val exception = shouldThrow<IllegalStateException> {
165164
subExtension.configured()

0 commit comments

Comments
 (0)