16 Commits

Author SHA1 Message Date
hlaeja
2ffabb8ff8 [RELEASE] - Release version: 0.4.0 2025-08-18 10:31:37 +00:00
8d0f949a69 add plugin ui-service 2025-08-18 12:03:31 +02:00
2862ead9fc fix publish plugin 2025-07-30 13:38:14 +02:00
hlaeja
69a73a228b [RELEASE] - Bump version 2025-07-29 17:07:09 +00:00
hlaeja
1cddac917a [RELEASE] - Release version: 0.3.0 2025-07-29 17:07:07 +00:00
4ace501f82 set +x on gradlew 2025-07-29 19:05:33 +02:00
092252a2f9 update resource process gradle deprecated 2025-07-29 19:03:24 +02:00
1abdb6fe18 rename integration test to test integration 2025-07-29 19:03:24 +02:00
7f02ac6b26 update gradlew 2025-07-29 19:03:24 +02:00
d808fe3573 update project 2025-07-29 19:03:24 +02:00
8bb23a7d55 add GitHub action
- add action run checks
- add action release
- remove release.sh
2025-07-29 19:03:24 +02:00
684b4c001e [RELEASE] - bump version 2024-12-10 23:15:22 +01:00
7fbf278fc4 [RELEASE] - release version: 0.2.0 2024-12-10 23:15:19 +01:00
0c657764db Add copyCertificates
- update README.md with certificate plugin
- add Ltd_hlaeja_plugin_hlaeja_common_plugin_certificate_gradle.kts
2024-12-10 18:42:43 +01:00
867b07575c update for core plugin v0.2.0
- update task ltd.hlaeja.plugin.hlaeja-common-plugin.service-container.gradle.kts
- update publishing ltd.hlaeja.plugin.hlaeja-common-plugin.library-publish.gradle.kts
- update publishing in build.gradle.kts
- update catalog version
2024-12-10 17:48:53 +01:00
9cae6198ad [RELEASE] - bump version 2024-11-12 16:37:21 +01:00
20 changed files with 293 additions and 230 deletions

View File

@@ -21,12 +21,14 @@ tab_width = 2
# noinspection EditorConfigKeyCorrectness # noinspection EditorConfigKeyCorrectness
[*.{kt,kts}] [*.{kt,kts}]
ij_kotlin_packages_to_use_import_on_demand = unset
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma = true
ktlint_standard_import-ordering = disabled ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_standard_no-empty-first-line-in-class-body = disabled ij_kotlin_packages_to_use_import_on_demand = unset
ktlint_standard_chain-method-continuation = disabled
ktlint_standard_class-signature = disabled
ktlint_standard_function-signature = disabled ktlint_standard_function-signature = disabled
ktlint_standard_parameter-list-wrapping = disabled ktlint_standard_import-ordering = disabled
ktlint_standard_multiline-expression-wrapping = disabled ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_no-empty-first-line-in-class-body = disabled
ktlint_standard_parameter-list-wrapping = disabled
ktlint_standard_string-template-indent = disabled ktlint_standard_string-template-indent = disabled

12
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: Release
on:
workflow_dispatch:
jobs:
release:
uses: swordsteel/hlaeja-common-workflows/.github/workflows/release.yml@master
secrets:
CI_BOT_PAT: ${{ secrets.CI_BOT_PAT }}
with:
TYPE: plugin

12
.github/workflows/run-checks.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: Pull request validation
on:
pull_request:
paths-ignore:
- '.github/**'
jobs:
validate:
uses: swordsteel/hlaeja-common-workflows/.github/workflows/run-checks.yml@master
secrets:
CI_BOT_PAT: ${{ secrets.CI_BOT_PAT }}

View File

