diff --git a/base-validating-builders/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt b/base-validating-builders/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt index 163234f79f..3e9250e751 100644 --- a/base-validating-builders/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt +++ b/base-validating-builders/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt @@ -98,6 +98,10 @@ object Versions { val animalSniffer = "1.18" val apiguardian = "1.1.0" val javaxAnnotation = "1.3.2" + val klaxon = "5.4" + val ouathJwt = "3.10.3" + val bouncyCastlePkcs = "1.66" + val assertK = "0.22" /** * Version of the SLF4J library. @@ -159,7 +163,7 @@ object Build { object AutoService { val annotations = "com.google.auto.service:auto-service-annotations:${Versions.autoService}" - val processor = "com.google.auto.service:auto-service:${Versions.autoService}" + val processor = "com.google.auto.service:auto-service:${Versions.autoService}" } } @@ -168,6 +172,13 @@ object Gen { val javaxAnnotation = "javax.annotation:javax.annotation-api:${Versions.javaxAnnotation}" } +object Publishing { + val klaxon = "com.beust:klaxon:${Versions.klaxon}" + val oauthJwt = "com.auth0:java-jwt:${Versions.ouathJwt}" + val bouncyCastlePkcs = "org.bouncycastle:bcpkix-jdk15on:${Versions.bouncyCastlePkcs}" + val assertK = "com.willowtreeapps.assertk:assertk-jvm:${Versions.assertK}" +} + object Grpc { val core = "io.grpc:grpc-core:${Versions.grpc}" val stub = "io.grpc:grpc-stub:${Versions.grpc}" @@ -275,6 +286,7 @@ object Deps { val test = Test val versions = Versions val scripts = Scripts + val publishing = Publishing } object DependencyResolution { diff --git a/base/src/main/java/io/spine/io/Resource.java b/base/src/main/java/io/spine/io/Resource.java index 6788568713..e72299bff5 100644 --- a/base/src/main/java/io/spine/io/Resource.java +++ b/base/src/main/java/io/spine/io/Resource.java @@ -25,8 +25,10 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.UnmodifiableIterator; +import com.google.common.io.CharStreams; import org.checkerframework.checker.nullness.qual.Nullable; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -203,6 +205,21 @@ public Reader openAsText() { return openAsText(UTF_8); } + /** + * Loads the whole resource file as a UTF-8 text file. + * + * @return the content of the resource file + * @throws IllegalStateException + * on a failure of opening the file, e.g. if the file does not exist + * @throws IOException + * on a failure of reading or closing the file + */ + public String read() throws IOException { + try (Reader reader = new BufferedReader(openAsText())) { + return CharStreams.toString(reader); + } + } + @Override public String toString() { return loaderCustomized() ? path + " via " + classLoader() : path; 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 163234f79f..3e9250e751 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt @@ -98,6 +98,10 @@ object Versions { val animalSniffer = "1.18" val apiguardian = "1.1.0" val javaxAnnotation = "1.3.2" + val klaxon = "5.4" + val ouathJwt = "3.10.3" + val bouncyCastlePkcs = "1.66" + val assertK = "0.22" /** * Version of the SLF4J library. @@ -159,7 +163,7 @@ object Build { object AutoService { val annotations = "com.google.auto.service:auto-service-annotations:${Versions.autoService}" - val processor = "com.google.auto.service:auto-service:${Versions.autoService}" + val processor = "com.google.auto.service:auto-service:${Versions.autoService}" } } @@ -168,6 +172,13 @@ object Gen { val javaxAnnotation = "javax.annotation:javax.annotation-api:${Versions.javaxAnnotation}" } +object Publishing { + val klaxon = "com.beust:klaxon:${Versions.klaxon}" + val oauthJwt = "com.auth0:java-jwt:${Versions.ouathJwt}" + val bouncyCastlePkcs = "org.bouncycastle:bcpkix-jdk15on:${Versions.bouncyCastlePkcs}" + val assertK = "com.willowtreeapps.assertk:assertk-jvm:${Versions.assertK}" +} + object Grpc { val core = "io.grpc:grpc-core:${Versions.grpc}" val stub = "io.grpc:grpc-stub:${Versions.grpc}" @@ -275,6 +286,7 @@ object Deps { val test = Test val versions = Versions val scripts = Scripts + val publishing = Publishing } object DependencyResolution { diff --git a/config b/config index 15df4f3934..a92f5382c8 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 15df4f3934ec0ce0a9a5d1be087df623f2d50598 +Subproject commit a92f5382c816462dcfe7b4dc9aaab41aafc003ca diff --git a/license-report.md b/license-report.md index 05a2bac5c4..cc10127b63 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-base:1.5.26` +# Dependencies of `io.spine:spine-base:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -329,12 +329,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:51 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 **Wed Aug 26 14:44:28 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-errorprone-checks:1.5.26` +# Dependencies of `io.spine.tools:spine-errorprone-checks:1.5.27` ## Runtime 1. **Group:** com.github.ben-manes.caffeine **Name:** caffeine **Version:** 2.7.0 @@ -785,12 +785,12 @@ This report was generated on **Fri Aug 21 18:11:51 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:51 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 **Wed Aug 26 14:44:29 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-javadoc-filter:1.5.26` +# Dependencies of `io.spine.tools:spine-javadoc-filter:1.5.27` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1169,12 +1169,12 @@ This report was generated on **Fri Aug 21 18:11:51 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:52 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 **Wed Aug 26 14:44:29 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-javadoc-prettifier:1.5.26` +# Dependencies of `io.spine.tools:spine-javadoc-prettifier:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1545,12 +1545,12 @@ This report was generated on **Fri Aug 21 18:11:52 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:52 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 **Wed Aug 26 14:44:29 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-compiler:1.5.26` +# Dependencies of `io.spine.tools:spine-model-compiler:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1937,12 +1937,12 @@ This report was generated on **Fri Aug 21 18:11:52 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:53 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 **Wed Aug 26 14:44: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.tools:spine-mute-logging:1.5.26` +# Dependencies of `io.spine.tools:spine-mute-logging:1.5.27` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -2317,12 +2317,12 @@ This report was generated on **Fri Aug 21 18:11:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:53 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 **Wed Aug 26 14:44: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.tools:spine-plugin-base:1.5.26` +# Dependencies of `io.spine.tools:spine-plugin-base:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -2693,12 +2693,12 @@ This report was generated on **Fri Aug 21 18:11:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:53 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 **Wed Aug 26 14:44: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.tools:spine-plugin-testlib:1.5.26` +# Dependencies of `io.spine.tools:spine-plugin-testlib:1.5.27` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -3123,12 +3123,12 @@ This report was generated on **Fri Aug 21 18:11:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:54 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 **Wed Aug 26 14:44: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). -# Dependencies of `io.spine.tools:spine-proto-dart-plugin:1.5.26` +# Dependencies of `io.spine.tools:spine-proto-dart-plugin:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3499,12 +3499,12 @@ This report was generated on **Fri Aug 21 18:11:54 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:54 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 **Wed Aug 26 14:44: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). -# Dependencies of `io.spine.tools:spine-proto-js-plugin:1.5.26` +# Dependencies of `io.spine.tools:spine-proto-js-plugin:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3875,12 +3875,12 @@ This report was generated on **Fri Aug 21 18:11:54 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:54 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 **Wed Aug 26 14:44: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). -# Dependencies of `io.spine.tools:spine-protoc-api:1.5.26` +# Dependencies of `io.spine.tools:spine-protoc-api:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4201,12 +4201,12 @@ This report was generated on **Fri Aug 21 18:11:54 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:55 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 **Wed Aug 26 14:44:32 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-protoc-plugin:1.5.26` +# Dependencies of `io.spine.tools:spine-protoc-plugin:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4545,12 +4545,12 @@ This report was generated on **Fri Aug 21 18:11:55 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:55 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 **Wed Aug 26 14:44:32 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-testlib:1.5.26` +# Dependencies of `io.spine:spine-testlib:1.5.27` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -4925,12 +4925,12 @@ This report was generated on **Fri Aug 21 18:11:55 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:55 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 **Wed Aug 26 14:44:32 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-tool-base:1.5.26` +# Dependencies of `io.spine.tools:spine-tool-base:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5269,12 +5269,12 @@ This report was generated on **Fri Aug 21 18:11:55 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:56 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 **Wed Aug 26 14:44: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.tools:spine-validation-generator:1.5.26` +# Dependencies of `io.spine.tools:spine-validation-generator:1.5.27` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5613,4 +5613,4 @@ This report was generated on **Fri Aug 21 18:11:56 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Aug 21 18:11:56 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 **Wed Aug 26 14:44: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). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6caa600aa8..77249425d0 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-base -1.5.26 +1.5.27 2015 @@ -154,7 +154,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-protoc-plugin - 1.5.26 + 1.5.27 test diff --git a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/CopyPluginJar.java b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/CopyPluginJar.java deleted file mode 100644 index 920b72a8a3..0000000000 --- a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/CopyPluginJar.java +++ /dev/null @@ -1,75 +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. - */ - -package io.spine.tools.gradle.compiler; - -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.Dependency; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -import static com.google.common.base.Preconditions.checkNotNull; -import static io.spine.tools.gradle.compiler.JavaProtocConfigurationPlugin.rootSpineDirectory; -import static io.spine.tools.gradle.compiler.JavaProtocConfigurationPlugin.spineDirectory; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; - -/** - * Downloads and lays out the {@code protoc} plugin executable JAR. - */ -public final class CopyPluginJar implements Action { - - private final Project project; - private final Dependency protocPluginDependency; - private final Configuration fetch; - - CopyPluginJar(Project project, Dependency protocPlugin, Configuration fetch) { - this.project = checkNotNull(project); - this.protocPluginDependency = checkNotNull(protocPlugin); - this.fetch = checkNotNull(fetch); - } - - @Override - public void execute(Task task) { - File executableJar = fetch.fileCollection(protocPluginDependency) - .getSingleFile(); - File spineDir = spineDirectory(project); - File rootSpineDir = rootSpineDirectory(project); - copy(executableJar, spineDir); - copy(executableJar, rootSpineDir); - } - - private static void copy(File file, File destinationDir) { - try { - destinationDir.mkdirs(); - Path destination = destinationDir.toPath() - .resolve(file.getName()); - Files.copy(file.toPath(), destination, REPLACE_EXISTING); - } catch (IOException e) { - throw new GradleException("Failed to copy Spine Protoc executable JAR.", e); - } - } -} diff --git a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/JavaProtocConfigurationPlugin.java b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/JavaProtocConfigurationPlugin.java index d5f4ddbba3..7479ae69aa 100644 --- a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/JavaProtocConfigurationPlugin.java +++ b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/JavaProtocConfigurationPlugin.java @@ -20,19 +20,20 @@ package io.spine.tools.gradle.compiler; -import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper; +import com.google.common.base.Charsets; +import com.google.common.io.CharSink; import com.google.protobuf.gradle.ExecutableLocator; import com.google.protobuf.gradle.GenerateProtoTask; import io.spine.code.fs.java.DefaultJavaProject; import io.spine.code.fs.java.DefaultJavaProject.GeneratedRoot; import io.spine.code.proto.DescriptorReference; +import io.spine.io.Resource; import io.spine.tools.gradle.Artifact; import io.spine.tools.gradle.ConfigurationName; import io.spine.tools.gradle.GradleTask; import io.spine.tools.gradle.ProtocConfigurationPlugin; import io.spine.tools.gradle.SourceScope; import io.spine.tools.gradle.TaskName; -import org.gradle.api.Action; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Project; import org.gradle.api.Task; @@ -41,21 +42,29 @@ import org.gradle.api.plugins.JavaPluginConvention; import java.io.File; +import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Base64; +import java.util.regex.Matcher; +import java.util.regex.Pattern; -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.io.Files.asCharSink; import static io.spine.code.fs.java.DefaultJavaProject.at; import static io.spine.tools.gradle.BaseTaskName.clean; -import static io.spine.tools.gradle.ModelCompilerTaskName.copyPluginJar; +import static io.spine.tools.gradle.ConfigurationName.fetch; import static io.spine.tools.gradle.ModelCompilerTaskName.writeDescriptorReference; import static io.spine.tools.gradle.ModelCompilerTaskName.writePluginConfiguration; import static io.spine.tools.gradle.ModelCompilerTaskName.writeTestDescriptorReference; import static io.spine.tools.gradle.ModelCompilerTaskName.writeTestPluginConfiguration; import static io.spine.tools.gradle.ProtocPluginName.grpc; import static io.spine.tools.gradle.ProtocPluginName.spineProtoc; +import static io.spine.util.Exceptions.illegalStateWithCauseOf; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.nio.file.Files.createTempFile; +import static java.util.regex.Matcher.quoteReplacement; +import static org.gradle.internal.os.OperatingSystem.current; /** * A Gradle plugin that performs additional {@code protoc} configurations relevant for Java @@ -63,18 +72,83 @@ */ public final class JavaProtocConfigurationPlugin extends ProtocConfigurationPlugin { - private static final String PLUGIN_ARTIFACT_PROPERTY = "Protoc plugin artifact"; private static final String JAR_EXTENSION = "jar"; - private static final String GRPC_GROUP = "io.grpc"; private static final String GRPC_PLUGIN_NAME = "protoc-gen-grpc-java"; + private static final String DOT_SH = ".sh"; + private static final String DOT_BAT = ".bat"; + private static final String SPINE_PLUGIN_NAME = "spine-protoc-plugin"; + private static final Pattern JAR_FILE_INSERTION_POINT = Pattern.compile("\\{jar-file}"); + + @Override + protected void + configureProtocPlugins(NamedDomainObjectContainer plugins, Project project) { + plugins.create(grpc.name(), + locator -> locator.setArtifact(Artifact.newBuilder() + .setGroup(GRPC_GROUP) + .setName(GRPC_PLUGIN_NAME) + .setVersion(VERSIONS.grpc()) + .build() + .notation())); + project.afterEvaluate(p -> { + Dependency dependency = pluginJarDependency(project); + Path jarFile = project.getConfigurations() + .getByName(fetch.name()) + .fileCollection(dependency) + .getSingleFile() + .toPath() + .toAbsolutePath(); + plugins.create(spineProtoc.name(), + locator -> locator.setPath(tryWriteLaunchScript(jarFile).toString())); + }); + } + + private static Dependency pluginJarDependency(Project project) { + Configuration fetch = project.getConfigurations() + .maybeCreate(ConfigurationName.fetch.name()); + Artifact protocPluginArtifact = Artifact + .newBuilder() + .useSpineToolsGroup() + .setName(SPINE_PLUGIN_NAME) + .setVersion(VERSIONS.spineBase()) + .setExtension(JAR_EXTENSION) + .build(); + Dependency protocPluginDependency = project + .getDependencies() + .add(fetch.getName(), protocPluginArtifact.notation()); + return protocPluginDependency; + } + + private static Path tryWriteLaunchScript(Path jarFile) { + try { + return writeLaunchScript(jarFile); + } catch (IOException e) { + throw illegalStateWithCauseOf(e); + } + } + + private static Path writeLaunchScript(Path jarFile) throws IOException { + boolean windows = current().isWindows(); + String scriptExt = windows ? DOT_BAT : DOT_SH; + Resource launcherTemplate = Resource.file("plugin_runner" + scriptExt); + String template = launcherTemplate.read(); + Matcher matcher = JAR_FILE_INSERTION_POINT.matcher(template); + String script = matcher.replaceAll(quoteReplacement(jarFile.toString())); + Path path = createTempFile(JavaProtocConfigurationPlugin.class.getSimpleName(), scriptExt); + File file = path.toFile(); + CharSink sink = asCharSink(file, UTF_8); + sink.write(script); + boolean canBeExecuted = file.setExecutable(true, false); + checkState(canBeExecuted, "Failed to make file `%s` executable.", file); + return path; + } @Override protected void customizeTask(GenerateProtoTask protocTask) { customizeDescriptorSetGeneration(protocTask); Path spineProtocConfigPath = spineProtocConfigPath(protocTask); Task writeConfig = newWriteSpineProtocConfigTask(protocTask, spineProtocConfigPath); - protocTask.dependsOn(createCopyPluginJarTask(protocTask.getProject()), writeConfig); + protocTask.dependsOn(writeConfig); protocTask.getPlugins() .create(grpc.name()); protocTask.getPlugins() @@ -97,7 +171,8 @@ private void customizeDescriptorSetGeneration(GenerateProtoTask protocTask) { .getPlugin(JavaPluginConvention.class); SourceScope sourceScope = tests ? SourceScope.test : SourceScope.main; File descriptorFile = new File(protocTask.getDescriptorPath()); - Path resourceDirectory = descriptorFile.toPath().getParent(); + Path resourceDirectory = descriptorFile.toPath() + .getParent(); javaConvention.getSourceSets() .getByName(sourceScope.name()) .getResources() @@ -110,59 +185,6 @@ private void customizeDescriptorSetGeneration(GenerateProtoTask protocTask) { protocTask.finalizedBy(writeRef.getTask()); } - private Task createCopyPluginJarTask(Project project) { - Configuration fetch = project.getConfigurations() - .maybeCreate(ConfigurationName.fetch.name()); - Artifact protocPluginArtifact = Artifact - .newBuilder() - .useSpineToolsGroup() - .setName(SPINE_PLUGIN_NAME) - .setVersion(VERSIONS.spineBase()) - .setExtension(JAR_EXTENSION) - .build(); - Dependency protocPluginDependency = project - .getDependencies() - .add(fetch.getName(), protocPluginArtifact.notation()); - checkNotNull(protocPluginDependency, - "Could not create dependency %s %s", fetch.getName(), protocPluginArtifact); - Action action = new CopyPluginJar(project, protocPluginDependency, fetch); - - Task copyPluginJarTask = project.getTasks() - .findByPath(copyPluginJar.name()); - if (copyPluginJarTask == null) { - GradleTask copyPluginJarBuilder = newTask(copyPluginJar, action) - .allowNoDependencies() - .withInputProperty(PLUGIN_ARTIFACT_PROPERTY, protocPluginArtifact.notation()) - .withOutputFiles(project.fileTree(spineDirectory(project))) - .withOutputFiles(project.fileTree(rootSpineDirectory(project))) - .applyNowTo(project); - copyPluginJarTask = copyPluginJarBuilder.getTask(); - } - return copyPluginJarTask; - } - - static File spineDirectory(Project project) { - return at(project.getProjectDir()).tempArtifacts(); - } - - static File rootSpineDirectory(Project project) { - return at(project.getRootDir()).tempArtifacts(); - } - - @OverridingMethodsMustInvokeSuper - @Override - protected void - configureProtocPlugins(NamedDomainObjectContainer plugins) { - super.configureProtocPlugins(plugins); - plugins.create(grpc.name(), - locator -> locator.setArtifact(Artifact.newBuilder() - .setGroup(GRPC_GROUP) - .setName(GRPC_PLUGIN_NAME) - .setVersion(VERSIONS.grpc()) - .build() - .notation())); - } - @Override protected File getTestDescriptorSet(Project project) { return Extension.getTestDescriptorSet(project); @@ -197,7 +219,7 @@ private Task newWriteSpineProtocConfigTask(GenerateProtoTask protocTask, Path co private static String base64Encoded(String value) { Base64.Encoder encoder = Base64.getEncoder(); - byte[] valueBytes = value.getBytes(UTF_8); + byte[] valueBytes = value.getBytes(Charsets.UTF_8); String result = encoder.encodeToString(valueBytes); return result; } diff --git a/tools/model-compiler/src/main/resources/plugin_runner.bat b/tools/model-compiler/src/main/resources/plugin_runner.bat new file mode 100644 index 0000000000..c21bc1507a --- /dev/null +++ b/tools/model-compiler/src/main/resources/plugin_runner.bat @@ -0,0 +1,3 @@ +@echo off + +java -jar {jar-file} diff --git a/tools/model-compiler/src/main/resources/plugin_runner.sh b/tools/model-compiler/src/main/resources/plugin_runner.sh new file mode 100644 index 0000000000..a18ce9aa18 --- /dev/null +++ b/tools/model-compiler/src/main/resources/plugin_runner.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +java -jar {jar-file} diff --git a/tools/plugin-base/src/main/java/io/spine/tools/gradle/ModelCompilerTaskName.java b/tools/plugin-base/src/main/java/io/spine/tools/gradle/ModelCompilerTaskName.java index 3da907de28..5af66a8c93 100644 --- a/tools/plugin-base/src/main/java/io/spine/tools/gradle/ModelCompilerTaskName.java +++ b/tools/plugin-base/src/main/java/io/spine/tools/gradle/ModelCompilerTaskName.java @@ -73,11 +73,6 @@ public enum ModelCompilerTaskName implements TaskName { */ mergeTestDescriptorSet, - /** - * Downloads the Protobuf compiler plugin executable JAR into the required paths in the project. - */ - copyPluginJar, - /** * Creates the Protobuf compiler plugin configuration. * diff --git a/tools/plugin-base/src/main/java/io/spine/tools/gradle/ProtocConfigurationPlugin.java b/tools/plugin-base/src/main/java/io/spine/tools/gradle/ProtocConfigurationPlugin.java index 19e851772e..5e763d53e2 100644 --- a/tools/plugin-base/src/main/java/io/spine/tools/gradle/ProtocConfigurationPlugin.java +++ b/tools/plugin-base/src/main/java/io/spine/tools/gradle/ProtocConfigurationPlugin.java @@ -21,12 +21,12 @@ package io.spine.tools.gradle; import com.google.common.collect.ImmutableList; -import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper; import com.google.protobuf.gradle.ExecutableLocator; import com.google.protobuf.gradle.GenerateProtoTask; import com.google.protobuf.gradle.ProtobufConfigurator; import com.google.protobuf.gradle.ProtobufConfigurator.GenerateProtoTaskCollection; import com.google.protobuf.gradle.ProtobufConvention; +import io.spine.tools.groovy.ConsumerClosure; import io.spine.tools.groovy.GStrings; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Project; @@ -37,9 +37,7 @@ import static io.spine.tools.gradle.ProtobufDependencies.gradlePlugin; import static io.spine.tools.gradle.ProtobufDependencies.protobufCompiler; -import static io.spine.tools.gradle.ProtocPluginName.spineProtoc; import static io.spine.tools.groovy.ConsumerClosure.closure; -import static org.gradle.internal.os.OperatingSystem.current; /** * An abstract base for Gradle plugins that configure Protobuf compilation. @@ -49,11 +47,6 @@ */ public abstract class ProtocConfigurationPlugin extends SpinePlugin { - protected static final String SPINE_PLUGIN_NAME = "spine-protoc-plugin"; - private static final String SH_EXTENSION = "sh"; - private static final String BAT_EXTENSION = "bat"; - private static final String SCRIPT_CLASSIFIER = "script"; - protected static final DependencyVersions VERSIONS = DependencyVersions.get(); @Override @@ -78,7 +71,10 @@ private void configureProtobuf(Project project, ProtobufConfigurator protobuf) { protocLocator.setArtifact(protobufCompiler() .ofVersion(version) .notation()))); - protobuf.plugins(closure(this::configureProtocPlugins)); + ConsumerClosure> pluginConfig = closure( + plugins -> configureProtocPlugins(plugins, project) + ); + protobuf.plugins(pluginConfig); protobuf.generateProtoTasks(closure(this::configureProtocTasks)); } @@ -103,32 +99,14 @@ private void configureProtocTasks(GenerateProtoTaskCollection tasks) { * * @param plugins * container of all plugins + * @param project + * the target project in which the codegen occurs * @apiNote overriding methods must invoke super to add the {@code spineProtoc} plugin, * which * is a required plugin */ - @OverridingMethodsMustInvokeSuper - protected void configureProtocPlugins(NamedDomainObjectContainer plugins) { - if (!spineProtocIsPresent(plugins)) { - plugins.create(spineProtoc.name(), locator -> { - boolean windows = current().isWindows(); - String scriptExt = windows ? BAT_EXTENSION : SH_EXTENSION; - locator.setArtifact(Artifact.newBuilder() - .useSpineToolsGroup() - .setName(SPINE_PLUGIN_NAME) - .setVersion(VERSIONS.spineBase()) - .setClassifier(SCRIPT_CLASSIFIER) - .setExtension(scriptExt) - .build() - .notation()); - }); - } - } - - private static boolean - spineProtocIsPresent(NamedDomainObjectContainer plugins) { - return plugins.findByName(spineProtoc.name()) != null; - } + protected abstract void + configureProtocPlugins(NamedDomainObjectContainer plugins, Project project); private void configureProtocTask(GenerateProtoTask protocTask) { configureDescriptorSetGeneration(protocTask); diff --git a/tools/proto-dart-plugin/src/main/java/io/spine/generate/dart/DartProtocConfigurationPlugin.java b/tools/proto-dart-plugin/src/main/java/io/spine/generate/dart/DartProtocConfigurationPlugin.java index 109459be93..91c536319a 100644 --- a/tools/proto-dart-plugin/src/main/java/io/spine/generate/dart/DartProtocConfigurationPlugin.java +++ b/tools/proto-dart-plugin/src/main/java/io/spine/generate/dart/DartProtocConfigurationPlugin.java @@ -20,7 +20,6 @@ package io.spine.generate.dart; -import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper; import com.google.protobuf.gradle.ExecutableLocator; import io.spine.tools.gradle.ProtocConfigurationPlugin; import org.gradle.api.NamedDomainObjectContainer; @@ -52,10 +51,9 @@ protected File getTestDescriptorSet(Project project) { return Extension.findIn(project).testDescriptorSetFile(); } - @OverridingMethodsMustInvokeSuper @Override - protected void configureProtocPlugins(NamedDomainObjectContainer plugins) { - super.configureProtocPlugins(plugins); + protected void configureProtocPlugins(NamedDomainObjectContainer plugins, + Project project) { Path executable = CachedDartProtocPlugin.locate(); plugins.create(dart.name(), locator -> locator.setPath(executable.toString())); } diff --git a/tools/proto-js-plugin/src/main/java/io/spine/js/gradle/JsProtocConfigurationPlugin.java b/tools/proto-js-plugin/src/main/java/io/spine/js/gradle/JsProtocConfigurationPlugin.java index 2a5e7cf13e..bc0a533302 100644 --- a/tools/proto-js-plugin/src/main/java/io/spine/js/gradle/JsProtocConfigurationPlugin.java +++ b/tools/proto-js-plugin/src/main/java/io/spine/js/gradle/JsProtocConfigurationPlugin.java @@ -20,8 +20,10 @@ package io.spine.js.gradle; +import com.google.protobuf.gradle.ExecutableLocator; import io.spine.code.fs.js.DefaultJsProject; import io.spine.tools.gradle.ProtocConfigurationPlugin; +import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Project; import java.io.File; @@ -49,4 +51,10 @@ protected Path generatedFilesBaseDir(Project project) { protected File getMainDescriptorSet(Project project) { return Extension.getMainDescriptorSet(project); } + + @Override + protected void configureProtocPlugins(NamedDomainObjectContainer plugins, + Project project) { + // Do nothing. + } } diff --git a/tools/protoc-plugin/build.gradle.kts b/tools/protoc-plugin/build.gradle.kts index bbba0eb00b..7964c6d22d 100644 --- a/tools/protoc-plugin/build.gradle.kts +++ b/tools/protoc-plugin/build.gradle.kts @@ -19,7 +19,6 @@ */ import io.spine.gradle.internal.Deps -import java.nio.file.Files group = "io.spine.tools" @@ -52,41 +51,3 @@ tasks.jar { } }) } - -val shellRunner = injectVersion(file("plugin_runner.sh")) -val batchRunner = injectVersion(file("plugin_runner.bat")) - -artifacts { - archives(shellRunner) { - classifier = "script" - } - archives(batchRunner) { - classifier = "script" - } -} - -/** - * Inserts the current Spine version into the given file replacing the {@code {@literal {version}}} - * string. - * - *

This insertion point is conventional for the runner scripts for the Spine protoc plugin. - * - *

Before the runner script is published, the version must be injected into it. - * - *

The standard Grade filtering mechanism (involving the Copy task) cannot be used in this case - * since the injection should be performed on the configuration stage. - * - * @param scriptFile the script file to modify - * @return the new script file to publish - */ -fun injectVersion(scriptFile: File): File { - var text = scriptFile.readText() - text = text.replace("{version}", project.version as String) - val extension = when { - scriptFile.name.endsWith(".sh") -> ".sh" - else -> ".bat" - } - val tempFile = Files.createTempFile("build", extension) - tempFile.toFile().writeText(text) - return project.file(tempFile.toAbsolutePath()) -} diff --git a/tools/protoc-plugin/plugin_runner.bat b/tools/protoc-plugin/plugin_runner.bat deleted file mode 100644 index 2f0c10d197..0000000000 --- a/tools/protoc-plugin/plugin_runner.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -java -jar ./.spine/spine-protoc-plugin-{version}.jar diff --git a/tools/protoc-plugin/plugin_runner.sh b/tools/protoc-plugin/plugin_runner.sh deleted file mode 100644 index 777a998c02..0000000000 --- a/tools/protoc-plugin/plugin_runner.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -CURRENT_DIR="$(pwd)" - -java -jar "${CURRENT_DIR}"/.spine/spine-protoc-plugin-{version}.jar diff --git a/tools/smoke-tests/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt b/tools/smoke-tests/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt index 163234f79f..3e9250e751 100644 --- a/tools/smoke-tests/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt +++ b/tools/smoke-tests/buildSrc/src/main/kotlin/io/spine/gradle/internal/deps.kt @@ -98,6 +98,10 @@ object Versions { val animalSniffer = "1.18" val apiguardian = "1.1.0" val javaxAnnotation = "1.3.2" + val klaxon = "5.4" + val ouathJwt = "3.10.3" + val bouncyCastlePkcs = "1.66" + val assertK = "0.22" /** * Version of the SLF4J library. @@ -159,7 +163,7 @@ object Build { object AutoService { val annotations = "com.google.auto.service:auto-service-annotations:${Versions.autoService}" - val processor = "com.google.auto.service:auto-service:${Versions.autoService}" + val processor = "com.google.auto.service:auto-service:${Versions.autoService}" } } @@ -168,6 +172,13 @@ object Gen { val javaxAnnotation = "javax.annotation:javax.annotation-api:${Versions.javaxAnnotation}" } +object Publishing { + val klaxon = "com.beust:klaxon:${Versions.klaxon}" + val oauthJwt = "com.auth0:java-jwt:${Versions.ouathJwt}" + val bouncyCastlePkcs = "org.bouncycastle:bcpkix-jdk15on:${Versions.bouncyCastlePkcs}" + val assertK = "com.willowtreeapps.assertk:assertk-jvm:${Versions.assertK}" +} + object Grpc { val core = "io.grpc:grpc-core:${Versions.grpc}" val stub = "io.grpc:grpc-stub:${Versions.grpc}" @@ -275,6 +286,7 @@ object Deps { val test = Test val versions = Versions val scripts = Scripts + val publishing = Publishing } object DependencyResolution { diff --git a/version.gradle.kts b/version.gradle.kts index 56669201bd..8609a1d222 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -25,7 +25,7 @@ * as we want to manage the versions in a single source. */ -val SPINE_VERSION = "1.5.26" +val SPINE_VERSION = "1.5.27" project.extra.apply { this["spineVersion"] = SPINE_VERSION