Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6f50c95
Copy `buildSrc` into included build roots
dmdashenkov May 19, 2020
2a2da11
Add imports
dmdashenkov May 19, 2020
08bcdff
Migrate `base-validating-builders` to Kotlin
dmdashenkov May 19, 2020
c52f3dd
Translate root `smoke-tests` script
dmdashenkov May 19, 2020
f19ff7a
Allow using Groovy for `version.gradle` in test projects
dmdashenkov May 19, 2020
1a8373b
Migrate to Kotlin in smoke tests where possible
dmdashenkov May 19, 2020
0fb1ed6
Update version
dmdashenkov May 19, 2020
68930e7
Fix dependency declarations
dmdashenkov May 19, 2020
7090a39
Fix file name
dmdashenkov May 19, 2020
8b7328e
Fix test names
dmdashenkov May 19, 2020
c55469b
Fix condition
dmdashenkov May 19, 2020
4b93e66
Add `pull.bat`
dmdashenkov May 19, 2020
3b8b8b8
Add a comma
dmdashenkov May 19, 2020
eef75b8
Add a note on `pull` scripts.
dmdashenkov May 19, 2020
b4a5955
Add copyright
dmdashenkov May 19, 2020
2858ada
Check if `buildSrc`s are the same on CI
dmdashenkov May 19, 2020
4388ce5
Fix scripting dialect
dmdashenkov May 19, 2020
1ffa9e1
Test CI
dmdashenkov May 19, 2020
fdf17e8
Fix CI
dmdashenkov May 19, 2020
0ace9ef
Migrate leftover Groovy to Kotlin
dmdashenkov May 20, 2020
e790ecd
Use Kotlin in temporary test Gradle projects
dmdashenkov May 20, 2020
4ac52c3
Revert to using Groovy in test projects
dmdashenkov May 21, 2020
8578713
Remove unused var
dmdashenkov May 21, 2020
43630d9
Rollback to a Groovy script in tests
dmdashenkov May 21, 2020
1d7f3b3
Use Kotlin for test projects
dmdashenkov May 21, 2020
2bbc5d1
Add `copyDir` util
dmdashenkov May 21, 2020
a28a5aa
Fix test script
dmdashenkov May 21, 2020
b271e52
Remove unnecessary plugin declaration
dmdashenkov May 21, 2020
fc06a46
Fix test build scripts
dmdashenkov May 22, 2020
659bb7f
Remove an outdated README section
dmdashenkov May 25, 2020
1e281cc
Fix a typo
dmdashenkov May 25, 2020
b5bdd21
Rename `same.sh` to `same-dir.sh`
dmdashenkov May 25, 2020
f691528
Explain `BuildGradle`
dmdashenkov May 25, 2020
3f61225
Use Kotlin extensions for Protobuf plugin instead of `Closure`s
dmdashenkov May 25, 2020
f940ece
Reduce duplicates
dmdashenkov May 25, 2020
3dd0b1c
Import extension functions
dmdashenkov May 25, 2020
766a8ea
Use extension method `protobuf` for simplicity
dmdashenkov May 25, 2020
737991a
Update Gradle wrapper in smoke-tests
dmdashenkov May 25, 2020
14f2880
Update config
dmdashenkov May 26, 2020
a7d72cb
Update config
dmdashenkov May 26, 2020
95274a5
Apply `IncrementGuard` to `:base`
dmdashenkov May 26, 2020
b24db68
Add missing config files
dmdashenkov May 26, 2020
c8d6fd1
Update reports
dmdashenkov May 26, 2020
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
26 changes: 26 additions & 0 deletions .github/workflows/buildSrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Ensures that `buildSrc` directories are the same in all 3 projects:
# - the root project;
# - smoke tests;
# - the `base-validating-builders` project.

name: Check buildSrc copies

on:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Check root and `smoke-tests` copies are the same.
shell: bash
run: ./script/same-dir.sh ./buildSrc ./tools/smoke-tests/buildSrc

- name: Check root and `base-validating-builders` copies are the same.
shell: bash
run: ./script/same-dir.sh ./buildSrc ./base-validating-builders/buildSrc
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ The repository also contains:

### Notes on Coverage

Currently the coverage stats reflect the hits gathered from unit tests. However, Gradle plugins -
Currently, the coverage stats reflect the hits gathered from unit tests. However, Gradle plugins -
a significant part of this repository - are covered with integration tests. During each of those, a
standalone Gradle process is launched. The limitations of `jacoco` task API do not allow to include
the coverage of such tests into the repository coverage report easily. Therefore, current coverage
percentage shown is significantly lower than a real one.

### `pull` scripts

In most Spine repositories, we update the `config` submodule by running `./config/pull` (or its
Batch equivalent). However, in `base` we also need to copy Gradle `buildSrc` directory into included
builds: `smoke-tests` and `base-validating-builders`. Thus, here we have `./pull` and `.\pull.bat`
scripts which do whatever their `config` counterparts do and also copy `buildSrc` into the two
included build directories.