@@ -2,62 +2,98 @@
Plugins for the libraries, lofty and grand, Plugins for the services, steadfast as stone, Plugins for the common, bound to their fate, Using the one plugin to rule them all, and in automation bind them, In the realm of code, where the builds take form. Plugins for the libraries, lofty and grand, Plugins for the services, steadfast as stone, Plugins for the common, bound to their fate, Using the one plugin to rule them all, and in automation bind them, In the realm of code, where the builds take form.
<!-- TOC -->
* [Hlæja Common Plugin](#hlæja-common-plugin)
* [Plugins](#plugins)
* [Common](#common)
* [Plugin Common](#plugin-common)
* [Gradle Tasks](#gradle-tasks)
* [Plugin Common Detekt](#plugin-common-detekt)
* [Plugin Common Ktlint](#plugin-common-ktlint)
* [Library](#library)
* [Plugin Library](#plugin-library)
* [Plugin Library Manifest](#plugin-library-manifest)
* [Plugin Library publish](#plugin-library-publish)
* [Service](#service)
* [Plugin Service](#plugin-service)
* [Plugin Service Container](#plugin-service-container)
* [Configuration](#configuration)
* [Gradle Tasks](#gradle-tasks-1)
* [Plugin Service Test Integration](#plugin-service-test-integration)
* [Plugin Service Process Resource](#plugin-service-process-resource)
* [Plugin Certificate](#plugin-certificate)
* [UI Service](#ui-service)
* [Plugin UI Service](#plugin-ui-service)
* [Plugin UI Service Thymeleaf Minify](#plugin-ui-service-thymeleaf-minify)
* [Releasing Plugin](#releasing-plugin)
* [Publishing plugin](#publishing-plugin)
* [Publish plugin locally](#publish-plugin-locally)
* [Publish plugin to repository](#publish-plugin-to-repository)
* [Global gradle properties](#global-gradle-properties)
<!-- TOC -->
## Plugins ## Plugins
### Plugin Common ### Common
#### Plugin Common
id `ltd.hlaeja.plugin.hlaeja-common-plugin.common` id `ltd.hlaeja.plugin.hlaeja-common-plugin.common`
Set core Java and Kotlin settings and overweight project version with git version. Set core Java and Kotlin settings and overweight project version with git version.
#### Gradle Tasks ##### Gradle Tasks
* `buildInfo` display name and version, add to `build` task. * `buildInfo` display name and version, add to `build` task.
* `projectInfo` display project, Gradle, and Java information * `projectInfo` display project, Gradle, and Java information
### Plugin Common Detekt #### Plugin Common Detekt
id `ltd.hlaeja.plugin.hlaeja-common-plugin.common-detekt` id `ltd.hlaeja.plugin.hlaeja-common-plugin.common-detekt`
Detect is a code smell analysis for your Kotlin projects. Detect is a code smell analysis for your Kotlin projects.
### Plugin Common Ktlint #### Plugin Common Ktlint
id `ltd.hlaeja.plugin.hlaeja-common-plugin.common-ktlint` id `ltd.hlaeja.plugin.hlaeja-common-plugin.common-ktlint`
Ktlint enforces consistent code style and formatting across Kotlin codebases. Ktlint enforces consistent code style and formatting across Kotlin codebases.
### Plugin Library ### Library
#### Plugin Library
id `ltd.hlaeja.plugin.hlaeja-common-plugin.library` id `ltd.hlaeja.plugin.hlaeja-common-plugin.library`
Default setting and tasks for libraries. Default setting and tasks for libraries.
### Plugin Library Manifest #### Plugin Library Manifest
id `ltd.hlaeja.plugin.hlaeja-common-plugin.library-manifest` id `ltd.hlaeja.plugin.hlaeja-common-plugin.library-manifest`
Extend manifest in library jar file. Extend manifest in library jar file.
### Plugin Library publish #### Plugin Library publish
id `ltd.hlaeja.plugin.hlaeja-common-plugin.library-publish` id `ltd.hlaeja.plugin.hlaeja-common-plugin.library-publish`
Configuration for publishing project artifacts to a remote Maven repository. Configuration for publishing project artifacts to a remote Maven repository.
### Plugin Service ### Service
#### Plugin Service
id `ltd.hlaeja.plugin.hlaeja-common-plugin.service` id `ltd.hlaeja.plugin.hlaeja-common-plugin.service`
Default setting and tasks for services. Default setting and tasks for services.
### Plugin Service Container #### Plugin Service Container
id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-container` id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-container`
Configuration for running project in docker locally during development. Configuration for running project in docker locally during development.
#### Configuration ##### Configuration
* properties `container.network`, environment `CONTAINER_NETWORK`, or default `develop` * properties `container.network`, environment `CONTAINER_NETWORK`, or default `develop`
* properties `container.port.expose`, environment `CONTAINER_PORT_EXPOSE`, or default `8080` * properties `container.port.expose`, environment `CONTAINER_PORT_EXPOSE`, or default `8080`
@@ -67,7 +103,7 @@ Configuration for running project in docker locally during development.
container and docker ports can be a single port (e.g., 8080) or multiple ports separated by commas (e.g., 8080,8443) container and docker ports can be a single port (e.g., 8080) or multiple ports separated by commas (e.g., 8080,8443)
#### Gradle Tasks ##### Gradle Tasks
* `containerCreate` create docker container with network and spring boot profile. * `containerCreate` create docker container with network and spring boot profile.
* `containerStart` starts docker container. * `containerStart` starts docker container.
@@ -76,25 +112,45 @@ container and docker ports can be a single port (e.g., 8080) or multiple ports s
* `containerNetworkCreate` creates network. * `containerNetworkCreate` creates network.
* `containerNetworkRemove` removes network. * `containerNetworkRemove` removes network.
### Plugin Service Integration Test #### Plugin Service Test Integration
id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test` id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-test-integration`
Adding task `integrationTest` to run integration test, add to `verification` group and add to task `check`. Adding task `testIntegration` to run integration test, add to `verification` group and add to task `check`.
Adding intellij support `src/integration-test/java`, `src/integration-test/kotlin`, and `src/integration-test/resources` as test module in intellij. Adding intellij support `src/test-integration/java`, `src/test-integration/kotlin`, and `src/test-integration/resources` as test module in intellij.
Adding dependencies support `integrationTestImplementation()`, and `integrationTestRuntimeOnly()` as part of Gradle. Adding dependencies support `testIntegrationImplementation()`, and `testIntegrationRuntimeOnly()` as part of Gradle.
### Plugin Service Process Resource #### Plugin Service Process Resource
id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-process-resource` id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-process-resource`
Assign values to `application.yml` from Gradle. Assign values to `application.yml` from Gradle.
## Releasing plugin #### Plugin Certificate
Run `release.sh` script from `master` branch. id `ltd.hlaeja.plugin.hlaeja-common-plugin.cetificat`
Copy certificate to build resources by placing one or more of `private_key.pem`, `public_key.pem`, or `keystore.p12` in `/cert` folder.
### UI Service
#### Plugin UI Service
id `ltd.hlaeja.plugin.hlaeja-common-plugin.ui-service`
Default setting and tasks for thymeleaf ui services.
#### Plugin UI Service Thymeleaf Minify
id `ltd.hlaeja.plugin.hlaeja-common-plugin.ui-service-thymeleaf.minify`
minimize all templates files during processResources. skips html tags pre, textarea, script, style, and template
## Releasing Plugin
Run release pipeline from `master` branch.
## Publishing plugin ## Publishing plugin
@@ -107,7 +163,7 @@ Run `release.sh` script from `master` branch.
### Publish plugin to repository ### Publish plugin to repository
```shell ```shell
./gradlew clean build publish ./gradlew clean build publishAllPublicationsToGitHubPackagesRepository
``` ```
### Global gradle properties ### Global gradle properties

View File

@@ -1,11 +1,10 @@
import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension.Companion.DEFAULT_SRC_DIR_KOTLIN import io.gitlab.arturbosch.detekt.extensions.DetektExtension.Companion.DEFAULT_SRC_DIR_KOTLIN
import java.lang.System.getenv
plugins { plugins {
alias(hlaeja.plugins.io.gitlab.arturbosch.detekt) alias(hlaeja.plugins.gradle.detekt)
alias(hlaeja.plugins.kotlin.jvm) alias(hlaeja.plugins.kotlin.jvm)
alias(hlaeja.plugins.ltd.hlaeja.plugin.core) alias(hlaeja.plugins.core)
`kotlin-dsl` `kotlin-dsl`
`maven-publish` `maven-publish`
@@ -39,22 +38,15 @@ kotlin.compilerOptions.freeCompilerArgs.addAll("-Xjsr305=strict")
publishing { publishing {
repositories { repositories {
fun retrieveConfiguration(
property: String,
environment: String,
): String? = project.findProperty(property)?.toString() ?: getenv(environment)
maven { maven {
url = uri("https://maven.pkg.github.com/swordsteel/${project.name}") url = uri("https://maven.pkg.github.com/swordsteel/${project.name}")
name = "GitHubPackages" name = "GitHubPackages"
credentials { credentials {
username = retrieveConfiguration("repository.user", "REPOSITORY_USER") username = config.find("repository.user", "REPOSITORY_USER")
password = retrieveConfiguration("repository.token", "REPOSITORY_TOKEN") password = config.find("repository.token", "REPOSITORY_TOKEN")
} }
} }
} }
publications.create<MavenPublication>("mavenJava") { from(components["java"]) }
} }
tasks { tasks {

View File

@@ -1,3 +1,3 @@
kotlin.code.style=official kotlin.code.style=official
version=0.1.0 version=0.4.0
catalog=0.2.0 catalog=0.12.0

Binary file not shown.

View File

@@ -1,6 +1,7 @@
#Mon Oct 21 14:08:46 BST 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

47
gradlew vendored Normal file → Executable file
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
# #
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +82,11 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;; NONSTOP* ) nonstop=true ;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
@@ -133,22 +133,29 @@ location of your Java installation."
fi fi
else else
JAVACMD=java 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. if ! command -v java >/dev/null 2>&1
then
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 Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
# shell script including quotes and variable substitutions, so put them in DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded. # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \ -classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

41
gradlew.bat vendored
View File

@@ -13,8 +13,10 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@@ -25,7 +27,8 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View File

@@ -1,89 +0,0 @@
#!/bin/sh
### This should be a pipeline, but for this example let use this ###
check_active_branch() {
if [ "$(git rev-parse --abbrev-ref HEAD)" != "$1" ]; then
echo "Error: The current branch is not $1."
exit 1
fi
}
check_uncommitted_changes() {
if [ -n "$(git status --porcelain)" ]; then
echo "Error: There are uncommitted changes in the repository."
exit 1
fi
}
prepare_environment() {
git fetch origin
}
check_last_commit() {
last_commit_message=$(git log -1 --pretty=format:%s)
if [ "$last_commit_message" = "[RELEASE] - bump version" ]; then
echo "Warning: Nothing to release!!!"
exit 1
fi
}
check_differences() {
if ! git diff --quiet origin/"$1" "$1"; then
echo "Error: The branches origin/$1 and $1 have differences."
exit 1
fi
}
un_snapshot_version() {
sed -i "s/\($1\s*=\s*[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/" gradle.properties
}
current_version() {
awk -F '=' '/version\s*=\s*[0-9.]*/ {gsub(/^ +| +$/,"",$2); print $2}' gradle.properties
}
stage_files() {
for file in "$@"; do
if git diff --exit-code --quiet -- "$file"; then
echo "No changes in $file"
else
git add "$file"
echo "Changes in $file staged for commit"
fi
done
}
commit_change() {
stage_files gradle.properties
git commit -m "[RELEASE] - $1"
git push --porcelain origin master
}
add_release_tag() {
gitTag="v$(current_version)"
git tag -a "$gitTag" -m "Release version $gitTag"
git push --porcelain origin "$gitTag"
}
snapshot_version() {
new_version="$(current_version | awk -F '.' '{print $1 "." $2+1 ".0"}')"
sed -i "s/\(version\s*=\s*\)[0-9.]*/\1$new_version-SNAPSHOT/" gradle.properties
}
# check and prepare for release
check_active_branch master
check_uncommitted_changes
prepare_environment
check_last_commit
check_differences master
# un-snapshot version for release
un_snapshot_version version
un_snapshot_version catalog
# release changes and prepare for next release
commit_change "release version: $(current_version)"
add_release_tag
snapshot_version
commit_change 'bump version'

View File

@@ -0,0 +1,18 @@
val filesToCopy = listOf(
"private_key.pem",
"public_key.pem",
"keystore.p12",
)
tasks {
register<Copy>("copyCertificates") {
group = "hlaeja"
into("${layout.buildDirectory.get()}/resources/main/cert")
filesToCopy.filter { file("cert/$it").exists() }
.forEach { file ->
from("cert/$file") {
include(file)
}
}
}
}

View File

@@ -1,23 +1,16 @@
import java.lang.System.getenv
plugins { plugins {
id("ltd.hlaeja.plugin.hlaeja-core-plugin")
`maven-publish` `maven-publish`
} }
publishing { publishing {
repositories { repositories {
fun retrieveConfiguration(
property: String,
environment: String,
): String? = project.findProperty(property)?.toString() ?: getenv(environment)
maven { maven {
url = uri("https://maven.pkg.github.com/swordsteel/${project.name}") url = uri("https://maven.pkg.github.com/swordsteel/${project.name}")
name = "GitHubPackages" name = "GitHubPackages"
credentials { credentials {
username = retrieveConfiguration("repository.user", "REPOSITORY_USER") username = config.find("repository.user", "REPOSITORY_USER")
password = retrieveConfiguration("repository.token", "REPOSITORY_TOKEN") password = config.find("repository.token", "REPOSITORY_TOKEN")
} }
} }
} }

View File

@@ -4,22 +4,16 @@ import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
import com.bmuschko.gradle.docker.tasks.network.DockerCreateNetwork import com.bmuschko.gradle.docker.tasks.network.DockerCreateNetwork
import com.bmuschko.gradle.docker.tasks.network.DockerInspectNetwork import com.bmuschko.gradle.docker.tasks.network.DockerInspectNetwork
import com.bmuschko.gradle.docker.tasks.network.DockerRemoveNetwork import com.bmuschko.gradle.docker.tasks.network.DockerRemoveNetwork
import java.lang.System.getenv
plugins { plugins {
id("ltd.hlaeja.plugin.hlaeja-core-plugin")
id("com.bmuschko.docker-spring-boot-application") id("com.bmuschko.docker-spring-boot-application")
} }
fun configuration(
property: String,
environment: String,
default: String,
): String = project.findProperty(property)?.toString() ?: getenv(environment) ?: default
fun configurationPorts( fun configurationPorts(
property: String, property: String,
environment: String, environment: String,
): List<String> = configuration(property, environment, "8080").split(',') ): List<String> = config.findOrDefault(property, environment, "8080").split(',')
fun exposeDockerPorts(): List<Int> = configurationPorts("docker.port.expose", "DOCKER_PORT_EXPOSE") fun exposeDockerPorts(): List<Int> = configurationPorts("docker.port.expose", "DOCKER_PORT_EXPOSE")
.mapNotNull { it.toIntOrNull() } .mapNotNull { it.toIntOrNull() }
@@ -40,9 +34,12 @@ tasks {
targetImageId("${project.name}:${project.version}") targetImageId("${project.name}:${project.version}")
containerName.set(project.name) containerName.set(project.name)
hostConfig.autoRemove.set(true) hostConfig.autoRemove.set(true)
hostConfig.network.set(configuration("container.network", "CONTAINER_NETWORK", "develop")) hostConfig.network.set(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
hostConfig.portBindings.set(exposeContainerPorts()) hostConfig.portBindings.set(exposeContainerPorts())
withEnvVar("SPRING_PROFILES_ACTIVE", configuration("container.profiles", "CONTAINER_PROFILES", "docker")) withEnvVar(
"SPRING_PROFILES_ACTIVE",
config.findOrDefault("container.profiles", "CONTAINER_PROFILES", "docker")
)
} }
register("containerStart", DockerStartContainer::class) { register("containerStart", DockerStartContainer::class) {
group = "hlaeja" group = "hlaeja"
@@ -55,15 +52,15 @@ tasks {
} }
register("containerNetworkCheck", DockerInspectNetwork::class) { register("containerNetworkCheck", DockerInspectNetwork::class) {
group = "hlaeja" group = "hlaeja"
targetNetworkId(configuration("container.network", "CONTAINER_NETWORK", "develop")) targetNetworkId(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
onError { println("Network does not exist.") } onError { println("Network does not exist.") }
} }
register("containerNetworkCreate", DockerCreateNetwork::class) { register("containerNetworkCreate", DockerCreateNetwork::class) {
group = "hlaeja" group = "hlaeja"
networkName.set(configuration("container.network", "CONTAINER_NETWORK", "develop")) networkName.set(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
} }
register("containerNetworkRemove", DockerRemoveNetwork::class) { register("containerNetworkRemove", DockerRemoveNetwork::class) {
group = "hlaeja" group = "hlaeja"
targetNetworkId(configuration("container.network", "CONTAINER_NETWORK", "develop")) targetNetworkId(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
} }
} }

View File

@@ -1,38 +0,0 @@
plugins {
id("idea")
kotlin("jvm")
}
@Suppress("unused")
fun DependencyHandler.integrationTestImplementation(
dependencyNotation: Any,
): Dependency? = add("integrationTestImplementation", dependencyNotation)
@Suppress("unused")
fun DependencyHandler.integrationTestRuntimeOnly(
dependencyNotation: Any,
): Dependency? = add("integrationTestRuntimeOnly", dependencyNotation)
sourceSets.create("integration-test") {
compileClasspath += sourceSets["main"].output
runtimeClasspath += sourceSets["main"].output
idea.module {
testSources.from(sourceSets["integration-test"].kotlin.srcDirs, sourceSets["integration-test"].java.srcDirs)
testResources.from(sourceSets["integration-test"].resources.srcDirs)
}
configurations.let {
it["integrationTestImplementation"].extendsFrom(configurations.implementation.get())
it["integrationTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
}
}
tasks {
register<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"
testClassesDirs = sourceSets["integration-test"].output.classesDirs
classpath = sourceSets["integration-test"].runtimeClasspath
}
check { dependsOn(getByName("integrationTest")) }
}

View File

@@ -6,14 +6,16 @@ plugins {
tasks { tasks {
withType<ProcessResources> { withType<ProcessResources> {
val projectName = project.name
val projectVersion = project.version
filesMatching("**/application.yml") { filesMatching("**/application.yml") {
filter { filter {
it.replace( it.replace(
"%APP_NAME%", "%APP_NAME%",
project.name.split("-").joinToString(" ") { word -> word.uppercaseFirstChar() }, projectName.split("-").joinToString(" ") { word -> word.uppercaseFirstChar() },
) )
} }
filter { it.replace("%APP_VERSION%", project.version as String) } filter { it.replace("%APP_VERSION%", projectVersion as String) }
filter { it.replace("%APP_BUILD_TIME%", info.utcTimestamp) } filter { it.replace("%APP_BUILD_TIME%", info.utcTimestamp) }
filter { it.replace("%APP_BUILD_OS_NAME%", System.getProperty("os.name")) } filter { it.replace("%APP_BUILD_OS_NAME%", System.getProperty("os.name")) }
filter { it.replace("%APP_BUILD_OS_VERSION%", System.getProperty("os.version")) } filter { it.replace("%APP_BUILD_OS_VERSION%", System.getProperty("os.version")) }

View File

@@ -0,0 +1,38 @@
plugins {
id("idea")
kotlin("jvm")
}
@Suppress("unused")
fun DependencyHandler.testIntegrationImplementation(
dependencyNotation: Any,
): Dependency? = add("testIntegrationImplementation", dependencyNotation)
@Suppress("unused")
fun DependencyHandler.testIntegrationRuntimeOnly(
dependencyNotation: Any,
): Dependency? = add("testIntegrationRuntimeOnly", dependencyNotation)
sourceSets.create("test-integration") {
compileClasspath += sourceSets["main"].output
runtimeClasspath += sourceSets["main"].output
idea.module {
testSources.from(sourceSets["test-integration"].kotlin.srcDirs, sourceSets["test-integration"].java.srcDirs)
testResources.from(sourceSets["test-integration"].resources.srcDirs)
}
configurations.let {
it["testIntegrationImplementation"].extendsFrom(configurations.implementation.get())
it["testIntegrationRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
}
}
tasks {
register<Test>("testIntegration") {
description = "Runs test integration."
group = "verification"
testClassesDirs = sourceSets["test-integration"].output.classesDirs
classpath = sourceSets["test-integration"].runtimeClasspath
}
check { dependsOn(getByName("testIntegration")) }
}

View File

@@ -1,6 +1,6 @@
plugins { plugins {
id("ltd.hlaeja.plugin.hlaeja-common-plugin.common") id("ltd.hlaeja.plugin.hlaeja-common-plugin.common")
id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-container") id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-container")
id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test")
id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-process-resource") id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-process-resource")
id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-test-integration")
} }

View File

@@ -0,0 +1,41 @@
import kotlin.text.RegexOption.IGNORE_CASE
tasks {
register("minifyTemplates") {
val srcTemplates = file("src/main/resources/templates")
val outTemplates = layout.buildDirectory.dir("resources/main/templates")
val preserveTags = listOf("pre", "textarea", "script", "style", "template")
inputs.dir(srcTemplates)
outputs.dir(outTemplates)
doLast {
fileTree(srcTemplates).matching { include("**/*.html") }
.forEach { srcFile ->
val preserve = preserveTags.joinToString("|")
val preservedBlocks = mutableListOf<String>()
Regex("<(?:$preserve)\\b[^>]*>[\\s\\S]*?<\\/\\s*(?:$preserve)>", IGNORE_CASE)
.replace(srcFile.readText()) {
val id = preservedBlocks.size
preservedBlocks += it.value
"%%%PRESERVE_BLOCK_$id%%%"
}
.replace(Regex("<!--([\\s\\S]*?)-->"), "")
.replace(Regex("[\\r\\n]+"), "")
.replace(Regex("\\s{2,}"), " ")
.replace(Regex(">\\s+<"), "><")
.replace(Regex("\\s*%%%PRESERVE_BLOCK_(\\d+)%%%\\s*")) {
preservedBlocks[it.groupValues[1].toInt()]
}
.let { stripped ->
outTemplates.get().asFile.resolve(srcFile.relativeTo(srcTemplates)).also { file ->
file.parentFile.mkdirs()
file.writeText(stripped)
}
}
}
}
}
named<ProcessResources>("processResources") {
exclude("templates/**")
dependsOn(findByPath("minifyTemplates"))
}
}

View File

@@ -0,0 +1,4 @@
plugins {
id("ltd.hlaeja.plugin.hlaeja-common-plugin.service")
id("ltd.hlaeja.plugin.hlaeja-common-plugin.ui-service-thymeleaf-minify")
}