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
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#
# Therefore, instructions below are superset of instructions required for all the projects.

# Temporary output of AI agents.
.output

# `jenv` local configuration.
.java-version

Expand All @@ -55,19 +58,28 @@
!.idea/codeStyles/
!.idea/copyright/

# Ignore IDEA config files under `tests`
/tests/.idea/**

# Gradle interim configs
**/.gradle/**

# Temp directory for Gradle TestKit runners
**/.gradle-test-kit/**

# Integration test log files
/tests/_out/**

# Generated source code
**/generated/**
**/*.pb.dart
**/*.pbenum.dart
**/*.pbserver.dart
**/*.pbjson.dart

# Generated source code with custom path under `tests`
/tests/**/proto-gen/**

# Gradle build files
**/build/**
!**/src/**/build/**
Expand Down
1 change: 1 addition & 0 deletions .idea/dictionaries/common.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 1 addition & 21 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .junie/guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Guidelines for Junie and AI Agent from JetBrains

Read the `../.agents/_TOC.md` file to understand:
- the agent responsibilities,
- project overview,
- coding guidelines,
- other relevant topics.

Also follow the Junie-specific rules described below.

## Junie Assistance Tips

When working with Junie AI on the Spine Tool-Base project:

1. **Project Navigation**: Use `search_project` to find relevant files and code segments.
2. **Code Understanding**: Request file structure with `get_file_structure` before editing.
3. **Code Editing**: Make minimal changes with `search_replace` to maintain project consistency.
4. **Testing**: Verify changes with `run_test` on relevant test files.
5. **Documentation**: Follow KDoc style for documentation.
6. **Kotlin Idioms**: Prefer Kotlin-style solutions over Java-style approaches.
7. **Version Updates**: Remember to update `version.gradle.kts` for PRs.
17 changes: 15 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

/**
* This script uses two declarations of the constant [licenseReportVersion] because
* currently there is no way to define a constant _before_ a build script of `buildSrc`.
Expand Down Expand Up @@ -73,7 +75,7 @@ val grGitVersion = "4.1.1"
* This version may change from the [version of Kotlin][io.spine.dependency.lib.Kotlin.version]
* used by the project.
*/
val kotlinEmbeddedVersion = "2.1.21"
val kotlinEmbeddedVersion = "2.2.20"

/**
* The version of Guava used in `buildSrc`.
Expand Down Expand Up @@ -140,7 +142,7 @@ val koverVersion = "0.9.1"
*
* `7.1.2` is the last version compatible with Gradle 7.x. Newer versions require Gradle v8.x.
*
* @see <a href="https://github.com/johnrengelman/shadow/releases">Shadow Plugin releases</a>
* @see <a href="https://github.com/GradleUp/shadow">Shadow Plugin releases</a>
*/
val shadowVersion = "8.3.6"

Expand All @@ -158,6 +160,17 @@ configurations.all {
}
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