It is always recommended to run `./pull` instead of `./config/pull`.
147 changes: 0 additions & 147 deletions base-validating-builders/build.gradle

This file was deleted.

170 changes: 170 additions & 0 deletions base-validating-builders/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* 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 com.google.protobuf.gradle.ProtobufConfigurator.JavaGenerateProtoTaskCollection
import com.google.protobuf.gradle.*
import io.spine.gradle.internal.Deps
import org.gradle.internal.os.OperatingSystem

buildscript {
apply(from = "$projectDir/../version.gradle.kts")
val spineVersion: String by extra

repositories {
mavenLocal()
jcenter()
}

@Suppress("RemoveRedundantQualifierName") // Cannot use imports here.
val deps = io.spine.gradle.internal.Deps

dependencies {
deps.build.protobuf.forEach { classpath(it) }
classpath(deps.build.guava)
classpath(deps.build.flogger)
classpath(deps.build.checkerAnnotations)
deps.build.errorProneAnnotations.forEach { classpath(it) }
classpath(deps.build.jsr305Annotations)
classpath(deps.build.gradlePlugins.protobuf)

classpath(deps.gen.javaPoet)
classpath(deps.runtime.flogger.systemBackend)

// A library for parsing Java sources.
// Used for parsing Java sources generated from Protobuf files
// to make their annotation more convenient.
classpath(deps.build.roasterApi) {
exclude(group = "com.google.guava")
}
classpath (deps.build.roasterJdt) {
exclude(group = "com.google.guava")
}

classpath(files(
"$projectDir/../tools/protoc-api/build/libs/protoc-api-${spineVersion}.jar",
"$projectDir/../tools/model-compiler/build/libs/model-compiler-${spineVersion}.jar",
"$projectDir/../tools/plugin-base/build/libs/plugin-base-${spineVersion}.jar",
"$projectDir/../tools/tool-base/build/libs/tool-base-${spineVersion}.jar",
"$projectDir/../base/build/libs/base-${spineVersion}.jar"
))
}
}

plugins {
java
idea
@Suppress("RemoveRedundantQualifierName") // Cannot use imports here.
id("com.google.protobuf").version(io.spine.gradle.internal.Deps.versions.protobufPlugin)
}

apply(plugin = "io.spine.tools.spine-model-compiler")

extensions["modelCompiler"].withGroovyBuilder {
setProperty("generateValidation", true)
}

repositories {
// This defines the `libs` directory of upstream projects as a local repository.
// See `dependencies` section below for definition of the dependency on the JAR produced by
// the `base` module.
flatDir {
val baseRoot = "$projectDir/.."
dir("$baseRoot/base/build/libs/")
}
mavenLocal()
jcenter()
}

val spineVersion: String by extra

dependencies {
Deps.build.protobuf.forEach { compileOnly(it) }
compileOnly(Deps.build.guava)
compileOnly(Deps.build.flogger)
compileOnly(Deps.build.checkerAnnotations)
Deps.build.errorProneAnnotations.forEach { compileOnly(it) }
compileOnly(Deps.build.jsr305Annotations)

// The below dependency refers to a local artifact.
// See `repositories.flatDir` definition above.
compileOnly(name = "base-${spineVersion}", group = "")
}

sourceSets {
main {
java.srcDirs("$projectDir/generated/main/spine")
proto.srcDirs("$projectDir/../base/src/main/proto")
}
}

protobuf {
generateProtoTasks {
all().forEach { task ->
task.plugins {
remove("grpc")
}
}
}
}

val compiledProtoDir = "$projectDir/compiled-proto"

val copyCompiledClasses by tasks.registering(Copy::class) {
from(sourceSets.main.get().java.outputDir)
into(compiledProtoDir)

include {
it.isDirectory || it.name.endsWith(".class")
}

dependsOn(tasks.compileJava)
}

tasks.assemble {
dependsOn(copyCompiledClasses)
}

tasks.build {
doLast {
val directory = "$projectDir/../"
val os = OperatingSystem.current()
val script = when {
os.isWindows -> "gradlew.bat"
else -> "gradlew"
}
val process = ProcessBuilder()
.command("$directory/$script", ":base:cleanJar", ":base:jar", "--console=plain")
.directory(file(directory))
.start()
if (process.waitFor() != 0) {
throw GradleException("Unable to rebuild JAR for :base.")
}
}
}

val cleanGenerated by tasks.registering(Delete::class) {
delete(files("$projectDir/generated", "$projectDir/.spine", compiledProtoDir))
}

tasks.clean { dependsOn(cleanGenerated) }

idea.module {
generatedSourceDirs.add(file(compiledProtoDir))
}
Loading