diff --git a/.github/workflows/check-code-embedding.yml b/.github/workflows/check-code-embedding.yml new file mode 100644 index 0000000..ff00d62 --- /dev/null +++ b/.github/workflows/check-code-embedding.yml @@ -0,0 +1,37 @@ +name: Check Code Embedding + +on: + pull_request: + +jobs: + build-embedded-code: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + submodules: 'recursive' + + - uses: actions/setup-java@v5 + with: + java-version: 8 + distribution: zulu + + - run: ./gradlew :buildAll + + check-embedded-samples: + # TODO:2025-12-16:julia.evseeva: Remove the `if: false` when the issue + # will be fixed https://github.com/SpineEventEngine/embed-code/issues/66 + if: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + submodules: 'recursive' + + - uses: actions/setup-java@v5 + with: + java-version: 11 + distribution: zulu + + - name: Check Embedding + run: ./gradlew :checkSamples diff --git a/.gitignore b/.gitignore index 143eaf0..c766456 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,13 @@ jsconfig.json # The `embed-code` temporary directory _code/build + +# Local Java version for this project +.java-version + +# Gradle interim configs +.gradle/ + +# Gradle build files +build/ +generated/ diff --git a/README.md b/README.md index cf7411e..9245a41 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,15 @@ are working as intended. It allows making changes more convenient for authors. ## Prerequisites -1. Install [Go][go] at least version `1.12`. -2. Install [Node.js][nodejs]. Its version should be `18+`. -3. Install [Hugo Extended][hugo-quick-start] at least version `v0.145` or higher. -4. Get access to the [`site-commons`][site-commons] repository from the admins +1. Install [Java JDK] version `11` to build the site. +2. Install [Go][go] at least version `1.12`. +3. Install [Node.js][nodejs]. Its version should be `18+`. +4. Install [Hugo Extended][hugo-quick-start] at least version `v0.145` or higher. +5. Get access to the [`site-commons`][site-commons] repository from the admins to be able to download the theme. -5. Make sure [SSH][site-commons-ssh] is configured correctly and the passphrase is stored in the keychain. +6. Make sure [SSH][site-commons-ssh] is configured correctly and the passphrase + is stored in the keychain. +7. Install project dependencies from the `site` directory by running `npm install`. ## Running the documentation locally @@ -35,16 +38,22 @@ The project has two directories: * `site` – contains the HTML and CSS files needed only to run the documentation locally. -To run the documentation locally: +To build and launch the site on the local server: -1. Navigate to the `site` directory. -2. Install project dependencies: +```shell +./gradlew :runSite +``` - ```shell - npm install - ``` +To build the site without running the server: + +```shell +./gradlew :buildSite +``` + +Another way to run the site locally is to follow these steps: -3. Run the site locally: +1. Navigate to the `site` folder. +2. Start the local server with this command: ```shell hugo server @@ -92,6 +101,20 @@ the [`embed-code`][embed-code] Go subcommand. The code resides under the `_code` directory. For instructions on embedding the code into the pages, please see the [`EMBEDDING.md`](./_code/EMBEDDING.md) file. +Please note that the following part of the script requires an ARM-based Mac. + +To embed the code samples, run: + +```shell +./gradlew :embedCode +``` + +To verify that the source code samples embedded into the pages are up-to-date, run: + +```shell +./gradlew :checkSamples +``` + ## Product release To release a new version of Spine documentation, see the [SPINE_RELEASE.md](SPINE_RELEASE.md). diff --git a/_code/EMBEDDING.md b/_code/EMBEDDING.md index 602b092..6d1c46e 100644 --- a/_code/EMBEDDING.md +++ b/_code/EMBEDDING.md @@ -25,6 +25,7 @@ of the spine.io documentation: * `examples` — contains examples selected from the repositories under `spine-examples` organization. These repositories are added to this project as Git submodules. +* `samples` — smaller pieces of code embedded to the site. To get the latest version of the code snippets, update the submodules: @@ -50,7 +51,7 @@ to the documentation files using the tool. The most important points here are: ### How to update an existing code snippet? 1. Update the snippet in the appropriate repository. -2. Make sure it builds successfully: `./gradlew build`. +2. Make sure it builds successfully. 3. Go to the `SpineEventEngine/documentation` project. 4. Navigate to the `_code` directory. 5. Execute the binary based on your operating system and architecture: @@ -61,20 +62,44 @@ to the documentation files using the tool. The most important points here are: ./embed-code-macos -config-path="config-v1.yml" -mode="embed" ``` -### How to add a new code snippet? +### Adding a new example project -1. Add a new snippet in the appropriate repository. -2. Make sure it builds successfully: `./gradlew build`. -3. Go to the `SpineEventEngine/documentation` project and insert code - embedding directives where needed. -4. Navigate to the `_code` directory. -5. Execute: `./embed-code -config-path="config-of-your-choice.yml" -mode="embed"`. +1. Make sure the project you're going to add has a top-level `buildAll` Gradle task. + + See the build script of [Hello Example](https://github.com/spine-examples/hello/blob/master/build.gradle) + for the declaration of such a task. This task must be present in both single- + and multi-module Gradle example projects that are going to be used for + embedding into this site. + + See the declaration of `buildAll` task for more details. + +2. Add the example code as a submodule for this project: + + ```bash + git submodule add https://github.com/spine-examples/ _code/examples/ + ``` + Please make sure the new submodule goes under the `_code/examples` directory, as shown in + the command line template above. + +3. Include the build of the added project into the [`settings.gradle.kts`](settings.gradle.kts) + file. +4. Insert code embedding directives where needed in the `docs/content/` folder. +5. Navigate to the `_code` directory. +6. Execute: `./embed-code -config-path="config-of-your-choice.yml" -mode="embed"`. For example: ```shell ./embed-code-macos -config-path="config-v1.yml" -mode="embed" ``` +### Adding a new small piece + +1. Add the code under `_code/samples/src` directory. +2. Make sure tests for the new code pass. +3. Add the new piece using the [`embed-code` guide][embed-code-readme]. +4. Include the build of the added project into the [`settings.gradle.kts`](settings.gradle.kts) + file `includeBuild("./_code/samples")`. + ### How to remove a code snippet? 1. Remove the snippet in the appropriate repository. diff --git a/_code/embed-code-ubuntu b/_code/embed-code-ubuntu new file mode 100755 index 0000000..7379805 Binary files /dev/null and b/_code/embed-code-ubuntu differ diff --git a/_code/samples/build.gradle b/_code/samples/build.gradle new file mode 100644 index 0000000..8b18b57 --- /dev/null +++ b/_code/samples/build.gradle @@ -0,0 +1,80 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 { + id "io.spine.tools.gradle.bootstrap" version "1.7.0" +} + +spine.enableJava().server() + +ext { + junitVersion = '5.7.0' +} + +dependencies { + testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" +} + +test { + useJUnitPlatform { + includeEngines 'junit-jupiter' + } +} + +project.ext { + // The root for the generated source code. + generatedRootDir = "$projectDir/generated" + + // Directories for the code generated by the Protobuf Compiler and Spine plugins + // for the Compiler. + generatedJavaDir = "$generatedRootDir/main/java" + generatedTestJavaDir = "$generatedRootDir/test/java" + + // Directories for the Spine-specific code generated by the Spine Model Compiler, + // for example, rejections. + generatedSpineDir = "$generatedRootDir/main/spine" + generatedTestSpineDir = "$generatedRootDir/test/spine" +} + +apply plugin: 'idea' + +idea { + module { + // Add generated code directories to the source code of the module in IntelliJ IDEA. + generatedSourceDirs += file(generatedJavaDir) + generatedSourceDirs += file(generatedSpineDir) + testSourceDirs += file(generatedTestJavaDir) + testSourceDirs += file(generatedTestSpineDir) + } +} + +/** + * The task for composite builds to include this project and depend on this top-level task. + */ +task buildAll(type: GradleBuild) { + tasks = [ 'build' ] +} diff --git a/_code/samples/gradle/wrapper/gradle-wrapper.jar b/_code/samples/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/_code/samples/gradle/wrapper/gradle-wrapper.jar differ diff --git a/_code/samples/gradle/wrapper/gradle-wrapper.properties b/_code/samples/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..4d9ca16 --- /dev/null +++ b/_code/samples/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/_code/samples/gradlew b/_code/samples/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/_code/samples/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/_code/samples/gradlew.bat b/_code/samples/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/_code/samples/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/_code/samples/settings.gradle b/_code/samples/settings.gradle new file mode 100644 index 0000000..55ac0f4 --- /dev/null +++ b/_code/samples/settings.gradle @@ -0,0 +1,27 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +rootProject.name = "samples" diff --git a/_code/samples/src/main/java/io/spine/site/home/server/NanoPmContext.java b/_code/samples/src/main/java/io/spine/site/home/server/NanoPmContext.java new file mode 100644 index 0000000..6bdcb96 --- /dev/null +++ b/_code/samples/src/main/java/io/spine/site/home/server/NanoPmContext.java @@ -0,0 +1,49 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.site.home.server; + +import io.spine.server.BoundedContext; +import io.spine.server.BoundedContextBuilder; + +/** + * Defines the Mini PM context. + */ +public final class NanoPmContext { + + static final String NAME = "Nano PM"; + + /** Prevents instantiation of this utility class. */ + private NanoPmContext() { + } + + /** Creates a builder for single-tenant context filled in with entity types. */ + public static BoundedContextBuilder newBuilder() { + return BoundedContext.singleTenant(NAME) + .add(TaskAggregate.class) + .add(TaskProjection.class); + } +} diff --git a/_code/samples/src/main/java/io/spine/site/home/server/TaskAggregate.java b/_code/samples/src/main/java/io/spine/site/home/server/TaskAggregate.java new file mode 100644 index 0000000..152f55f --- /dev/null +++ b/_code/samples/src/main/java/io/spine/site/home/server/TaskAggregate.java @@ -0,0 +1,84 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.site.home.server; + +import io.spine.core.CommandContext; +import io.spine.site.home.Task; +import io.spine.site.home.TaskId; +import io.spine.site.home.command.AssignTask; +import io.spine.site.home.command.CompleteTask; +import io.spine.site.home.command.CreateTask; +import io.spine.site.home.event.TaskAssigned; +import io.spine.site.home.event.TaskCompleted; +import io.spine.site.home.event.TaskCreated; +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; +import io.spine.server.command.Assign; + +final class TaskAggregate extends Aggregate { + + @Assign + TaskCreated handle(CreateTask cmd, CommandContext ctx) { + return TaskCreated.newBuilder() + .setTask(cmd.getId()) + .setName(cmd.getName()) + .setDescription(cmd.getDescription()) + .setOwner(ctx.getActorContext().getActor()) + .vBuild(); // validate the event + } + + @Apply + private void event(TaskCreated e) { + builder().setName(e.getName()) + .setDescription(e.getDescription()) + .setOwner(e.getOwner()); + } + + @Assign + TaskCompleted handle(CompleteTask cmd) { + return TaskCompleted.newBuilder() + .setTask(cmd.getTask()) + .vBuild(); + } + + @Apply + private void event(TaskCompleted e) { + setArchived(true); + } + + @Assign + TaskAssigned handle(AssignTask cmd) { + return TaskAssigned.newBuilder() + .setAssignee(cmd.getAssignee()) + .vBuild(); + } + + @Apply + private void event(TaskAssigned e) { + builder().setAssignee(e.getAssignee()); + } +} diff --git a/_code/samples/src/main/java/io/spine/site/home/server/TaskProjection.java b/_code/samples/src/main/java/io/spine/site/home/server/TaskProjection.java new file mode 100644 index 0000000..03752f9 --- /dev/null +++ b/_code/samples/src/main/java/io/spine/site/home/server/TaskProjection.java @@ -0,0 +1,65 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.site.home.server; + +import io.spine.core.EventContext; +import io.spine.core.Subscribe; +import io.spine.core.UserId; +import io.spine.site.home.TaskId; +import io.spine.site.home.TaskItem; +import io.spine.site.home.event.TaskAssigned; +import io.spine.site.home.event.TaskCompleted; +import io.spine.site.home.event.TaskCreated; +import io.spine.server.projection.Projection; + +final class TaskProjection extends Projection { + + @Subscribe + void on(TaskCreated e) { + builder().setName(e.getName()) + .setDescription(e.getDescription()) + .setOwner(toPersonName(e.getOwner())); + } + + @Subscribe + void on(TaskAssigned e) { + builder().setAssignee(toPersonName(e.getAssignee())); + } + + @Subscribe + void on(TaskCompleted e, EventContext ctx) { + builder().setWhenDone(ctx.getTimestamp()); + } + + /** + * Returns always the same mock name because this code is not going to be shown + * at the site pages. + */ + private static String toPersonName(@SuppressWarnings("unused") UserId user) { + return "John Doe"; + } +} diff --git a/_code/samples/src/main/java/io/spine/site/home/server/package-info.java b/_code/samples/src/main/java/io/spine/site/home/server/package-info.java new file mode 100644 index 0000000..13658d0 --- /dev/null +++ b/_code/samples/src/main/java/io/spine/site/home/server/package-info.java @@ -0,0 +1,39 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +/** + * This package contains server-side implementation of the Mini PM example which is used + * at the site home page. + */ +@CheckReturnValue +@ParametersAreNonnullByDefault +@BoundedContext(NanoPmContext.NAME) +package io.spine.site.home.server; + +import com.google.errorprone.annotations.CheckReturnValue; +import io.spine.core.BoundedContext; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/_code/samples/src/main/proto/spine/example/events.proto b/_code/samples/src/main/proto/spine/example/events.proto new file mode 100644 index 0000000..ace437e --- /dev/null +++ b/_code/samples/src/main/proto/spine/example/events.proto @@ -0,0 +1,41 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ +syntax = "proto3"; + +package spine.example; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.example"; +option java_outer_classname = "EventsProto"; +option java_multiple_files = true; + +// #docregion ProjectCreated +message ProjectCreated { + +} +// #enddocregion ProjectCreated diff --git a/_code/samples/src/main/proto/spine/site/home/commands.proto b/_code/samples/src/main/proto/spine/site/home/commands.proto new file mode 100644 index 0000000..bd14cd4 --- /dev/null +++ b/_code/samples/src/main/proto/spine/site/home/commands.proto @@ -0,0 +1,55 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ +syntax = "proto3"; + +package spine.site.home; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.site.home.command"; +option java_outer_classname = "CommandsProto"; +option java_multiple_files = true; + +import "spine/site/home/identifiers.proto"; + +// Create a new task. +message CreateTask { + TaskId id = 1; // assumed `required` + string name = 2 [(required) = true]; + string description = 3; +} + +// Assign a task on a user. +message AssignTask { + TaskId task = 1; + spine.core.UserId assignee = 2 [(required) = true]; +} + +// Mark a task as completed. +message CompleteTask { + TaskId task = 1; +} diff --git a/_code/samples/src/main/proto/spine/site/home/events.proto b/_code/samples/src/main/proto/spine/site/home/events.proto new file mode 100644 index 0000000..379e1c7 --- /dev/null +++ b/_code/samples/src/main/proto/spine/site/home/events.proto @@ -0,0 +1,56 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ +syntax = "proto3"; + +package spine.site.home; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.site.home.event"; +option java_outer_classname = "CommandsProto"; +option java_multiple_files = true; + +import "spine/site/home/identifiers.proto"; + +// A new task has been created. +message TaskCreated { + TaskId task = 1 [(required) = true]; + string name = 2 [(required) = true]; + string description = 3; + spine.core.UserId owner = 4 [(required) = true]; +} + +// A task was assigned to a user. +message TaskAssigned { + TaskId task = 1 [(required) = true]; + spine.core.UserId assignee = 2 [(required) = true]; +} + +// A task was marked as completed. +message TaskCompleted { + TaskId task = 1 [(required) = true]; +} diff --git a/_code/samples/src/main/proto/spine/site/home/identifiers.proto b/_code/samples/src/main/proto/spine/site/home/identifiers.proto new file mode 100644 index 0000000..fee4bea --- /dev/null +++ b/_code/samples/src/main/proto/spine/site/home/identifiers.proto @@ -0,0 +1,41 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ +syntax = "proto3"; + +package spine.site.home; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.site.home"; +option java_outer_classname = "IdentifiersProto"; +option java_multiple_files = true; + +import public "spine/core/user_id.proto"; + +message TaskId { + string uuid = 1; +} diff --git a/_code/samples/src/main/proto/spine/site/home/task.proto b/_code/samples/src/main/proto/spine/site/home/task.proto new file mode 100644 index 0000000..32aa1da --- /dev/null +++ b/_code/samples/src/main/proto/spine/site/home/task.proto @@ -0,0 +1,59 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ +syntax = "proto3"; + +package spine.site.home; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.site.home"; +option java_outer_classname = "TaskProto"; +option java_multiple_files = true; + +import "google/protobuf/timestamp.proto"; +import "spine/site/home/identifiers.proto"; + +// A task which can be assigned to a user. +message Task { + option (entity).kind = AGGREGATE; + TaskId id = 1; // assumed `required` + string name = 2 [(required) = true]; + string description = 3; + spine.core.UserId owner = 4 [(required) = true]; + spine.core.UserId assignee = 5; +} + +// An item in a task list displayed in UI. +message TaskItem { + option (entity).kind = PROJECTION; + TaskId task = 1; + string name = 2 [(required) = true]; + string description = 3; + string owner = 4 [(required) = true]; + string assignee = 5; + google.protobuf.Timestamp when_done = 6; +} diff --git a/_code/samples/src/test/java/io/spine/example/CompiledProtobuf.java b/_code/samples/src/test/java/io/spine/example/CompiledProtobuf.java new file mode 100644 index 0000000..591de70 --- /dev/null +++ b/_code/samples/src/test/java/io/spine/example/CompiledProtobuf.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.example; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static com.google.common.truth.Truth.assertThat; + +@DisplayName("Project should contain Protobuf types:") +class CompiledProtobuf { + + @Test + @DisplayName("ProjectCreated") + void projectCreated() { + assertThat(ProjectCreated.class) + .isNotNull(); + } +} diff --git a/_code/samples/src/test/java/io/spine/site/home/server/TaskCreationTest.java b/_code/samples/src/test/java/io/spine/site/home/server/TaskCreationTest.java new file mode 100644 index 0000000..5b7d085 --- /dev/null +++ b/_code/samples/src/test/java/io/spine/site/home/server/TaskCreationTest.java @@ -0,0 +1,122 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.site.home.server; + +import io.spine.server.BoundedContextBuilder; +import io.spine.site.home.Task; +import io.spine.site.home.TaskId; +import io.spine.site.home.TaskItem; +import io.spine.site.home.command.CreateTask; +import io.spine.site.home.event.TaskCreated; +import io.spine.testing.server.blackbox.ContextAwareTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static io.spine.testing.TestValues.randomString; + +@DisplayName("Handling `CreateTask` command should") +public class TaskCreationTest extends ContextAwareTest { + + private TaskId task; + private String name; + private String description; + + @Override + protected BoundedContextBuilder contextBuilder() { + return NanoPmContext.newBuilder(); + } + + private CreateTask generateCommand() { + task = TaskId.generate(); + name = randomString(); + description = randomString(); + return CreateTask.newBuilder() + .setId(task) + .setName(name) + .setDescription(description) + .vBuild(); + } + + @BeforeEach + void postCommand() { + CreateTask cmd = generateCommand(); + context().receivesCommand(cmd); + } + + @Test + @DisplayName("generate `TaskCreated` event") + void eventGenerated() { + TaskCreated expected = expectedEvent(); + context().assertEvent(TaskCreated.class) + .comparingExpectedFieldsOnly() + .isEqualTo(expected); + } + + private TaskCreated expectedEvent() { + return TaskCreated.newBuilder() + .setTask(task) + .setName(name) + .setDescription(description) + .buildPartial(); + } + + @Test + @DisplayName("create a `Task`") + void aggregateCreation() { + Task expected = expectedAggregateState(); + context().assertEntityWithState(task, Task.class) + .hasStateThat() + .comparingExpectedFieldsOnly() + .isEqualTo(expected); + } + + private Task expectedAggregateState() { + return Task.newBuilder() + .setId(task) + .setName(name) + .setDescription(description) + .buildPartial(); + } + + @Test + @DisplayName("create a `TaskItem`") + void projectionCreation() { + TaskItem expected = expectedProjectionState(); + context().assertEntityWithState(task, TaskItem.class) + .hasStateThat() + .comparingExpectedFieldsOnly() + .isEqualTo(expected); + } + + private TaskItem expectedProjectionState() { + return TaskItem.newBuilder() + .setName(name) + .setDescription(description) + .buildPartial(); + } +} diff --git a/_script/check-samples b/_script/check-samples new file mode 100755 index 0000000..c724ed1 --- /dev/null +++ b/_script/check-samples @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# +# Copyright 2020, TeamDev. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +set -e + +# Load environment variables for the case of execution from the Gradle build if they exist. +BASH_PROFILE=~/.bash_profile +BASH_RC=~/.bashrc + +if [ -f ${BASH_PROFILE} ]; then + echo "Using user's local bash profile." + . ${BASH_PROFILE} +elif [ -f ${BASH_RC} ]; then + echo "Using user's local bash runtime configuration." + . ${BASH_RC} +fi + +# Navigate to the folder with samples. +cd _code + +# Use the Ubuntu binary for GitHub Actions and macOS binary in other cases. +if [ "$GITHUB_ACTIONS" = "true" ]; then + echo "Running in GitHub Action." + TOOL="./embed-code-ubuntu" +else + echo "Running locally on macOS." + TOOL="./embed-code-macos" +fi + +# Check code samples. +"$TOOL" -config-path="config-v1.yml" -mode="check" diff --git a/_script/embed-code b/_script/embed-code new file mode 100755 index 0000000..67de7b1 --- /dev/null +++ b/_script/embed-code @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# +# Copyright 2020, TeamDev. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +# Load environment variables for the case of execution from the Gradle build if they exist. +BASH_PROFILE=~/.bash_profile +BASH_RC=~/.bashrc + +if [ -f ${BASH_PROFILE} ]; then + echo "Using user's local bash profile." + . ${BASH_PROFILE} +elif [ -f ${BASH_RC} ]; then + echo "Using user's local bash runtime configuration." + . ${BASH_RC} +fi + +# Ensure `_code` files are fetched. +git submodule update --remote --merge --recursive + +# Navigate to the folder with samples. +cd _code + +# Update code samples. +./embed-code-macos -config-path="config-v1.yml" -mode="embed" diff --git a/_script/hugo-build b/_script/hugo-build new file mode 100755 index 0000000..cc35453 --- /dev/null +++ b/_script/hugo-build @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Copyright 2025, TeamDev. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +# Load environment variables for the case of execution from the Gradle build if they exist. +BASH_PROFILE=~/.bash_profile +BASH_RC=~/.bashrc + +if [ -f ${BASH_PROFILE} ]; then + echo "Using user's local bash profile." + . ${BASH_PROFILE} +elif [ -f ${BASH_RC} ]; then + echo "Using user's local bash runtime configuration." + . ${BASH_RC} +fi + +cd site +hugo diff --git a/_script/hugo-serve b/_script/hugo-serve new file mode 100755 index 0000000..0180823 --- /dev/null +++ b/_script/hugo-serve @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Copyright 2025, TeamDev. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +# Load environment variables for the case of execution from the Gradle build if they exist. +BASH_PROFILE=~/.bash_profile +BASH_RC=~/.bashrc + +if [ -f ${BASH_PROFILE} ]; then + echo "Using user's local bash profile." + . ${BASH_PROFILE} +elif [ -f ${BASH_RC} ]; then + echo "Using user's local bash runtime configuration." + . ${BASH_RC} +fi + +cd site +hugo server diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..bfc4036 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,65 @@ +/* + * Copyright 2025, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +/** + * Builds and runs the site locally. + */ +task("runSite") { + commandLine("./_script/hugo-serve") +} + +/** + * Builds the site without starting the server. + */ +task("buildSite") { + commandLine("./_script/hugo-build") +} + +/** + * Embeds the code samples into pages of the site. + */ +task("embedCode") { + commandLine("./_script/embed-code") +} + +/** + * Verifies that the source code samples embedded into the pages are up-to-date. + */ +task("checkSamples") { + commandLine("./_script/check-samples") +} + +/** + * Builds all included projects via depending on the top-level "buildAll" tasks + * declared in these projects. + * + * @see https://discuss.gradle.org/t/defining-a-composite-build-only-to-build-all-subprojects/25070/6 + * @see https://github.com/AlexMAS/gradle-composite-build-example + * @see https://docs.gradle.org/current/userguide/composite_builds.html + */ +tasks.register("buildAll") { + dependsOn(gradle.includedBuilds.map { it.task(":buildAll") }) +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..4d9ca16 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..5d89773 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,32 @@ +/* + * Copyright 2025, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +rootProject.name = "spine.io" + +includeBuild("./_code/samples") + +includeBuild("./_code/examples/airport") +includeBuild("./_code/examples/hello")