dependencies {
api("com.github.jk1:gradle-license-report:$licenseReportVersion")
api(platform("org.jetbrains.kotlin:kotlin-bom:$kotlinEmbeddedVersion"))
Expand Down
80 changes: 58 additions & 22 deletions buildSrc/src/main/kotlin/BuildExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ import io.spine.dependency.build.GradleDoctor
import io.spine.dependency.build.Ksp
import io.spine.dependency.build.PluginPublishPlugin
import io.spine.dependency.lib.Protobuf
import io.spine.dependency.local.Compiler
import io.spine.dependency.local.CoreJvmCompiler
import io.spine.dependency.local.McJava
import io.spine.dependency.local.ProtoData
import io.spine.dependency.local.ProtoTap
import io.spine.dependency.test.Kotest
import io.spine.dependency.test.Kover
import io.spine.gradle.repo.standardToSpineSdk
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.tasks.JavaExec
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.ScriptHandlerScope
import org.gradle.plugin.use.PluginDependenciesSpec
import org.gradle.plugin.use.PluginDependencySpec
Expand Down Expand Up @@ -79,37 +82,43 @@ fun ScriptHandlerScope.standardSpineSdkRepositories() {
val ScriptHandlerScope.protobuf: Protobuf
get() = Protobuf

/**
* Shortcut to [CoreJvmCompiler] dependency object for using under `buildScript`.
*/
val ScriptHandlerScope.coreJvmCompiler: CoreJvmCompiler
get() = CoreJvmCompiler

/**
* Shortcut to [McJava] dependency object for using under `buildScript`.
*/
val ScriptHandlerScope.mcJava: McJava
get() = McJava

/**
* Shortcut to [McJava] dependency object.
* Shortcut to [CoreJvmCompiler] dependency object.
*
* This plugin is not published to Gradle Portal and cannot be applied directly to a project.
* Firstly, it should be put to buildscript's classpath and then applied by ID only.
*/
val PluginDependenciesSpec.mcJava: McJava
get() = McJava
val PluginDependenciesSpec.coreJvmCompiler: CoreJvmCompiler
get() = CoreJvmCompiler

/**
* Shortcut to [ProtoData] dependency object for using under `buildscript`.
* Shortcut to [Compiler] dependency object for using under `buildscript`.
*/
val ScriptHandlerScope.protoData: ProtoData
get() = ProtoData
val ScriptHandlerScope.spineCompiler: Compiler
get() = Compiler

/**
* Shortcut to [ProtoData] dependency object.
* Shortcut to [Compiler] dependency object.
*
* This plugin is published at Gradle Plugin Portal.
* But when used in a pair with [mcJava], it cannot be applied directly to a project.
* It is so, because [mcJava] uses [protoData] as its dependency.
* It is so, because [mcJava] uses [spineCompiler] as its dependency.
* And the buildscript's classpath ends up with both of them.
*/
val PluginDependenciesSpec.protoData: ProtoData
get() = ProtoData
val PluginDependenciesSpec.spineCompiler: Compiler
get() = Compiler

/**
* Provides shortcuts for applying plugins from our dependency objects.
Expand Down Expand Up @@ -162,11 +171,11 @@ val PluginDependenciesSpec.`plugin-publish`: PluginDependencySpec

/**
* Configures the dependencies between third-party Gradle tasks
* and those defined via ProtoData and Spine Model Compiler.
* and those defined via the Spine Compiler and its plugins.
*
* It is required to avoid warnings in build logs, detecting the undeclared
* usage of Spine-specific task output by other tasks,
* e.g., the output of `launchProtoData` is used by `compileKotlin`.
* e.g., the output of `launchSpineCompiler` is used by `compileKotlin`.
*/
@Suppress("unused")
fun Project.configureTaskDependencies() {
Expand Down Expand Up @@ -297,31 +306,58 @@ fun Project.setRemoteDebug(taskName: String, enabled: Boolean = true) {
}

/**
* Sets remote debug options for the `launchProtoData` task.
* Sets remote debug options for the `launchSpineCompiler` task.
*
* @param enabled if `true` the task will be suspended.
*
* @see remoteDebug
*/
fun Project.protoDataRemoteDebug(enabled: Boolean = true) =
setRemoteDebug("launchProtoData", enabled)
fun Project.spineCompilerRemoteDebug(enabled: Boolean = true) =
setRemoteDebug("launchSpineCompiler", enabled)

/**
* Sets remote debug options for the `launchTestProtoData` task.
* Sets remote debug options for the `launchTestSpineCompiler` task.
*
* @param enabled if `true` the task will be suspended.
*
* @see remoteDebug
*/
fun Project.testProtoDataRemoteDebug(enabled: Boolean = true) =
setRemoteDebug("launchTestProtoData", enabled)
fun Project.testSpineCompilerRemoteDebug(enabled: Boolean = true) =
setRemoteDebug("launchTestSpineCompiler", enabled)

/**
* Sets remote debug options for the `launchTestFixturesProtoData` task.
* Sets remote debug options for the `launchTestFixturesSpineCompiler` task.
*
* @param enabled if `true` the task will be suspended.
*
* @see remoteDebug
*/
fun Project.testFixturesProtoDataRemoteDebug(enabled: Boolean = true) =
setRemoteDebug("launchTestFixturesProtoData", enabled)
fun Project.testFixturesSpineCompilerRemoteDebug(enabled: Boolean = true) =
setRemoteDebug("launchTestFixturesSpineCompiler", enabled)

/**
* Parts of names of configurations to be excluded by
* `artifactMeta/excludeConfigurations/containing` in the modules
* where `io.spine.atifact-meta` plugin is applied.
*/
val buildToolConfigurations: Array<String> = arrayOf(
"detekt",
"jacoco",
"pmd",
"checkstyle",
"checkerframework",
"ksp",
"dokka",
)

/**
* Make the `sourcesJar` task accept duplicated input which seems to occur
* somewhere inside Protobuf Gradle Plugin.
*/
fun Project.allowDuplicationInSourcesJar() {
tasks.withType(Jar::class.java).configureEach {
if (name == "sourcesJar") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}
}
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/DokkaExts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ fun DependencyHandlerScope.useDokkaWithSpineExtensions() {
private fun DependencyHandler.dokkaPlugin(dependencyNotation: Any): Dependency? =
add("dokkaPlugin", dependencyNotation)

/**
* Resolves the directory where Dokka outputs HTML documentation for the given language.
*/
internal fun Project.dokkaOutput(language: String): File {
val lng = language.titleCaseFirstChar()
return layout.buildDirectory.dir("docs/dokka$lng").get().asFile
}

/**
* Locates a Dokka configuration file under the `buildSrc` resources.
*/
fun Project.dokkaConfigFile(file: String): File {
val dokkaConfDir = project.rootDir.resolve("buildSrc/src/main/resources/dokka")
return dokkaConfDir.resolve(file)
Expand Down
16 changes: 16 additions & 0 deletions buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,19 @@ private fun ResolutionStrategy.forceWithLogging(
force(artifact)
project.log { "Forced the version of `$artifact` in " + configuration.diagSuffix(project) }
}

/**
* Obtains full Maven coordinates for the requested [module].
*
* This extension allows referencing properties of the [Dependency],
* upon which it is invoked.
*
* An example usage:
*
* ```
* // Supposing there is `Ksp.symbolProcessingApi: String` property declared.
* Ksp.artifact { symbolProcessingApi }
* ```
*/
fun <T : Dependency> T.artifact(module: T.() -> String): String =
artifact(module())
Loading
Loading