Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github-workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORMAL_GIT_HUB_PAGES_AUTHOR: developers@spine.io
# https://docs.github.com/en/actions/reference/environment-variables
REPO_SLUG: ${{ github.repository }} # e.g. SpineEventEngine/core-java
REPO_SLUG: ${{ github.repository }} # e.g. SpineEventEngine/core-jvm
GOOGLE_APPLICATION_CREDENTIALS: ./maven-publisher.json
NPM_TOKEN: ${{ secrets.NPM_SECRET }}
23 changes: 20 additions & 3 deletions buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

package io.spine.dependency.local

import io.spine.dependency.Dependency

/**
* Dependencies on the Spine Compiler modules.
*
Expand Down Expand Up @@ -56,9 +58,9 @@ package io.spine.dependency.local
"ConstPropertyName" /* We use custom convention for artifact properties. */,
"MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */,
)
object Compiler {
object Compiler : Dependency() {
const val pluginGroup = Spine.group
const val group = "io.spine.tools"
override val group = "io.spine.tools"
const val pluginId = "io.spine.compiler"

/**
Expand All @@ -69,7 +71,7 @@ object Compiler {
/**
* The version of the Compiler dependencies.
*/
val version: String
override val version: String
private const val fallbackVersion = "2.0.0-SNAPSHOT.035"

/**
Expand Down Expand Up @@ -129,6 +131,21 @@ object Compiler {
val testlib
get() = "$group:compiler-testlib:$version"

override val modules: List<String>
get() = listOf(
api,
backend,
params,
protocPlugin,
gradleApi,
cliApi,
jvm,
fatCli,
testlib
).map {
it.split(":").let { (group, artifact) -> "$group:$artifact" }
}

/**
* An env variable storing a custom [version].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object Validation {
/**
* The version of the Validation library artifacts.
*/
const val version = "2.0.0-SNAPSHOT.373"
const val version = "2.0.0-SNAPSHOT.375"

/**
* The last version of Validation compatible with ProtoData.
Expand All @@ -46,11 +46,12 @@ object Validation {
const val group = Spine.toolsGroup
private const val prefix = "validation"

const val gradlePluginLib = "$group:$prefix-gradle-plugin:$version"

const val runtimeModule = "${Spine.group}:spine-$prefix-jvm-runtime"
const val runtime = "$runtimeModule:$version"
const val javaModule = "$group:$prefix-java"
const val java = "$javaModule:$version"

const val javaBundleModule = "$group:$prefix-java-bundle"

/** Obtains the artifact for the `java-bundle` artifact of the given version. */
Expand Down
10 changes: 7 additions & 3 deletions buildSrc/src/main/kotlin/io/spine/gradle/publish/ProtoExts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ import org.gradle.api.file.SourceDirectorySet
import org.gradle.api.tasks.bundling.Jar

/**
* Tells whether there are any Proto sources in "main" source set.
* Tells whether there are any Proto sources in the "main" source set.
*/
internal fun Project.hasProto(): Boolean {
fun Project.hasProto(): Boolean {
val protoSources = protoSources()
val result = protoSources.any { it.exists() }
val result = protoSources.any {
it.exists()
&& it.isDirectory
&& it.listFiles()?.isNotEmpty() ?: false
}
return result
}

Expand Down
21 changes: 19 additions & 2 deletions buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.publish.PublicationContainer
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
Expand Down Expand Up @@ -231,7 +232,7 @@ fun TaskContainer.excludeGoogleProtoFromArtifacts() {
* Java and Kotlin sources are default to `main` source set since it is created by `java` plugin.
* For Proto sources to be included – [special treatment][protoSources] is needed.
*/
internal fun Project.sourcesJar(): TaskProvider<Jar> = tasks.getOrCreate("sourcesJar") {
fun Project.sourcesJar(): TaskProvider<Jar> = tasks.getOrCreate("sourcesJar") {
dependOnGenerateProto()
archiveClassifier.set("sources")
from(sourceSets["main"].allSource) // Puts Java and Kotlin sources.
Expand All @@ -245,7 +246,7 @@ internal fun Project.sourcesJar(): TaskProvider<Jar> = tasks.getOrCreate("source
* The output of this task is a `jar` archive. The archive contains only
* [Proto sources][protoSources] from `main` source set.
*/
internal fun Project.protoJar(): TaskProvider<Jar> = tasks.getOrCreate("protoJar") {
fun Project.protoJar(): TaskProvider<Jar> = tasks.getOrCreate("protoJar") {
dependOnGenerateProto()
archiveClassifier.set("proto")
from(protoSources())
Expand Down Expand Up @@ -317,3 +318,19 @@ internal fun Project.artifacts(jarFlags: JarFlags): Set<TaskProvider<Jar>> {

return tasks
}

/**
* Adds the source code and documentation JARs to the publication.
*/
fun MavenPublication.addSourceAndDocJars(project: Project) {
val tasks = mutableSetOf<TaskProvider<Jar>>()
tasks.add(project.sourcesJar())
tasks.add(project.javadocJar())
tasks.add(project.htmlDocsJar())
if (project.hasProto()) {
tasks.add(project.protoJar())
}
tasks.forEach {
artifact(it)
}
}