diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 2c9b64c7..03cca76b 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -22,5 +22,10 @@ jobs: run: git submodule update --init --recursive - name: Run tests with Gradle - run: gradlew.bat build shell: cmd + run: > + choco install dart-sdk --limitoutput + && refreshenv + && pub global activate protoc_plugin + && pub global activate dart_code_gen + && gradlew.bat build diff --git a/.travis.yml b/.travis.yml index fecd8124..92e13828 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,18 @@ language: java jdk: - openjdk8 +env: + global: + - PATH="$PATH:/usr/lib/dart/bin" + before_install: - chmod +x ./gradlew - chmod +x ./config/scripts/publish-artifacts.sh + - chmod +x ./config/scripts/update-apt.sh + - ./config/scripts/update-apt.sh + - sudo apt-get install dart + - pub global activate protoc_plugin + - pub global activate dart_code_gen install: - openssl aes-256-cbc -K $encrypted_484d6a99d515_key -iv $encrypted_484d6a99d515_iv -in credentials.tar.enc -out credentials.tar -d diff --git a/buildSrc/src/main/kotlin/func-test-env.gradle.kts b/buildSrc/src/main/kotlin/func-test-env.gradle.kts deleted file mode 100644 index ee3f7efd..00000000 --- a/buildSrc/src/main/kotlin/func-test-env.gradle.kts +++ /dev/null @@ -1,65 +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. - */ - -plugins { - base -} - -/* - * Creates a configuration named `fetch`. - * - * The configuration is used in order to download artifacts. The artifacts are NOT added into - * the application classpath. - */ -configurations { create("fetch") } - -val spineBaseVersion: String by extra - -var spineProtocPluginDependency: Dependency? = null -dependencies { - spineProtocPluginDependency = "fetch"("io.spine.tools:spine-protoc-plugin:${spineBaseVersion}@jar") -} - -val spineArtifactDir = file("$projectDir/.spine") - -val downloadProtocPlugin by tasks.registering { - description = "Downloads the Spine Protoc plugin for functional tests." - - doLast { - val executableJar = configurations["fetch"] - .fileCollection(spineProtocPluginDependency) - .getSingleFile() - spineArtifactDir.mkdirs() - copy { - from(executableJar) - into(spineArtifactDir) - } - } - - mustRunAfter(tasks.clean) -} - -tasks.withType(Test::class) { - dependsOn(downloadProtocPlugin) -} - -tasks.clean { - delete(spineArtifactDir) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt b/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt index 3e9250e7..be5d1d09 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt @@ -67,41 +67,41 @@ object Repos { } object Versions { - val checkerFramework = "3.3.0" - val errorProne = "2.3.4" + val checkerFramework = "3.7.1" + val errorProne = "2.4.0" val errorProneJavac = "9+181-r4173-1" // taken from here: https://github.com/tbroyer/gradle-errorprone-plugin/blob/v0.8/build.gradle.kts - val errorPronePlugin = "1.2.1" + val errorPronePlugin = "1.3.0" val pmd = "6.24.0" val checkstyle = "8.29" - val protobufPlugin = "0.8.12" - val appengineApi = "1.9.79" + val protobufPlugin = "0.8.13" + val appengineApi = "1.9.82" val appenginePlugin = "2.2.0" val findBugs = "3.0.2" - val guava = "29.0-jre" - val protobuf = "3.11.4" + val guava = "30.0-jre" + val protobuf = "3.13.0" val grpc = "1.28.1" val flogger = "0.5.1" - val junit4 = "4.12" - val junit5 = "5.6.2" - val junitPlatform = "1.6.2" - val junitPioneer = "0.4.2" - val truth = "1.0.1" + val junit4 = "4.13.1" + val junit5 = "5.7.0" + val junitPlatform = "1.7.0" + val junitPioneer = "1.0.0" + val truth = "1.1" val httpClient = "1.34.2" val apacheHttpClient = "2.1.2" val firebaseAdmin = "6.12.2" val roaster = "2.21.2.Final" val licensePlugin = "1.13" - val javaPoet = "1.12.1" - val autoService = "1.0-rc6" + val javaPoet = "1.13.0" + val autoService = "1.0-rc7" val autoCommon = "0.10" val jackson = "2.9.10.5" - val animalSniffer = "1.18" + val animalSniffer = "1.19" val apiguardian = "1.1.0" val javaxAnnotation = "1.3.2" val klaxon = "5.4" - val ouathJwt = "3.10.3" + val ouathJwt = "3.11.0" val bouncyCastlePkcs = "1.66" - val assertK = "0.22" + val assertK = "0.23" /** * Version of the SLF4J library. @@ -113,7 +113,7 @@ object Versions { * this version and force it via [forceConfiguration(..)][DependencyResolution.forceConfiguration]. */ @Deprecated("Use Flogger over SLF4J.", replaceWith = ReplaceWith("flogger")) - val slf4j = "1.7.29" + val slf4j = "1.7.30" } object GradlePlugins { @@ -312,6 +312,9 @@ object DependencyResolution { Deps.test.junit4, // Transitive dependencies of 3rd party components that we don't use directly. + "org.junit.platform:junit-platform-commons:${Versions.junitPlatform}", + "com.google.auto.value:auto-value-annotations:1.7.4", + "com.google.auto.service:auto-service-annotations:1.0-rc7", "com.google.code.gson:gson:2.8.6", "com.google.j2objc:j2objc-annotations:1.3", "org.codehaus.plexus:plexus-utils:3.3.0", diff --git a/gradle.properties b/gradle.properties index 23a9c161..33d60558 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,3 @@ # org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=1024m -org.gradle.logging.level=info diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index be52383e..4d9ca164 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.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/license-report.md b/license-report.md index c1f8a136..eda957af 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:spine-plugin:1.6.4` +# Dependencies of `io.spine.tools:spine-plugin:1.6.11` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -10,10 +10,10 @@ 1. **Group:** com.google.code.gson **Name:** gson **Version:** 2.8.6 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_annotations **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_annotations **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_type_annotations **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_type_annotations **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group:** com.google.flogger **Name:** flogger **Version:** 0.5.1 @@ -32,7 +32,7 @@ * **Manifest Project URL:** [https://github.com/google/guava/](https://github.com/google/guava/) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.guava **Name:** guava **Version:** 29.0-jre +1. **Group:** com.google.guava **Name:** guava **Version:** 30.0-jre * **Manifest Project URL:** [https://github.com/google/guava/](https://github.com/google/guava/) * **POM License: Apache License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -43,19 +43,19 @@ * **POM Project URL:** [https://github.com/google/j2objc/](https://github.com/google/j2objc/) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.protobuf **Name:** protobuf-gradle-plugin **Version:** 0.8.12 +1. **Group:** com.google.protobuf **Name:** protobuf-gradle-plugin **Version:** 0.8.13 * **POM Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) * **POM License: BSD 3-Clause** - [http://opensource.org/licenses/BSD-3-Clause](http://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protobuf-java **Version:** 3.11.4 +1. **Group:** com.google.protobuf **Name:** protobuf-java **Version:** 3.13.0 * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protobuf-java-util **Version:** 3.11.4 +1. **Group:** com.google.protobuf **Name:** protobuf-java-util **Version:** 3.13.0 * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.squareup **Name:** javapoet **Version:** 1.12.1 +1. **Group:** com.squareup **Name:** javapoet **Version:** 1.13.0 * **POM Project URL:** [http://github.com/square/javapoet/](http://github.com/square/javapoet/) * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -77,7 +77,7 @@ * **POM License: GNU General Public License, version 2 (GPL2), with the classpath exception** - [http://www.gnu.org/software/classpath/license.html](http://www.gnu.org/software/classpath/license.html) * **POM License: The MIT License** - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) -1. **Group:** org.checkerframework **Name:** checker-qual **Version:** 3.3.0 +1. **Group:** org.checkerframework **Name:** checker-qual **Version:** 3.7.1 * **Manifest License:** MIT (Not packaged) * **POM Project URL:** [https://checkerframework.org](https://checkerframework.org) * **POM License: The MIT License** - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) @@ -95,7 +95,7 @@ * **POM Project URL:** [http://jcommander.org](http://jcommander.org) * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) -1. **Group:** com.github.ben-manes.caffeine **Name:** caffeine **Version:** 2.7.0 +1. **Group:** com.github.ben-manes.caffeine **Name:** caffeine **Version:** 2.8.0 * **POM Project URL:** [https://github.com/ben-manes/caffeine](https://github.com/ben-manes/caffeine) * **POM License: Apache License, Version 2.0** - [https://www.apache.org/licenses/LICENSE-2.0.txt](https://www.apache.org/licenses/LICENSE-2.0.txt) @@ -106,7 +106,12 @@ 1. **Group:** com.google.auto **Name:** auto-common **Version:** 0.10 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 +1. **Group:** com.google.auto.service **Name:** auto-service-annotations **Version:** 1.0-rc7 + * **POM Project URL:** [https://github.com/google/auto/tree/master/service](https://github.com/google/auto/tree/master/service) + * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.7.4 + * **POM Project URL:** [https://github.com/google/auto/tree/master/value](https://github.com/google/auto/tree/master/value) * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group:** com.google.code.findbugs **Name:** jFormatString **Version:** 3.0.0 @@ -120,19 +125,19 @@ 1. **Group:** com.google.code.gson **Name:** gson **Version:** 2.8.6 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_annotation **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_annotation **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_annotations **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_annotations **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_check_api **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_check_api **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_core **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_core **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.errorprone **Name:** error_prone_type_annotations **Version:** 2.3.4 +1. **Group:** com.google.errorprone **Name:** error_prone_type_annotations **Version:** 2.4.0 * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group:** com.google.errorprone **Name:** javac **Version:** 9+181-r4173-1 @@ -155,11 +160,11 @@ * **Manifest Project URL:** [https://github.com/google/guava/](https://github.com/google/guava/) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.guava **Name:** guava **Version:** 29.0-jre +1. **Group:** com.google.guava **Name:** guava **Version:** 30.0-jre * **Manifest Project URL:** [https://github.com/google/guava/](https://github.com/google/guava/) * **POM License: Apache License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.guava **Name:** guava-testlib **Version:** 29.0-jre +1. **Group:** com.google.guava **Name:** guava-testlib **Version:** 30.0-jre * **POM License: Apache License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group:** com.google.guava **Name:** listenablefuture **Version:** 9999.0-empty-to-avoid-conflict-with-guava @@ -169,35 +174,35 @@ * **POM Project URL:** [https://github.com/google/j2objc/](https://github.com/google/j2objc/) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.protobuf **Name:** protobuf-gradle-plugin **Version:** 0.8.12 +1. **Group:** com.google.protobuf **Name:** protobuf-gradle-plugin **Version:** 0.8.13 * **POM Project URL:** [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin) * **POM License: BSD 3-Clause** - [http://opensource.org/licenses/BSD-3-Clause](http://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protobuf-java **Version:** 3.11.4 +1. **Group:** com.google.protobuf **Name:** protobuf-java **Version:** 3.13.0 * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protobuf-java-util **Version:** 3.11.4 +1. **Group:** com.google.protobuf **Name:** protobuf-java-util **Version:** 3.13.0 * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.truth **Name:** truth **Version:** 1.0.1 +1. **Group:** com.google.truth **Name:** truth **Version:** 1.1 * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.truth.extensions **Name:** truth-java8-extension **Version:** 1.0.1 +1. **Group:** com.google.truth.extensions **Name:** truth-java8-extension **Version:** 1.1 * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.truth.extensions **Name:** truth-liteproto-extension **Version:** 1.0.1 +1. **Group:** com.google.truth.extensions **Name:** truth-liteproto-extension **Version:** 1.1 * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.google.truth.extensions **Name:** truth-proto-extension **Version:** 1.0.1 +1. **Group:** com.google.truth.extensions **Name:** truth-proto-extension **Version:** 1.1 * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group:** com.googlecode.java-diff-utils **Name:** diffutils **Version:** 1.3.0 * **POM Project URL:** [http://code.google.com/p/java-diff-utils/](http://code.google.com/p/java-diff-utils/) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group:** com.squareup **Name:** javapoet **Version:** 1.12.1 +1. **Group:** com.squareup **Name:** javapoet **Version:** 1.13.0 * **POM Project URL:** [http://github.com/square/javapoet/](http://github.com/square/javapoet/) * **POM License: Apache 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -214,7 +219,7 @@ * **POM Project URL:** [http://jcp.org/en/jsr/detail?id=250](http://jcp.org/en/jsr/detail?id=250) * **POM License: CDDL + GPLv2 with classpath exception** - [https://github.com/javaee/javax.annotation/blob/master/LICENSE](https://github.com/javaee/javax.annotation/blob/master/LICENSE) -1. **Group:** junit **Name:** junit **Version:** 4.12 +1. **Group:** junit **Name:** junit **Version:** 4.13.1 * **POM Project URL:** [http://junit.org](http://junit.org) * **POM License: Eclipse Public License 1.0** - [http://www.eclipse.org/legal/epl-v10.html](http://www.eclipse.org/legal/epl-v10.html) @@ -253,26 +258,17 @@ * **POM License: GNU General Public License, version 2 (GPL2), with the classpath exception** - [http://www.gnu.org/software/classpath/license.html](http://www.gnu.org/software/classpath/license.html) * **POM License: The MIT License** - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) -1. **Group:** org.checkerframework **Name:** checker-qual **Version:** 3.3.0 +1. **Group:** org.checkerframework **Name:** checker-qual **Version:** 3.7.1 * **Manifest License:** MIT (Not packaged) * **POM Project URL:** [https://checkerframework.org](https://checkerframework.org) * **POM License: The MIT License** - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) -1. **Group:** org.checkerframework **Name:** dataflow **Version:** 3.0.0 +1. **Group:** org.checkerframework **Name:** dataflow-shaded **Version:** 3.1.2 * **Manifest License:** (GPL-2.0-only WITH Classpath-exception-2.0) (Not packaged) * **POM Project URL:** [https://checkerframework.org](https://checkerframework.org) * **POM License: GNU General Public License, version 2 (GPL2), with the classpath exception** - [http://www.gnu.org/software/classpath/license.html](http://www.gnu.org/software/classpath/license.html) * **POM License: The MIT License** - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) -1. **Group:** org.checkerframework **Name:** javacutil **Version:** 3.0.0 - * **Manifest License:** (GPL-2.0-only WITH Classpath-exception-2.0) (Not packaged) - * **POM Project URL:** [https://checkerframework.org](https://checkerframework.org) - * **POM License: GNU General Public License, version 2 (GPL2), with the classpath exception** - [http://www.gnu.org/software/classpath/license.html](http://www.gnu.org/software/classpath/license.html) - * **POM License: The MIT License** - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) - -1. **Group:** org.hamcrest **Name:** hamcrest-all **Version:** 1.3 - * **POM License: New BSD License** - [http://www.opensource.org/licenses/bsd-license.php](http://www.opensource.org/licenses/bsd-license.php) - 1. **Group:** org.hamcrest **Name:** hamcrest-core **Version:** 1.3 * **POM License: New BSD License** - [http://www.opensource.org/licenses/bsd-license.php](http://www.opensource.org/licenses/bsd-license.php) @@ -284,24 +280,24 @@ * **POM License: Eclipse Public License version 1.0** - [http://www.eclipse.org/legal/epl-v10.html](http://www.eclipse.org/legal/epl-v10.html) * **POM License: Public Domain** - [http://repository.jboss.org/licenses/cc0-1.0.txt](http://repository.jboss.org/licenses/cc0-1.0.txt) -1. **Group:** org.junit **Name:** junit-bom **Version:** 5.6.2 **No license information found** -1. **Group:** org.junit.jupiter **Name:** junit-jupiter-api **Version:** 5.6.2 +1. **Group:** org.junit **Name:** junit-bom **Version:** 5.7.0 **No license information found** +1. **Group:** org.junit.jupiter **Name:** junit-jupiter-api **Version:** 5.7.0 * **POM Project URL:** [https://junit.org/junit5/](https://junit.org/junit5/) * **POM License: Eclipse Public License v2.0** - [https://www.eclipse.org/legal/epl-v20.html](https://www.eclipse.org/legal/epl-v20.html) -1. **Group:** org.junit.jupiter **Name:** junit-jupiter-engine **Version:** 5.6.2 +1. **Group:** org.junit.jupiter **Name:** junit-jupiter-engine **Version:** 5.7.0 * **POM Project URL:** [https://junit.org/junit5/](https://junit.org/junit5/) * **POM License: Eclipse Public License v2.0** - [https://www.eclipse.org/legal/epl-v20.html](https://www.eclipse.org/legal/epl-v20.html) -1. **Group:** org.junit.jupiter **Name:** junit-jupiter-params **Version:** 5.6.2 +1. **Group:** org.junit.jupiter **Name:** junit-jupiter-params **Version:** 5.7.0 * **POM Project URL:** [https://junit.org/junit5/](https://junit.org/junit5/) * **POM License: Eclipse Public License v2.0** - [https://www.eclipse.org/legal/epl-v20.html](https://www.eclipse.org/legal/epl-v20.html) -1. **Group:** org.junit.platform **Name:** junit-platform-commons **Version:** 1.6.2 +1. **Group:** org.junit.platform **Name:** junit-platform-commons **Version:** 1.7.0 * **POM Project URL:** [https://junit.org/junit5/](https://junit.org/junit5/) * **POM License: Eclipse Public License v2.0** - [https://www.eclipse.org/legal/epl-v20.html](https://www.eclipse.org/legal/epl-v20.html) -1. **Group:** org.junit.platform **Name:** junit-platform-engine **Version:** 1.6.2 +1. **Group:** org.junit.platform **Name:** junit-platform-engine **Version:** 1.7.0 * **POM Project URL:** [https://junit.org/junit5/](https://junit.org/junit5/) * **POM License: Eclipse Public License v2.0** - [https://www.eclipse.org/legal/epl-v20.html](https://www.eclipse.org/legal/epl-v20.html) @@ -317,25 +313,25 @@ * **POM License: BSD-3-Clause** - [https://asm.ow2.io/license.html](https://asm.ow2.io/license.html) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group:** org.ow2.asm **Name:** asm **Version:** 9.0 + * **Manifest Project URL:** [http://asm.ow2.org](http://asm.ow2.org) + * **Manifest License:** BSD-3-Clause;link=https://asm.ow2.io/LICENSE.txt (Not packaged) + * **POM Project URL:** [http://asm.ow2.io/](http://asm.ow2.io/) + * **POM License: BSD-3-Clause** - [https://asm.ow2.io/license.html](https://asm.ow2.io/license.html) + * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group:** org.pcollections **Name:** pcollections **Version:** 2.1.2 * **POM Project URL:** [http://pcollections.org](http://pcollections.org) * **POM License: The MIT License** - [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) -1. **Group:** org.plumelib **Name:** plume-util **Version:** 1.0.6 - * **POM Project URL:** [https://github.com/plume-lib/plume-util](https://github.com/plume-lib/plume-util) - * **POM License: MIT License** - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT) - -1. **Group:** org.plumelib **Name:** reflection-util **Version:** 0.0.2 - * **POM Project URL:** [https://github.com/plume-lib/reflection-util](https://github.com/plume-lib/reflection-util) - * **POM License: MIT License** - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT) - -1. **Group:** org.plumelib **Name:** require-javadoc **Version:** 0.1.0 - * **POM Project URL:** [https://github.com/plume-lib/require-javadoc](https://github.com/plume-lib/require-javadoc) - * **POM License: MIT License** - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT) +1. **Group:** org.threeten **Name:** threeten-extra **Version:** 1.5.0 + * **Manifest Project URL:** [https://www.threeten.org](https://www.threeten.org) + * **POM Project URL:** [https://www.threeten.org/threeten-extra](https://www.threeten.org/threeten-extra) + * **POM License: BSD 3-clause** - [https://raw.githubusercontent.com/ThreeTen/threeten-extra/master/LICENSE.txt](https://raw.githubusercontent.com/ThreeTen/threeten-extra/master/LICENSE.txt) The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 13:45:31 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 **Tue Nov 17 19:24:52 EET 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/plugin/build.gradle.kts b/plugin/build.gradle.kts index d0b3054f..d2160da6 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -27,7 +27,6 @@ plugins { id("com.gradle.plugin-publish").version("0.12.0") id("com.github.johnrengelman.shadow").version("6.0.0") `bootstrap-plugin` - `func-test-env` `prepare-config-resources` } @@ -44,6 +43,7 @@ dependencies { implementation("io.spine.tools:spine-plugin-base:$spineBaseVersion") implementation("io.spine.tools:spine-model-compiler:$spineBaseVersion") implementation("io.spine.tools:spine-proto-js-plugin:$spineBaseVersion") + implementation("io.spine.tools:spine-proto-dart-plugin:$spineBaseVersion") testImplementation("io.spine:spine-testlib:$spineBaseVersion") testImplementation("io.spine.tools:spine-plugin-testlib:$spineBaseVersion") diff --git a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/CodeGenExtension.java b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/CodeGenExtension.java index f631024c..a87c9f1d 100644 --- a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/CodeGenExtension.java +++ b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/CodeGenExtension.java @@ -95,6 +95,14 @@ final SpinePluginTarget pluginTarget() { return pluginTarget; } + /** + * Obtains the {@code ProtobufGenerator} which configures the code generation for the associated + * project. + */ + final ProtobufGenerator protobufGenerator() { + return protobufGenerator; + } + /** * Obtains the dependency container associated with this extension. */ diff --git a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/DartExtension.java b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/DartExtension.java new file mode 100644 index 00000000..aed5f20e --- /dev/null +++ b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/DartExtension.java @@ -0,0 +1,197 @@ +/* + * 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.tools.gradle.bootstrap; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Joiner; +import io.spine.dart.PubCache; +import io.spine.dart.gradle.Extension; +import io.spine.tools.gradle.TaskName; +import org.apache.tools.ant.taskdefs.condition.Os; +import org.gradle.api.GradleException; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.provider.Property; +import org.gradle.api.tasks.TaskContainer; + +import javax.annotation.OverridingMethodsMustInvokeSuper; +import java.io.IOException; +import java.nio.file.Path; + +import static io.spine.tools.gradle.BaseTaskName.assemble; +import static io.spine.tools.gradle.ProtobufTaskName.generateProto; +import static io.spine.tools.gradle.ProtobufTaskName.generateTestProto; +import static io.spine.tools.gradle.bootstrap.DartTaskName.generateDart; +import static io.spine.tools.gradle.bootstrap.DartTaskName.generateTestDart; +import static io.spine.tools.gradle.protoc.ProtocPlugin.Name.dart; +import static io.spine.tools.gradle.protoc.ProtocPlugin.called; +import static java.lang.String.format; +import static java.nio.file.Files.exists; +import static org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS; + +/** + * An extension which configures Dart code generation. + */ +@VisibleForTesting // Would be package private, but needed for integration tests. +public final class DartExtension extends CodeGenExtension { + + public static final String TYPES_FILE = "types.dart"; + private static final String DART_TOOL_NAME = "dart_code_gen"; + private static final Joiner commandJoiner = Joiner.on(' '); + + private final Project project; + + private DartExtension(Builder builder) { + super(builder); + this.project = builder.project(); + } + + @OverridingMethodsMustInvokeSuper + @Override + void enableGeneration() { + super.enableGeneration(); + pluginTarget().applyProtobufPlugin(); + protobufGenerator().enablePlugin(called(dart)); + pluginTarget().applyProtoDartPlugin(); + createGenerationTasks(); + } + + private void createGenerationTasks() { + Extension protoDart = project.getExtensions() + .getByType(Extension.class); + Task mainTask = createTask(generateDart, + protoDart.getMainDescriptorSet(), + protoDart.getLibDir()); + Task testTask = createTask(generateTestDart, + protoDart.getTestDescriptorSet(), + protoDart.getTestDir()); + Task assembleTask = project.getTasks() + .getByName(assemble.name()); + project.afterEvaluate((p) -> { + mainTask.dependsOn(generateProto.name()); + testTask.dependsOn(generateTestProto.name()); + }); + assembleTask.dependsOn(mainTask, testTask); + testTask.shouldRunAfter(mainTask); + } + + private Task createTask(TaskName name, + Property descriptorFile, + DirectoryProperty dartDir) { + TaskContainer tasks = project.getTasks(); + Task foundTask = tasks.findByName(name.name()); + if (foundTask != null) { + return foundTask; + } + Task task = tasks.create(name.name()); + task.doLast(t -> runDartTool(descriptorFile, dartDir)); + return task; + } + + private void runDartTool(Property descriptorFile, DirectoryProperty dartDir) { + if (project.file(descriptorFile) + .exists()) { + @SuppressWarnings("UseOfProcessBuilder") + ProcessBuilder processBuilder = buildDartToolProcess(descriptorFile, dartDir); + int exitCode; + try { + Process dartToolProcess = processBuilder.start(); + exitCode = dartToolProcess.waitFor(); + } catch (IOException | InterruptedException e) { + throw new GradleException(format("Failed to execute `%s`.", DART_TOOL_NAME), e); + } + if (exitCode != 0) { + throw onProcessError(processBuilder, exitCode); + } + } + } + + private ProcessBuilder buildDartToolProcess(Property descriptorFile, + DirectoryProperty dartDir) { + Path command = dartCodeGenCommand(); + @SuppressWarnings("UseOfProcessBuilder") + ProcessBuilder processBuilder = new ProcessBuilder( + command.toString(), + "--descriptor", project.file(descriptorFile) + .getAbsolutePath(), + "--destination", dartDir.file(TYPES_FILE) + .get() + .getAsFile() + .getAbsolutePath(), + "--standard-types", "spine_client", + "--import-prefix", "." + ).inheritIO(); + return processBuilder; + } + + private static GradleException onProcessError( + @SuppressWarnings("UseOfProcessBuilder") ProcessBuilder processBuilder, + int exitCode + ) { + String command = commandJoiner.join(processBuilder.command()); + throw new GradleException(format("Command `%s` exited with code %s.", command, exitCode)); + } + + private Path dartCodeGenCommand() { + String extension = Os.isFamily(FAMILY_WINDOWS) ? ".bat" : ""; + Path command = PubCache.bin() + .resolve(DART_TOOL_NAME + extension); + if (!exists(command)) { + _warn().log("Cannot locate `dart_code_gen` under `%s`. " + + "To install, run `pub global activate %s`.", + command, DART_TOOL_NAME); + } + return command; + } + + /** + * Creates a new instance of {@code Builder} for {@code DartExtension} instances. + * + * @return new instance of {@code Builder} + */ + static Builder newBuilder() { + return new Builder(); + } + + /** + * A builder for the {@code DartExtension} instances. + */ + static final class Builder extends CodeGenExtension.Builder { + + /** + * Prevents direct instantiation. + */ + private Builder() { + super(); + } + + @Override + Builder self() { + return this; + } + + @Override + DartExtension doBuild() { + return new DartExtension(this); + } + } +} diff --git a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/DartTaskName.java b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/DartTaskName.java new file mode 100644 index 00000000..cf5e8f8b --- /dev/null +++ b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/DartTaskName.java @@ -0,0 +1,41 @@ +/* + * 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.tools.gradle.bootstrap; + +import io.spine.tools.gradle.TaskName; + +/** + * Tasks which launch the `dart_code_gen` tool. + */ +public enum DartTaskName implements TaskName { + + /** + * Name of the task which launches the `dart_code_gen` tool for generating extra Dart code for + * the main scope. + */ + generateDart, + + /** + * Name of the task which launches the `dart_code_gen` tool for generating extra Dart code for + * the test scope. + */ + generateTestDart +} diff --git a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/Extension.java b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/Extension.java index 954c97da..50e11dac 100644 --- a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/Extension.java +++ b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/Extension.java @@ -54,17 +54,17 @@ public final class Extension { private final JavaExtension java; private final JavaScriptExtension javaScript; + private final DartExtension dart; private final ModelExtension modelExtension; private final ArtifactSnapshot artifacts; - private final Project project; - private boolean javaEnabled = false; - + private boolean javaEnabled; private boolean forceDependencies; private Extension(Builder builder) { this.java = builder.buildJavaExtension(); this.javaScript = builder.buildJavaScriptExtension(); + this.dart = builder.buildDartExtension(); this.modelExtension = builder.buildModelExtension(); this.project = builder.project; this.artifacts = builder.artifacts; @@ -139,6 +139,22 @@ public JavaScriptExtension enableJavaScript() { return javaScript; } + /** + * Marks this project as a Dart project and configures the Dart code generation. + * + *

Enables the Dart code generation from Protobuf. If the {@code spine-proto-dart-plugin} is + * not applied to this project, applies it immediately. + */ + @CanIgnoreReturnValue + public DartExtension enableDart() { + dart.enableGeneration(); + if (!this.javaEnabled) { + toggleJavaTasks(false); + } + disableTransitiveProtos(); + return dart; + } + /** * Marks this project as a project that contains the Protobuf model definition. * @@ -336,6 +352,18 @@ private JavaScriptExtension buildJavaScriptExtension() { return javaScriptExtension; } + private DartExtension buildDartExtension() { + DartExtension dartExtension = DartExtension + .newBuilder() + .setProject(project) + .setDependant(dependencyTarget) + .setPluginTarget(pluginTarget) + .setProtobufGenerator(generator) + .setArtifactSnapshot(artifacts) + .build(); + return dartExtension; + } + private ModelExtension buildModelExtension() { ModelExtension modelExtension = ModelExtension .newBuilder() diff --git a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/JavaScriptExtension.java b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/JavaScriptExtension.java index eaf07488..8903442b 100644 --- a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/JavaScriptExtension.java +++ b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/JavaScriptExtension.java @@ -28,7 +28,7 @@ /** * An extension which configures JavaScript code generation. */ -public final class JavaScriptExtension extends CodeGenExtension { +final class JavaScriptExtension extends CodeGenExtension { private static final String IMPORT_STYLE_OPTION = "import_style=commonjs"; diff --git a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/SpinePluginTarget.java b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/SpinePluginTarget.java index 95ea6895..2a121a15 100644 --- a/plugin/src/main/java/io/spine/tools/gradle/bootstrap/SpinePluginTarget.java +++ b/plugin/src/main/java/io/spine/tools/gradle/bootstrap/SpinePluginTarget.java @@ -21,6 +21,7 @@ package io.spine.tools.gradle.bootstrap; import com.google.protobuf.gradle.ProtobufPlugin; +import io.spine.dart.gradle.ProtoDartPlugin; import io.spine.js.gradle.ProtoJsPlugin; import io.spine.tools.gradle.GradlePlugin; import io.spine.tools.gradle.PluginScript; @@ -105,6 +106,14 @@ public void applyProtoJsPlugin() { apply(plugin); } + /** + * Applies the {@link ProtoDartPlugin}. + */ + public void applyProtoDartPlugin() { + GradlePlugin plugin = GradlePlugin.implementedIn(ProtoDartPlugin.class); + apply(plugin); + } + /** * Checks if the {@code idea} plugin is applied to this project. */ diff --git a/plugin/src/main/java/io/spine/tools/gradle/protoc/ProtocPlugin.java b/plugin/src/main/java/io/spine/tools/gradle/protoc/ProtocPlugin.java index 5f50cfa9..59f4a3df 100644 --- a/plugin/src/main/java/io/spine/tools/gradle/protoc/ProtocPlugin.java +++ b/plugin/src/main/java/io/spine/tools/gradle/protoc/ProtocPlugin.java @@ -71,6 +71,7 @@ public void removeFrom(NamedDomainObjectContainerAllow to assert facts about a collection of tasks referencing them by names instead of + * looking up individual elements. + */ + private static final + Correspondence<@NonNull Task, @NonNull TaskName> names = Correspondence.from( + (@NonNull Task task, @NonNull TaskName name) -> task.getName().equals(name.name()), + "has name" + ); + private PluginTarget pluginTarget; private Extension extension; private MemoizingSourceSuperset codeLayout; private MemoizingDependant dependencyTarget; private Path projectDir; + private Project project; @BeforeEach - void setUp(@TempDir Path projectDir) { - Project project = ProjectBuilder + void setUp() { + this.projectDir = TempDir.forClass(ExtensionTest.class).toPath(); + projectDir.toFile().deleteOnExit(); + this.project = ProjectBuilder .builder() .withName(BootstrapPluginTest.class.getSimpleName()) .withProjectDir(projectDir.toFile()) .build(); - this.projectDir = project.getProjectDir() - .toPath(); - pluginTarget = new MemoizingPluginRegistry(); + pluginTarget = new PlugableProject(project); dependencyTarget = new MemoizingDependant(); codeLayout = new MemoizingSourceSuperset(); extension = Extension @@ -84,9 +104,6 @@ void setUp(@TempDir Path projectDir) { .setDependencyTarget(dependencyTarget) .setArtifactSnapshot(FakeArtifacts.snapshot()) .build(); - project.getExtensions() - .add(ModelCompilerPlugin.extensionName(), - new io.spine.tools.gradle.compiler.Extension()); } @Nested @@ -324,12 +341,13 @@ void noExclusions() { @Test @DisplayName("declare `generated` directory a source root") - void declareGeneratedDirectory() { + void declareGeneratedDirectory() throws IOException { extension.enableJava(); assertApplied(JavaPlugin.class); ImmutableSet declaredPaths = codeLayout.javaSourceDirs(); - assertThat(declaredPaths).contains(projectDir.resolve("generated")); + Path realDirPath = projectDir.toRealPath(); + assertThat(declaredPaths).contains(realDirPath.resolve("generated")); } @Test @@ -369,6 +387,22 @@ void disableCodegen() { assertFalse(codegen.getProtobuf()); } + @Test + @DisplayName("apply Proto Dart plugin to a Dart project") + void applyProtoDart() { + DartExtension dartExtension = extension.enableDart(); + assertThat(dartExtension) + .isNotNull(); + assertApplied(ProtoDartPlugin.class); + } + + @Test + @DisplayName("apply Protobuf plugin to a Dart project") + void applyProtobufToDart() { + extension.enableDart(); + assertApplied(ProtobufPlugin.class); + } + private String baseDependency() { return "io.spine:spine-base:" + spineVersion; } @@ -414,13 +448,13 @@ private String datastoreDependency() { } private void assertApplied(Class> pluginClass) { - GradlePlugin plugin = GradlePlugin.implementedIn(pluginClass); + GradlePlugin plugin = GradlePlugin.implementedIn(pluginClass); assertTrue(pluginTarget.isApplied(plugin), format("Plugin %s must be applied.", plugin)); } private void assertNotApplied(Class> pluginClass) { - GradlePlugin plugin = GradlePlugin.implementedIn(pluginClass); + GradlePlugin plugin = GradlePlugin.implementedIn(pluginClass); assertFalse(pluginTarget.isApplied(plugin), format("Plugin %s must NOT be applied.", plugin)); } @@ -580,4 +614,14 @@ void exposeWhetherConfigurationForced() { extension.setForceDependencies(true); assertThat(extension.getForceDependencies()).isTrue(); } + + @Test + @DisplayName("add `generateDart` tasks if needed") + void addDartTasks() { + extension.enableDart(); + TaskContainer tasks = project.getTasks(); + assertThat(tasks) + .comparingElementsUsing(names) + .containsAtLeastElementsIn(DartTaskName.values()); + } } diff --git a/plugin/src/test/java/io/spine/tools/gradle/bootstrap/func/SpineBootstrapPluginTest.java b/plugin/src/test/java/io/spine/tools/gradle/bootstrap/func/SpineBootstrapPluginTest.java index 375e4f8b..e0816280 100644 --- a/plugin/src/test/java/io/spine/tools/gradle/bootstrap/func/SpineBootstrapPluginTest.java +++ b/plugin/src/test/java/io/spine/tools/gradle/bootstrap/func/SpineBootstrapPluginTest.java @@ -25,12 +25,12 @@ import com.google.common.truth.IterableSubject; import io.spine.code.proto.FileDescriptors; import io.spine.testing.SlowTest; +import io.spine.testing.TempDir; import io.spine.tools.gradle.testing.GradleProject; import org.gradle.testkit.runner.BuildResult; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; import java.io.File; import java.nio.file.Path; @@ -40,6 +40,7 @@ import static com.google.common.truth.Truth.assertThat; import static io.spine.tools.gradle.BaseTaskName.build; import static io.spine.tools.gradle.ProtoJsTaskName.generateJsonParsers; +import static io.spine.tools.gradle.bootstrap.DartExtension.TYPES_FILE; import static java.nio.file.Files.exists; import static java.util.Collections.emptySet; import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; @@ -58,8 +59,9 @@ class SpineBootstrapPluginTest { private Path projectDir; @BeforeEach - void setUp(@TempDir Path dir) { - this.projectDir = dir; + void setUp() { + this.projectDir = TempDir.forClass(SpineBootstrapPluginTest.class).toPath(); + projectDir.toFile().deleteOnExit(); this.project = GradleProject .newBuilder() .setProjectName("func-test") @@ -112,7 +114,8 @@ void applyModelCompiler() { project.executeTask(build); Collection resourceFiles = assembledResources(); - String projectDir = this.projectDir.getFileName().toString(); + String projectDir = this.projectDir.getFileName() + .toString(); boolean containsDescriptorSetFile = resourceFiles.stream() .filter(f -> f.endsWith(FileDescriptors.DESC_EXTENSION)) @@ -134,6 +137,25 @@ void generateJs() { assertThat(jsFileNames).contains("roller_coaster_pb.js"); } + @Test + @DisplayName("generate Dart if requested") + void generateDart() { + configureDartGeneration(); + GradleProject project = this.project.build(); + project.executeTask(build); + + Collection dartFileNames = generatedDartFileNames(); + String protoName = "roller_coaster"; + assertThat(dartFileNames) + .containsExactly( + TYPES_FILE, + protoName + ".pb.dart", + protoName + ".pbjson.dart", + protoName + ".pbenum.dart", + protoName + ".pbserver.dart" + ); + } + @Test @DisplayName("generate an `index.js` file") void generateIndexJs() { @@ -258,7 +280,8 @@ void noJsForModelProjects() { GradleProject project = this.project.build(); project.executeTask(build); - assertThat(generatedFiles().toFile().exists()).isFalse(); + assertThat(generatedFiles().toFile() + .exists()).isFalse(); } private void noAdditionalConfig() { @@ -280,6 +303,12 @@ private void configureJsGeneration() { ); } + private void configureDartGeneration() { + writeConfigGradle( + "spine.enableDart()" + ); + } + @SuppressWarnings("CheckReturnValue") private void configureJavaClient() { writeConfigGradle( @@ -412,4 +441,14 @@ private Collection generatedJsFileNames() { ImmutableSet packageContents = ImmutableSet.copyOf(compiledJsDir.list()); return packageContents; } + + private Collection generatedDartFileNames() { + Path libDir = projectDir.resolve("lib"); + File libDirFile = libDir.toFile(); + assertTrue(libDirFile.exists()); + assertTrue(libDirFile.isDirectory()); + @SuppressWarnings("ConstantConditions") + ImmutableSet packageContents = ImmutableSet.copyOf(libDirFile.list()); + return packageContents; + } } diff --git a/pom.xml b/pom.xml index 22374cfa..b42aac32 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-bootstrap -1.6.4 +1.6.11 2015 @@ -28,91 +28,97 @@ all modules and does not describe the project structure per-subproject. com.google.errorprone error_prone_annotations - 2.3.4 + 2.4.0 compile com.google.errorprone error_prone_type_annotations - 2.3.4 + 2.4.0 compile com.google.guava guava - 29.0-jre + 30.0-jre compile com.google.protobuf protobuf-gradle-plugin - 0.8.12 + 0.8.13 compile io.spine spine-base - 1.6.4 + 1.6.11 compile io.spine.tools spine-model-compiler - 1.6.4 + 1.6.11 compile io.spine.tools spine-plugin-base - 1.6.4 + 1.6.11 + compile + + + io.spine.tools + spine-proto-dart-plugin + 1.6.11 compile io.spine.tools spine-proto-js-plugin - 1.6.4 + 1.6.11 compile org.checkerframework checker-qual - 3.3.0 + 3.7.1 compile com.google.guava guava-testlib - 29.0-jre + 30.0-jre test com.google.truth truth - 1.0.1 + 1.1 test com.google.truth.extensions truth-java8-extension - 1.0.1 + 1.1 test com.google.truth.extensions truth-proto-extension - 1.0.1 + 1.1 test io.spine spine-testlib - 1.6.4 + 1.6.11 test io.spine.tools spine-plugin-testlib - 1.6.4 + 1.6.11 test @@ -124,36 +130,31 @@ all modules and does not describe the project structure per-subproject. org.junit.jupiter junit-jupiter-api - 5.6.2 + 5.7.0 test org.junit.jupiter junit-jupiter-engine - 5.6.2 + 5.7.0 test org.junit.jupiter junit-jupiter-params - 5.6.2 + 5.7.0 test com.google.errorprone error_prone_core - 2.3.4 + 2.4.0 com.google.errorprone javac 9+181-r4173-1 - - io.spine.tools - spine-protoc-plugin - 1.6.4 - net.sourceforge.pmd pmd-java diff --git a/version.gradle.kts b/version.gradle.kts index 12a15b4d..31e5132f 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -29,9 +29,9 @@ * already in the root directory. */ -val spineBaseVersion: String by extra("1.6.4") +val spineBaseVersion: String by extra("1.6.11") val spineTimeVersion: String by extra("1.6.0") -val spineVersion: String by extra("1.6.4") -val spineWebVersion: String by extra("1.6.0") -val spineGCloudVersion: String by extra("1.6.0") -val pluginVersion: String by extra("1.6.5") +val spineVersion: String by extra("1.6.6") +val spineWebVersion: String by extra("1.6.6") +val spineGCloudVersion: String by extra("1.6.6") +val pluginVersion: String by extra("1.6.11")