diff --git a/build.gradle b/build.gradle deleted file mode 100644 index eb44086b313..00000000000 --- a/build.gradle +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright 2020, TeamDev. All rights reserved. - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -buildscript { final scriptHandler -> - - // Applying from `version.gradle` inside the `buildscript` section to reuse the properties. - // - // As long as `buildscript` section is always evaluated first, we need to apply - // `version.gradle` explicitly here. - apply from: 'version.gradle' - apply from: "$rootDir/config/gradle/dependencies.gradle" - - defaultRepositories(scriptHandler) - dependencies { - classpath deps.build.guava - classpath deps.build.gradlePlugins.errorProne - classpath deps.build.gradlePlugins.protobuf - classpath "io.spine.tools:spine-model-compiler:$spineBaseVersion" - } - - forceConfiguration(scriptHandler) - configurations.all { - resolutionStrategy { - //noinspection GroovyAssignabilityCheck - force( - "io.spine:spine-base:$spineBaseVersion", - "io.spine:spine-time:$spineTimeVersion" - ) - } - } -} - -apply from: 'version.gradle' - -ext { - spineProtobufPluginId = 'io.spine.tools.spine-model-compiler' - - credentialsPropertyFile = 'credentials.properties' - projectsToPublish = ["core", - "client", - "server", - "testutil-core", - "testutil-client", - "testutil-server", - "model-assembler", - "model-verifier"] -} - -allprojects { - apply plugin: 'jacoco' - apply plugin: 'idea' - apply plugin: 'project-report' - - group = 'io.spine' - version = versionToPublish -} - -final boolean isTravis = System.env.TRAVIS == 'true' - -subprojects { - project.ext { - sourcesRootDir = "$projectDir/src" - generatedRootDir = "$projectDir/generated" - - generatedJavaDir = "$generatedRootDir/main/java" - generatedTestJavaDir = "$generatedRootDir/test/java" - - generatedGrpcDir = "$generatedRootDir/main/grpc" - generatedTestGrpcDir = "$generatedRootDir/test/grpc" - - generatedSpineDir = "$generatedRootDir/main/spine" - generatedTestSpineDir = "$generatedRootDir/test/spine" - - filterInternalJavadocsScript = "${rootDir}/config/gradle/filter-internal-javadoc.gradle" - } - - apply plugin: 'com.google.protobuf' - apply plugin: 'java-library' - apply plugin: 'net.ltgt.errorprone' - apply plugin: 'pmd' - apply plugin: spineProtobufPluginId - - apply from: deps.scripts.javacArgs - apply from: deps.scripts.modelCompiler - apply from: deps.scripts.projectLicenseReport - - modelCompiler { - generateValidation = true - } - - // Specific setup for a Travis build, - // which prevents appearing of warning messages in build logs. - // - // It is expected that warnings are viewed and analyzed in the local build logs. - if (isTravis) { - javadoc { - - // Set the maximum number of Javadoc warnings to print. - // - // If the parameter value is zero, all warnings will be printed. - options.addStringOption('Xmaxwarns', '1') - } - } - - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - - // Set Java home to point to JDK8 in gradle.properties file. - // - // For Mac OS X, it looks like this: - // - // # suppress inspection "UnusedProperty" - // org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/ - - defaultRepositories(project) - dependencies { - errorprone deps.build.errorProneCore - errorproneJavac deps.build.errorProneJavac - // For dependencies config. based on version of Java, see: - // https://github.com/epeee/junit-jupiter-extension-testing/blob/57b7ba75ab64ed8c229d2a5b14a954d6ae359189/gradle/errorprone.gradle - - implementation ( - deps.build.guava, - deps.build.jsr305Annotations, // See: https://github.com/SpineEventEngine/base/issues/108 - deps.build.checkerAnnotations, - deps.build.errorProneAnnotations - ) - - testImplementation ( - deps.test.hamcrest, - deps.test.guavaTestlib, - deps.test.junit5Api, - deps.test.junit5Runner, - "io.spine.tools:spine-mute-logging:$spineBaseVersion" - ) - } - - forceConfiguration(project) - configurations { - all { - resolutionStrategy { - force( - "io.spine:spine-base:$spineBaseVersion", - "io.spine:spine-time:$spineTimeVersion" - ) - } - } - // Avoid collisions of Java classes defined both in `protobuf-lite` and `protobuf-java` - runtime.exclude group: "com.google.protobuf", module: "protobuf-lite" - testRuntime.exclude group: "com.google.protobuf", module: "protobuf-lite" - } - - sourceSets { - main { - proto.srcDirs "$sourcesRootDir/main/proto" - java.srcDirs generatedJavaDir, "$sourcesRootDir/main/java", generatedSpineDir - resources.srcDirs "$generatedRootDir/main/resources" - } - test { - proto.srcDirs "$sourcesRootDir/test/proto" - java.srcDirs generatedTestJavaDir, "$sourcesRootDir/test/java", generatedTestSpineDir - resources.srcDirs "$generatedRootDir/test/resources" - } - } - - test { - useJUnitPlatform { - includeEngines 'junit-jupiter' - } - } - - apply from: deps.scripts.slowTests - apply from: deps.scripts.testOutput - apply from: deps.scripts.javadocOptions - - task sourceJar(type: Jar) { - from sourceSets.main.allJava - archiveClassifier.set("sources") - } - - task testOutputJar(type: Jar) { - from sourceSets.test.output - archiveClassifier.set("test") - } - - task javadocJar(type: Jar, dependsOn: 'javadoc') { - from ("$projectDir/build/docs/javadoc") - archiveClassifier.set("javadoc") - } - - // Apply the same IDEA module configuration for each of sub-projects. - idea { - module { - generatedSourceDirs += file(generatedJavaDir) - generatedSourceDirs += file(generatedGrpcDir) - generatedSourceDirs += file(generatedSpineDir) - generatedSourceDirs += file(generatedTestJavaDir) - generatedSourceDirs += file(generatedTestGrpcDir) - generatedSourceDirs += file(generatedTestSpineDir) - - testSourceDirs += file(generatedTestJavaDir) - - downloadJavadoc = true - downloadSources = true - - iml { - beforeMerged { final module -> - module.dependencies.clear() - } - whenMerged { final module -> - module.dependencies*.exported = true - } - } - } - } - - /** - * Determines whether the given {@code project} should expose its Javadoc to - * SpineEventEngine.github.io website. - * - *

Currently, the {@code testutil} projects are excluded from publishing, as well as the modules - * that perform the model compile-time checks. - * - * @param project the project to check - * @return {@code true} is the project Javadoc should be published, {@code false} otherwise - */ - ext.shouldPublishJavadoc = { - return !project.name.startsWith('testutil') && !project.name.startsWith("model") - } - - // Apply the Javadoc publishing plugin. - // This plugin *must* be applied here, not in the module `build.gradle` files. - // - if (shouldPublishJavadoc()) { - apply from: deps.scripts.updateGitHubPages - afterEvaluate { - tasks.publish.dependsOn('updateGitHubPages') - } - } - - apply from: deps.scripts.pmd -} - -apply from: deps.scripts.publish - -// IDEA project configuration. -idea { - project { - ipr { - beforeMerged { final project -> - project.modulePaths.clear() - } - withXml { final provider -> - provider.node.component - .find { it.@name == 'VcsDirectoryMappings' } - .mapping.@vcs = 'Git' - } - } - } -} - -// Aggregated coverage report across all subprojects. -apply from: deps.scripts.jacoco - -// Generate a repository-wide report of 3rd-party dependencies and their licenses. -apply from: deps.scripts.repoLicenseReport - -// Generate a `pom.xml` file containing first-level dependency of all projects in the repository. -apply from: deps.scripts.generatePom diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000000..7e3807beb74 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,258 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import io.spine.gradle.internal.DependencyResolution +import io.spine.gradle.internal.Deps +import io.spine.gradle.internal.PublishingRepos + +buildscript { + + apply(from = "version.gradle.kts") + apply(from = "$rootDir/config/gradle/dependencies.gradle") + + @Suppress("RemoveRedundantQualifierName") // Cannot use imports here. + val dependencyResolution = io.spine.gradle.internal.DependencyResolution + + val spineBaseVersion: String by extra + val spineTimeVersion: String by extra + + dependencyResolution.defaultRepositories(repositories) + dependencies { + classpath("io.spine.tools:spine-model-compiler:$spineBaseVersion") + } + + dependencyResolution.forceConfiguration(configurations) + + configurations.all { + resolutionStrategy { + force( + "io.spine:spine-base:$spineBaseVersion", + "io.spine:spine-time:$spineTimeVersion" + ) + } + } +} + +plugins { + java + idea + @Suppress("RemoveRedundantQualifierName") // Cannot use imports here. + id("com.google.protobuf").version(io.spine.gradle.internal.Deps.versions.protobufPlugin) + @Suppress("RemoveRedundantQualifierName") // Cannot use imports here. + id("net.ltgt.errorprone").version(io.spine.gradle.internal.Deps.versions.errorPronePlugin) +} + +apply(from = "version.gradle.kts") +val spineBaseVersion: String by extra +val spineTimeVersion: String by extra + +extra["projectsToPublish"] = listOf( + "core", + "client", + "server", + "testutil-core", + "testutil-client", + "testutil-server", + "model-assembler", + "model-verifier" +) +extra["credentialsPropertyFile"] = PublishingRepos.cloudRepo.credentials + +allprojects { + apply { + plugin("jacoco") + plugin("idea") + plugin("project-report") + + from("$rootDir/version.gradle.kts") + } + + group = "io.spine" + version = extra["versionToPublish"]!! +} + +subprojects { + + apply { + plugin("java-library") + plugin("com.google.protobuf") + plugin("net.ltgt.errorprone") + plugin("pmd") + plugin("io.spine.tools.spine-model-compiler") + + from(Deps.scripts.javacArgs(project)) + from(Deps.scripts.modelCompiler(project)) + from(Deps.scripts.projectLicenseReport(project)) + } + + extensions["modelCompiler"].withGroovyBuilder { + setProperty("generateValidation", true) + } + + val isTravis = System.getenv("TRAVIS") == "true" + if (isTravis) { + tasks.javadoc { + val opt = options + if (opt is CoreJavadocOptions) { + opt.addStringOption("Xmaxwarns", "1") + } + } + } + + java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + DependencyResolution.defaultRepositories(repositories) + + dependencies { + errorprone(Deps.build.errorProneCore) + errorproneJavac(Deps.build.errorProneJavac) + + implementation(Deps.build.guava) + implementation(Deps.build.jsr305Annotations) + implementation(Deps.build.checkerAnnotations) + Deps.build.errorProneAnnotations.forEach { implementation(it) } + + testImplementation(Deps.test.guavaTestlib) + Deps.test.junit5Api.forEach { testImplementation(it) } + testImplementation(Deps.test.junit5Runner) + testImplementation("io.spine.tools:spine-mute-logging:$spineBaseVersion") + } + + DependencyResolution.forceConfiguration(configurations) + configurations { + all { + resolutionStrategy { + force( + "io.spine:spine-base:$spineBaseVersion", + "io.spine:spine-time:$spineTimeVersion" + ) + } + } + } + DependencyResolution.excludeProtobufLite(configurations) + + val sourcesRootDir = "$projectDir/src" + val generatedRootDir = "$projectDir/generated" + val generatedJavaDir = "$generatedRootDir/main/java" + val generatedTestJavaDir = "$generatedRootDir/test/java" + val generatedGrpcDir = "$generatedRootDir/main/grpc" + val generatedTestGrpcDir = "$generatedRootDir/test/grpc" + val generatedSpineDir = "$generatedRootDir/main/spine" + val generatedTestSpineDir = "$generatedRootDir/test/spine" + + sourceSets { + main { + java.srcDirs(generatedJavaDir, "$sourcesRootDir/main/java", generatedSpineDir) + resources.srcDirs("$sourcesRootDir/main/resources", "$generatedRootDir/main/resources") + proto.srcDirs("$sourcesRootDir/main/proto") + } + test { + java.srcDirs(generatedTestJavaDir, "$sourcesRootDir/test/java", generatedTestSpineDir) + resources.srcDirs("$sourcesRootDir/test/resources", "$generatedRootDir/test/resources") + proto.srcDirs("$sourcesRootDir/test/proto") + } + } + + tasks.test { + useJUnitPlatform { + includeEngines("junit-jupiter") + } + } + + apply { + from(Deps.scripts.slowTests(project)) + from(Deps.scripts.testOutput(project)) + from(Deps.scripts.javadocOptions(project)) + } + + tasks.register("sourceJar", Jar::class) { + from(sourceSets.main.get().allJava) + archiveClassifier.set("sources") + } + + tasks.register("testOutputJar", Jar::class) { + from(sourceSets.test.get().output) + archiveClassifier.set("test") + } + + tasks.register("javadocJar", Jar::class) { + from("$projectDir/build/docs/javadoc") + archiveClassifier.set("javadoc") + + dependsOn(tasks.javadoc) + } + + idea { + module { + generatedSourceDirs.addAll(files( + generatedJavaDir, + generatedGrpcDir, + generatedSpineDir, + generatedTestJavaDir, + generatedTestGrpcDir, + generatedTestSpineDir + )) + + testSourceDirs.add(file(generatedTestJavaDir)) + + isDownloadJavadoc = true + isDownloadSources = true + } + } + + /** + * Determines whether this project should expose its Javadoc to `SpineEventEngine.github.io` + * website. + * + * Currently, the `testutil` projects are excluded from publishing, as well as the modules + * that perform the model compile-time checks. + * + * @return `true` is the project Javadoc should be published, `false` otherwise + */ + fun shouldPublishJavadoc() = + !project.name.startsWith("testutil") && + !project.name.startsWith("model") + + // Apply the Javadoc publishing plugin. + // This plugin *must* be applied here, not in the module `build.gradle` files. + // + if (shouldPublishJavadoc()) { + apply(from = Deps.scripts.updateGitHubPages(project)) + afterEvaluate { + tasks.getByName("publish").dependsOn("updateGitHubPages") + } + } + + apply(from = Deps.scripts.pmd(project)) +} + +apply { + from(Deps.scripts.publish(project)) + + // Aggregated coverage report across all subprojects. + from(Deps.scripts.jacoco(project)) + // Generate a repository-wide report of 3rd-party dependencies and their licenses. + from(Deps.scripts.repoLicenseReport(project)) + // Generate a `pom.xml` file containing first-level dependency of all projects in the repository. + from(Deps.scripts.generatePom(project)) +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index bdfd32a6d6c..7dc929afcaa 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -19,6 +19,8 @@ */ plugins { + // Use Kotlin for `buildSrc`. + // https://kotlinlang.org/docs/reference/using-gradle.html#targeting-the-jvm kotlin("jvm").version("1.3.72") } @@ -26,3 +28,9 @@ repositories { mavenLocal() jcenter() } + +val jacksonVersion = "2.11.0" + +dependencies { + implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion") +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/internal/CheckVersionIncrement.kt b/buildSrc/src/main/kotlin/io/spine/gradle/internal/CheckVersionIncrement.kt new file mode 100644 index 00000000000..60709874e88 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/internal/CheckVersionIncrement.kt @@ -0,0 +1,104 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.gradle.internal + +import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES +import com.fasterxml.jackson.dataformat.xml.XmlMapper +import org.gradle.api.GradleException +import org.gradle.api.Project +import org.gradle.api.internal.AbstractTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import java.net.URL + +/** + * A task which verifies that the current version of the library has not been published to the given + * Maven repository yet. + */ +open class CheckVersionIncrement : AbstractTask() { + + /** + * The Maven repository in which to look for published artifacts. + * + * We only check the `releases` repository. Artifacts in `snapshots` repository still may be + * overridden. + */ + @Input + lateinit var repository: Repository + + @Input + private val version: String = project.version as String + + @TaskAction + private fun fetchAndCheck() { + val artifact = "${project.artifactPath()}/${MavenMetadata.FILE_NAME}" + val repoUrl = repository.releases + val metadata = fetch(repoUrl, artifact) + val versions = metadata.versioning.versions + val versionExists = versions.contains(version) + if (versionExists) { + throw GradleException(""" + Version `$version` is already published to maven repository `$repoUrl`. + Try incrementing the library version. + All available versions are: ${versions.joinToString(separator = ", ")}. + + To disable this check, run Gradle with `-x $name`. + """.trimIndent() + ) + } + } + + private fun fetch(repository: String, artifact: String): MavenMetadata { + val url = URL("$repository/$artifact") + return MavenMetadata.fetchAndParse(url) + } + + private fun Project.artifactPath(): String { + val group = this.group as String + val name = "spine-${this.name}" + + val pathElements = ArrayList(group.split('.')) + pathElements.add(name) + val path = pathElements.joinToString(separator = "/") + return path + } +} + +private data class MavenMetadata(var versioning: Versioning = Versioning()) { + + companion object { + + const val FILE_NAME = "maven-metadata.xml" + + private val mapper = XmlMapper() + + init { + mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false) + } + + fun fetchAndParse(url: URL): MavenMetadata { + val metadata = mapper.readValue(url, MavenMetadata::class.java) + return metadata + } + } +} + +private data class Versioning(var versions: List = listOf()) diff --git a/version.gradle b/buildSrc/src/main/kotlin/io/spine/gradle/internal/IncrementGuard.kt similarity index 60% rename from version.gradle rename to buildSrc/src/main/kotlin/io/spine/gradle/internal/IncrementGuard.kt index 5f1ce10bbe1..c227f49889f 100644 --- a/version.gradle +++ b/buildSrc/src/main/kotlin/io/spine/gradle/internal/IncrementGuard.kt @@ -18,22 +18,29 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +package io.spine.gradle.internal + +import org.gradle.api.Plugin +import org.gradle.api.Project + /** - * The versions of the libraries used. + * Gradle plugin which adds a [CheckVersionIncrement] task. * - * This file is used in both module `build.gradle` scripts and in the integration tests, - * as we want to manage the versions in a single source. + * The task is called `checkVersionIncrement` inserted before the `check` task. */ +class IncrementGuard : Plugin { -final def spineVersion = '1.5.13' - -ext { - // The version of the modules in this project. - versionToPublish = spineVersion + companion object { + const val taskName = "checkVersionIncrement" + } - // Depend on `base` for the general definitions and a model compiler. - spineBaseVersion = '1.5.10' + override fun apply(target: Project) { + val tasks = target.tasks + tasks.register(taskName, CheckVersionIncrement::class.java) { + it.repository = PublishingRepos.cloudRepo + tasks.getByName("check").dependsOn(it) - // Depend on `time` for `ZoneId`, `ZoneOffset` and other date/time types and utilities. - spineTimeVersion = '1.5.8' + it.shouldRunAfter("test") + } + } } diff --git a/client/build.gradle b/client/build.gradle.kts similarity index 67% rename from client/build.gradle rename to client/build.gradle.kts index 928f5dbc2b3..190c0928271 100644 --- a/client/build.gradle +++ b/client/build.gradle.kts @@ -18,19 +18,23 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import io.spine.gradle.internal.Deps + +val spineBaseVersion: String by extra + dependencies { - api deps.grpc.grpcStub - api project(':core') - implementation( - deps.grpc.grpcProtobuf, - deps.grpc.grpcCore - ) - testImplementation( - "io.spine:spine-testlib:$spineBaseVersion", - project(':testutil-client'), - project(path: ':core', configuration: 'testArtifacts') - ) + api(Deps.grpc.stub) + api(project(":core")) + + implementation(Deps.grpc.protobuf) + implementation(Deps.grpc.core) + + testImplementation("io.spine:spine-testlib:$spineBaseVersion") + testImplementation(project(":testutil-client")) + testImplementation(project(path = ":core", configuration = "testArtifacts")) } -apply from: deps.scripts.testArtifacts -apply from: deps.scripts.publishProto +apply { + from(Deps.scripts.testArtifacts(project)) + from(Deps.scripts.publishProto(project)) +} diff --git a/config b/config index 5ffcb1a8dbe..d9223f98f58 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 5ffcb1a8dbe4b9f14aacb9ecf663c5e639eac4b5 +Subproject commit d9223f98f58cca6a6c91d3339f0fa6c366e3a00c diff --git a/core/build.gradle b/core/build.gradle.kts similarity index 66% rename from core/build.gradle rename to core/build.gradle.kts index ecf65432b7a..e9b9a5f13a5 100644 --- a/core/build.gradle +++ b/core/build.gradle.kts @@ -18,25 +18,34 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import io.spine.gradle.internal.Deps +import io.spine.gradle.internal.IncrementGuard + +val spineBaseVersion: String by extra +val spineTimeVersion: String by extra + dependencies { - api "io.spine:spine-base:$spineBaseVersion" - api "io.spine:spine-time:$spineTimeVersion" + api("io.spine:spine-base:$spineBaseVersion") + api("io.spine:spine-time:$spineTimeVersion") - testImplementation project(path: ":testutil-core") - testImplementation "io.spine:spine-testutil-time:$spineTimeVersion" + testImplementation(project(":testutil-core")) + testImplementation("io.spine:spine-testutil-time:$spineTimeVersion") } modelCompiler { fields { // Enable the strongly-typed fields generation for `spine.core.Event` as currently it's // a subscribable entity state. - generateFor "spine.core.Event", markAs("io.spine.base.EntityStateField") + generateFor("spine.core.Event", markAs("io.spine.base.EntityStateField")) // Enable the strongly-typed fields generation for `spine.core.EventContext` to allow // creation of typed event filters based on event context. - generateFor "spine.core.EventContext", markAs("io.spine.core.EventContextField") + generateFor("spine.core.EventContext", markAs("io.spine.core.EventContextField")) } } -apply from: deps.scripts.testArtifacts -apply from: deps.scripts.publishProto +apply { + from(Deps.scripts.testArtifacts(project)) + from(Deps.scripts.publishProto(project)) + plugin(IncrementGuard::class) +} diff --git a/core/src/main/proto/spine/core/response.proto b/core/src/main/proto/spine/core/response.proto index 8838a31d48f..a13b3357541 100644 --- a/core/src/main/proto/spine/core/response.proto +++ b/core/src/main/proto/spine/core/response.proto @@ -29,7 +29,6 @@ option java_multiple_files = true; option java_outer_classname = "ResponseProto"; import "google/protobuf/empty.proto"; -import "google/protobuf/any.proto"; import "spine/base/error.proto"; import "spine/core/event.proto"; diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f3d88b1c2fa..490fda8577d 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4b4429748d..a4f0001d203 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/license-report.md b/license-report.md index 21c373d5a2b..6fcb012b680 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.5.12` +# Dependencies of `io.spine:spine-client:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -405,12 +405,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:10 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:11:30 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-core:1.5.12` +# Dependencies of `io.spine:spine-core:1.5.14` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -775,12 +775,12 @@ This report was generated on **Sat May 23 10:33:10 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:11 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:11:38 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-assembler:1.5.12` +# Dependencies of `io.spine.tools:spine-model-assembler:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1180,12 +1180,12 @@ This report was generated on **Sat May 23 10:33:11 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:11 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:12:07 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-verifier:1.5.12` +# Dependencies of `io.spine.tools:spine-model-verifier:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1645,12 +1645,12 @@ This report was generated on **Sat May 23 10:33:11 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:12 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:12:22 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-server:1.5.12` +# Dependencies of `io.spine:spine-server:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2067,12 +2067,12 @@ This report was generated on **Sat May 23 10:33:12 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:12 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:13:27 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-client:1.5.12` +# Dependencies of `io.spine:spine-testutil-client:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2526,12 +2526,12 @@ This report was generated on **Sat May 23 10:33:12 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:14 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:13:33 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-core:1.5.12` +# Dependencies of `io.spine:spine-testutil-core:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2993,12 +2993,12 @@ This report was generated on **Sat May 23 10:33:14 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:15 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri May 29 20:13:36 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-server:1.5.12` +# Dependencies of `io.spine:spine-testutil-server:1.5.14` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3496,4 +3496,4 @@ This report was generated on **Sat May 23 10:33:15 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat May 23 10:33:18 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Fri May 29 20:13:47 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/model/README.MD b/model/README.MD index ea96729b6a0..147cb25da7f 100644 --- a/model/README.MD +++ b/model/README.MD @@ -4,21 +4,21 @@ This directory contains modules that implement compile time verification of the To enable the verification in a project, apply the following Gradle config to subprojects that may contain _Spine model elements_: - ```groovy + ```kotlin buildscript { dependencies { - classpath "io.spine.tools:spine-model-verifier:${spineVersion}" + classpath("io.spine.tools:spine-model-verifier:${spineVersion}") } } - apply plugin: 'io.spine.tools.spine-model-verifier' + apply(plugin = "io.spine.tools.spine-model-verifier") - compileJava { - options.compilerArgs += ["-processor", "io.spine.model.assemble.AssignLookup", "-AspineDirRoot=${rootDir}"] + tasks.compileJava { + options.compilerArgs.addAll(listOf("-processor", "io.spine.model.assemble.AssignLookup", "-AspineDirRoot=${rootDir}")) } dependencies { - annotationProcessor group: 'io.spine.tools', name: 'spine-model-assembler', version: spineVersion + annotationProcessor(group = "io.spine.tools", name = "spine-model-assembler", version = spineVersion) } ``` The _Spine model elements_ are Java and Protobuf declarations of Entities and the messages handled (i.e. `Command`s, `Event`s and `Rejection`s). diff --git a/model/model-assembler/build.gradle b/model/model-assembler/build.gradle.kts similarity index 82% rename from model/model-assembler/build.gradle rename to model/model-assembler/build.gradle.kts index 1a59ea48478..c92190fe38b 100644 --- a/model/model-assembler/build.gradle +++ b/model/model-assembler/build.gradle.kts @@ -19,13 +19,15 @@ */ buildscript { - apply from: "$rootDir/version.gradle" + apply(from = "$rootDir/version.gradle.kts") } -group 'io.spine.tools' +group = "io.spine.tools" + +val spineBaseVersion: String by extra dependencies { - implementation project(':server') + implementation(project(":server")) - testImplementation "io.spine:spine-testlib:$spineBaseVersion" + testImplementation("io.spine:spine-testlib:$spineBaseVersion") } diff --git a/model/model-verifier/build.gradle b/model/model-verifier/build.gradle deleted file mode 100644 index 9524df38469..00000000000 --- a/model/model-verifier/build.gradle +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020, TeamDev. All rights reserved. - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -buildscript { - apply from: "$rootDir/version.gradle" -} - -group 'io.spine.tools' - -sourceSets { - main { - resources.srcDirs "$sourcesRootDir/main/resources" - } - test { - resources.srcDirs "$sourcesRootDir/test/resources" - } -} - -dependencies { - implementation gradleApi() - implementation "io.spine.tools:spine-plugin-base:$spineBaseVersion" - implementation "io.spine.tools:spine-model-compiler:$spineBaseVersion" - implementation project(':server') - implementation project(':model-assembler') - - testImplementation gradleTestKit() - testImplementation "io.spine:spine-testlib:$spineBaseVersion" - testImplementation "io.spine.tools:spine-plugin-testlib:$spineBaseVersion" - testImplementation deps.test.junitPioneer - testImplementation project(":testutil-server") -} - -test { - dependsOn publishToMavenLocal - dependsOn project(':core').publishToMavenLocal - dependsOn project(':client').publishToMavenLocal - dependsOn project(':server').publishToMavenLocal - dependsOn project(':model-assembler').publishToMavenLocal -} diff --git a/model/model-verifier/build.gradle.kts b/model/model-verifier/build.gradle.kts new file mode 100644 index 00000000000..e11e272cd97 --- /dev/null +++ b/model/model-verifier/build.gradle.kts @@ -0,0 +1,51 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import io.spine.gradle.internal.Deps + +buildscript { + apply(from = "$rootDir/version.gradle.kts") +} + +group = "io.spine.tools" + +val spineBaseVersion: String by extra + +dependencies { + implementation(gradleApi()) + implementation("io.spine.tools:spine-plugin-base:$spineBaseVersion") + implementation("io.spine.tools:spine-model-compiler:$spineBaseVersion") + implementation(project(":server")) + implementation(project(":model-assembler")) + + testImplementation(gradleTestKit()) + testImplementation("io.spine:spine-testlib:$spineBaseVersion") + testImplementation("io.spine.tools:spine-plugin-testlib:$spineBaseVersion") + testImplementation(Deps.test.junitPioneer) + testImplementation(project(":testutil-server")) +} + +tasks.test { + dependsOn("publishToMavenLocal", + ":core:publishToMavenLocal", + ":client:publishToMavenLocal", + ":server:publishToMavenLocal", + ":model-assembler:publishToMavenLocal") +} diff --git a/model/model-verifier/src/main/java/io/spine/model/verify/ModelVerifierPlugin.java b/model/model-verifier/src/main/java/io/spine/model/verify/ModelVerifierPlugin.java index 1d925ffdd21..78a3f963877 100644 --- a/model/model-verifier/src/main/java/io/spine/model/verify/ModelVerifierPlugin.java +++ b/model/model-verifier/src/main/java/io/spine/model/verify/ModelVerifierPlugin.java @@ -69,7 +69,6 @@ private void createTask(Path rawModelStorage, Project project) { newTask(verifyModel, action(rawModelStorage)) .insertBeforeTask(classes) .insertAfterTask(compileJava) - .withInputFiles(project.fileTree(rawModelStorage)) .applyNowTo(project); } diff --git a/model/model-verifier/src/test/java/io/spine/model/verify/ModelVerifierPluginTest.java b/model/model-verifier/src/test/java/io/spine/model/verify/ModelVerifierPluginTest.java index 2e96d5da6a1..2af896cd784 100644 --- a/model/model-verifier/src/test/java/io/spine/model/verify/ModelVerifierPluginTest.java +++ b/model/model-verifier/src/test/java/io/spine/model/verify/ModelVerifierPluginTest.java @@ -79,10 +79,11 @@ void passValidModelClasses() { @MuteLogging @DisplayName("halt build on duplicate command handling methods") void rejectDuplicateHandlingMethods() { - BuildResult result = newProjectWithJava( + GradleProject project = newProjectWithJava( "io/spine/model/verify/DuplicateAggregate.java", - "io/spine/model/verify/DuplicateCommandHandler.java") - .executeAndFail(verifyModel); + "io/spine/model/verify/DuplicateCommandHandler.java" + ); + BuildResult result = project.executeAndFail(verifyModel); BuildTask task = result.task(toPath(verifyModel)); assertNotNull(task, result.getOutput()); TaskOutcome generationResult = task.getOutcome(); diff --git a/model/model-verifier/src/test/resources/build.gradle b/model/model-verifier/src/test/resources/build.gradle deleted file mode 100644 index 00cdfd017fc..00000000000 --- a/model/model-verifier/src/test/resources/build.gradle +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2020, TeamDev. All rights reserved. - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Common build file for the tests with same configuration - -buildscript { - - // Apply the script created by `io.spine.tools.gradle.testing.TestEnvGradle`. - // - // The script defines `enclosingRootDir` variable that we use below. - // - apply from: "$rootDir/test-env.gradle" - - // Apply shared dependencies. - apply from: "$enclosingRootDir/config/gradle/dependencies.gradle" - - // Applying from `version.gradle` inside the `buildscript` section to reuse the properties. - // - // As long as `buildscript` section is always evaluated first, we need to apply - // `version.gradle` explicitly here. - // - apply from: "$enclosingRootDir/version.gradle" - - repositories { - mavenLocal() - maven { - url = repos.spine - content { - includeGroup 'io.spine' - includeGroup 'io.spine.tools' - } - mavenContent { - releasesOnly() - } - } - maven { - url = repos.spineSnapshots - content { - includeGroup 'io.spine' - includeGroup 'io.spine.tools' - } - mavenContent { - snapshotsOnly() - } - } - jcenter() - } - - dependencies { - classpath deps.build.protobuf - classpath deps.build.gradlePlugins.protobuf - classpath "io.spine.tools:spine-model-compiler:${spineBaseVersion}" - classpath "io.spine.tools:spine-model-verifier:${versionToPublish}" - } - - configurations.all({ - resolutionStrategy.cacheChangingModulesFor(0, 'seconds') - }) -} - -apply plugin: 'java' -apply plugin: 'com.google.protobuf' -apply plugin: 'io.spine.tools.spine-model-compiler' -apply plugin: 'io.spine.tools.spine-model-verifier' - -// NOTE: this file is copied from the root project in the test setup. -apply from: "$enclosingRootDir/version.gradle" -apply from: "$enclosingRootDir/config/gradle/model-compiler.gradle" - -repositories { - mavenLocal() - maven { - url = repos.spine - content { - includeGroup 'io.spine' - includeGroup 'io.spine.tools' - } - mavenContent { - releasesOnly() - } - } - maven { - url = repos.spineSnapshots - content { - includeGroup 'io.spine' - includeGroup 'io.spine.tools' - } - mavenContent { - snapshotsOnly() - } - } - jcenter() -} - -compileJava { - options.compilerArgs += ["-processor", "io.spine.model.assemble.AssignLookup", "-AspineDirRoot=${rootDir}"] -} - -dependencies { - implementation deps.build.protobuf - implementation "io.spine:spine-server:$versionToPublish" - - annotationProcessor "io.spine.tools:spine-model-assembler:$versionToPublish" -} - -sourceSets { - main { - proto.srcDirs += ["$projectDir/src/main/proto"] - java.srcDirs += ["$projectDir/generated/main/java", - "$projectDir/generated/main/spine"] - resources.srcDirs += ["$projectDir/generated/main/resources"] - } -} diff --git a/model/model-verifier/src/test/resources/build.gradle.kts b/model/model-verifier/src/test/resources/build.gradle.kts new file mode 100644 index 00000000000..51122046395 --- /dev/null +++ b/model/model-verifier/src/test/resources/build.gradle.kts @@ -0,0 +1,102 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import io.spine.gradle.internal.DependencyResolution +import io.spine.gradle.internal.Deps +import org.gradle.api.file.SourceDirectorySet + +buildscript { + + // Apply the script created by `io.spine.tools.gradle.testing.TestEnvGradle`. + // + // The script defines `enclosingRootDir` variable that we use below. + // + apply(from = "$rootDir/test-env.gradle") + + val enclosingRootDir: String by extra + + // Apply shared dependencies. + apply(from = "$enclosingRootDir/config/gradle/dependencies.gradle") + + // Applying from `version.gradle.kts` inside the `buildscript` section to reuse the properties. + // + // As long as `buildscript` section is always evaluated first, we need to apply + // `version.gradle.kts` explicitly here. + // + apply(from = "$enclosingRootDir/version.gradle.kts") + + val spineBaseVersion: String by extra + val versionToPublish: String by extra + + @Suppress("RemoveRedundantQualifierName") // Cannot use imports here. + val dependencyResolution = io.spine.gradle.internal.DependencyResolution + dependencyResolution.defaultRepositories(repositories) + + @Suppress("RemoveRedundantQualifierName") // Cannot use imports here. + val deps = io.spine.gradle.internal.Deps + + dependencies { + classpath(deps.build.gradlePlugins.protobuf) + classpath("io.spine.tools:spine-model-compiler:${spineBaseVersion}") + classpath("io.spine.tools:spine-model-verifier:${versionToPublish}") + } +} + +plugins { + java +} + +apply(from = "$rootDir/test-env.gradle") +val enclosingRootDir: String by extra + +apply(from = "$enclosingRootDir/version.gradle.kts") +val spineBaseVersion: String by extra +val versionToPublish: String by extra + +apply { + plugin("com.google.protobuf") + plugin("io.spine.tools.spine-model-compiler") + plugin("io.spine.tools.spine-model-verifier") + from("$enclosingRootDir/version.gradle.kts") + from("$enclosingRootDir/config/gradle/model-compiler.gradle") +} + +DependencyResolution.defaultRepositories(repositories) + +tasks.compileJava { + options.compilerArgs.addAll(listOf("-processor", + "io.spine.model.assemble.AssignLookup", + "-AspineDirRoot=${rootDir}")) +} + +dependencies { + Deps.build.protobuf.forEach { implementation(it) } + implementation("io.spine:spine-server:$versionToPublish") + + annotationProcessor("io.spine.tools:spine-model-assembler:$versionToPublish") +} + +sourceSets { + main { + java.srcDirs("$projectDir/generated/main/java", "$projectDir/generated/main/spine") + resources.srcDirs("$projectDir/generated/main/resources") + (extensions["proto"] as SourceDirectorySet).srcDirs("$projectDir/src/main/proto") + } +} diff --git a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateAggregate.java b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateAggregate.java index 7c1b2758daf..2a12d650cfd 100644 --- a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateAggregate.java +++ b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateAggregate.java @@ -30,21 +30,21 @@ public class DuplicateAggregate extends Aggregate { @Assign - public MessageSent handle(SendMessage command) { + MessageSent handle(SendMessage command) { return MessageSent.newBuilder() .setMessage(command.getMessage()) .build(); } @Assign - public List on(StartVideoCall command) { + List on(StartVideoCall command) { return singletonList(VideoCallStarted.newBuilder() .setIp(command.getIp()) .build()); } @Assign - public VideoCallStarted oneMore(StartVideoCall cmd) { + VideoCallStarted oneMore(StartVideoCall cmd) { // NoOp for test return VideoCallStarted.getDefaultInstance(); } diff --git a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateCommandHandler.java b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateCommandHandler.java index 8086b643c75..19f0b551a18 100644 --- a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateCommandHandler.java +++ b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/DuplicateCommandHandler.java @@ -29,14 +29,14 @@ public class DuplicateCommandHandler extends Aggregate { @Assign - public Iterable handle(SendLink command) { + Iterable handle(SendLink command) { return singletonList(LinkSent.newBuilder() .setLink(command.getLink()) .build()); } @Assign - public MessageSent onCommandAny(SendMessage command) { + MessageSent onCommandAny(SendMessage command) { return MessageSent.newBuilder() .setMessage(command.getMessage()) .build(); diff --git a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/MalformedAggregate.java b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/MalformedAggregate.java index a94cea1cfed..6adc3ddadb9 100644 --- a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/MalformedAggregate.java +++ b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/MalformedAggregate.java @@ -40,7 +40,7 @@ protected MalformedAggregate(String id) { } @Assign - public List handle() { + List handle() { return Collections.emptyList(); } } diff --git a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/ValidCommandHandler.java b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/ValidCommandHandler.java index e7416088377..0f9441d9d3c 100644 --- a/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/ValidCommandHandler.java +++ b/model/model-verifier/src/test/resources/model-verifier-test/src/main/java/io/spine/model/verify/ValidCommandHandler.java @@ -34,7 +34,7 @@ public class ValidCommandHandler extends AbstractCommandHandler { @Assign - public List handle(SendLink command) { + List handle(SendLink command) { return singletonList(LinkSent.newBuilder() .setLink(command.getLink()) .build()); diff --git a/pom.xml b/pom.xml index 8fb34d94dc4..5889a5e07ee 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.5.13 +1.5.14 2015 @@ -70,25 +70,25 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base - 1.5.10 + 1.5.12 compile io.spine spine-time - 1.5.8 + 1.5.12 compile io.spine.tools spine-model-compiler - 1.5.10 + 1.5.12 compile io.spine.tools spine-plugin-base - 1.5.10 + 1.5.12 compile @@ -130,25 +130,25 @@ all modules and does not describe the project structure per-subproject. io.spine spine-testlib - 1.5.10 + 1.5.12 test io.spine spine-testutil-time - 1.5.8 + 1.5.12 test io.spine.tools spine-mute-logging - 1.5.10 + 1.5.12 test io.spine.tools spine-plugin-testlib - 1.5.10 + 1.5.12 test @@ -157,12 +157,6 @@ all modules and does not describe the project structure per-subproject. 1.1.0 test - - org.hamcrest - hamcrest-all - 1.3 - test - org.junit-pioneer junit-pioneer @@ -210,12 +204,12 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-javadoc-filter - 1.5.10 + 1.5.12 io.spine.tools spine-protoc-plugin - 1.5.10 + 1.5.12 net.sourceforge.pmd diff --git a/server/build.gradle b/server/build.gradle.kts similarity index 59% rename from server/build.gradle rename to server/build.gradle.kts index c4352ef1257..dc8d6f633da 100644 --- a/server/build.gradle +++ b/server/build.gradle.kts @@ -18,33 +18,37 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import io.spine.gradle.internal.Deps + +val spineBaseVersion: String by extra + dependencies { - api project(':client') - implementation( - deps.grpc.grpcProtobuf, - deps.grpc.grpcCore - ) - testAnnotationProcessor deps.build.autoService.processor - testCompileOnly deps.build.autoService.annotations - testImplementation( - deps.grpc.grpcNettyShaded, - "io.spine:spine-testlib:$spineBaseVersion", - project(path: ':core', configuration: 'testArtifacts'), - project(path: ':client', configuration: 'testArtifacts'), - project(':testutil-server') - ) + api(project(":client")) + + implementation(Deps.grpc.protobuf) + implementation(Deps.grpc.core) + + testAnnotationProcessor(Deps.build.autoService.processor) + testCompileOnly(Deps.build.autoService.annotations) + testImplementation(Deps.grpc.nettyShaded) + testImplementation("io.spine:spine-testlib:$spineBaseVersion") + testImplementation(project(path = ":core", configuration = "testArtifacts")) + testImplementation(project(path = ":client", configuration = "testArtifacts")) + testImplementation(project(":testutil-server")) } -apply from: deps.scripts.testArtifacts -apply from: deps.scripts.publishProto +apply { + from(Deps.scripts.testArtifacts(project)) + from(Deps.scripts.publishProto(project)) +} // Copies the documentation files to the Javadoc output folder. // Inspired by https://discuss.gradle.org/t/do-doc-files-work-with-gradle-javadoc/4673 -javadoc { +tasks.javadoc { doLast { copy { - from "src/main/docs" - into "$buildDir/docs/javadoc" + from("src/main/docs") + into("$buildDir/docs/javadoc") } } } diff --git a/settings.gradle b/settings.gradle.kts similarity index 73% rename from settings.gradle rename to settings.gradle.kts index e54c49a01dd..2d9910d52ac 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -18,17 +18,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -rootProject.name = 'spine-core-java' +rootProject.name = "spine-core-java" -include 'core' -include 'client' -include 'server' -include 'testutil-core' -include 'testutil-client' -include 'testutil-server' +include("core") +include("client") +include("server") +include("testutil-core") +include("testutil-client") +include("testutil-server") -include 'model-assembler' -include 'model-verifier' +include("model-assembler") +include("model-verifier") -project(':model-assembler').projectDir = './model/model-assembler' as File -project(':model-verifier').projectDir = './model/model-verifier' as File +project(":model-assembler").projectDir = File("./model/model-assembler") +project(":model-verifier").projectDir = File("./model/model-verifier") diff --git a/testutil-core/build.gradle b/testutil-client/build.gradle.kts similarity index 75% rename from testutil-core/build.gradle rename to testutil-client/build.gradle.kts index bbccc918287..975309da5bd 100644 --- a/testutil-core/build.gradle +++ b/testutil-client/build.gradle.kts @@ -18,14 +18,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -dependencies { - api project(path: ':client') +import io.spine.gradle.internal.Deps + +val spineTimeVersion: String by extra - // Depend on JUnit in the production part of the code, as this module exposes testing utilities - // that are based on JUnit. - api deps.test.junit5Api - runtimeClasspath deps.test.junit5Runner +dependencies { + api(project(":client")) + api(project(":testutil-core")) + api("io.spine:spine-testutil-time:$spineTimeVersion") - // General purpose test utilities. - api "io.spine:spine-testlib:$spineBaseVersion" + implementation(Deps.grpc.protobuf) } + +apply(from = Deps.scripts.testArtifacts(project)) diff --git a/testutil-client/build.gradle b/testutil-core/build.gradle.kts similarity index 80% rename from testutil-client/build.gradle rename to testutil-core/build.gradle.kts index 6a8f5d273e6..237e3e2efc1 100644 --- a/testutil-client/build.gradle +++ b/testutil-core/build.gradle.kts @@ -18,12 +18,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import io.spine.gradle.internal.Deps + +val spineBaseVersion: String by extra + dependencies { - api project(path: ':client') - - implementation deps.grpc.grpcProtobuf - api project(path: ':testutil-core') - api "io.spine:spine-testutil-time:$spineTimeVersion" + api(project(":client")) + api("io.spine:spine-testlib:$spineBaseVersion") + Deps.test.junit5Api.forEach { api(it) } + runtimeClasspath(Deps.test.junit5Runner) } - -apply from: deps.scripts.testArtifacts diff --git a/testutil-server/build.gradle b/testutil-server/build.gradle.kts similarity index 78% rename from testutil-server/build.gradle rename to testutil-server/build.gradle.kts index 7fbeace6e5d..472daab27a9 100644 --- a/testutil-server/build.gradle +++ b/testutil-server/build.gradle.kts @@ -17,12 +17,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -dependencies { - api project(path: ':server') - api project(path: ':testutil-client') - testImplementation deps.grpc.grpcNetty - testImplementation project(path: ':testutil-client', configuration: 'testArtifacts') +import io.spine.gradle.internal.Deps + +dependencies { + api(project(":server")) + api(project(":testutil-client")) + testImplementation(Deps.grpc.netty) + testImplementation(project(path = ":testutil-client", configuration = "testArtifacts")) } -apply from: deps.scripts.testArtifacts +apply(from = Deps.scripts.testArtifacts(project)) diff --git a/version.gradle.kts b/version.gradle.kts new file mode 100644 index 00000000000..e6036e8ebf6 --- /dev/null +++ b/version.gradle.kts @@ -0,0 +1,30 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * The versions of the libraries used. + * + * This file is used in both module `build.gradle.kts` scripts and in the integration tests, + * as we want to manage the versions in a single source. + */ + +val spineBaseVersion: String by extra("1.5.12") +val spineTimeVersion: String by extra("1.5.12") +val versionToPublish: String by extra("1.5.14")