From 1c9a06f4c81d78f3b691aa34dabbcfcae8c0342c Mon Sep 17 00:00:00 2001 From: John Blum Date: Tue, 23 Apr 2019 16:59:11 -0700 Subject: [PATCH] Customize processResources build step and configure the Apache Ant ReplaceTokens filter to process all tokens in configuration files and Gfsh shell scripts. --- .../spring-geode-samples-boot-configuration.gradle | 10 ++++++++++ .../src/main/resources/geode/bin/connect.gfsh | 2 +- .../src/main/resources/geode/bin/setenv.gfsh | 2 +- .../main/resources/geode/bin/start-secure-cluster.gfsh | 7 +++++-- .../main/resources/geode/bin/start-secure-cluster.sh | 2 +- .../main/resources/geode/bin/start-simple-cluster.sh | 2 +- .../src/main/resources/geode/bin/stop-cluster.sh | 2 +- .../src/main/resources/geode/config/gemfire.properties | 4 ++-- 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/spring-geode-samples/boot/configuration/spring-geode-samples-boot-configuration.gradle b/spring-geode-samples/boot/configuration/spring-geode-samples-boot-configuration.gradle index 0d47e040..2d63d3e1 100644 --- a/spring-geode-samples/boot/configuration/spring-geode-samples-boot-configuration.gradle +++ b/spring-geode-samples/boot/configuration/spring-geode-samples-boot-configuration.gradle @@ -1,3 +1,5 @@ +import org.apache.tools.ant.filters.ReplaceTokens + apply plugin: 'io.spring.convention.spring-sample-boot' description = "Spring Geode Samples demonstrating the use of Spring Boot Auto-configuration for Apache Geode." @@ -13,3 +15,11 @@ dependencies { compile "org.projectlombok:lombok" } + +processResources { + filter ReplaceTokens, tokens: [ + 'project-dir' : rootProject.projectDir.path, + 'project-version' : project.version, + 'samples-dir' : rootProject.projectDir.path + '/spring-geode-samples/' + ] +} diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/connect.gfsh b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/connect.gfsh index affa83b8..223832cb 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/connect.gfsh +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/connect.gfsh @@ -1,4 +1,4 @@ # Gfsh shell script used to connect to a secure cluster # Connect to a secure Locator with Authentication and SSL enabled -connect --security-properties-file=${SBDG_HOME}/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties +connect --security-properties-file=${SBDG_HOME}/spring-geode-samples/boot/configuration/build/resources/main/geode/config/gemfire.properties diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/setenv.gfsh b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/setenv.gfsh index d50bbc6f..e50a67bc 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/setenv.gfsh +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/setenv.gfsh @@ -1,4 +1,4 @@ # Gfsh shell script to set the environment -set variable --name=SBDG_HOME --value=/Users/jblum/pivdev/spring-boot-data-geode +set variable --name=SBDG_HOME --value=@project-dir@ echo --string=${SBDG_HOME} diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.gfsh b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.gfsh index cca3e3f4..743d77a0 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.gfsh +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.gfsh @@ -1,5 +1,8 @@ # Gfsh shell script to start a secure GemFire/Geode cluster -start locator --name=LocatorOne --classpath=${SBDG_HOME}/apache-geode-extensions/build/libs/apache-geode-extensions-1.0.0.BUILD-SNAPSHOT.jar --properties-file=${SBDG_HOME}/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties +set variable --name=CLASSPATH --value=${SBDG_HOME}/apache-geode-extensions/build/libs/apache-geode-extensions-@project-version@.jar +set variable --name=GEMFIRE_PROPERTIES --value=${SBDG_HOME}/spring-geode-samples/boot/configuration/build/resources/main/geode/config/gemfire.properties + +start locator --name=LocatorOne --classpath=${CLASSPATH} --properties-file=${GEMFIRE_PROPERTIES} connect --user=test --password=test -start server --name=ServerOne --classpath=${SBDG_HOME}/apache-geode-extensions/build/libs/apache-geode-extensions-1.0.0.BUILD-SNAPSHOT.jar --properties-file=${SBDG_HOME}/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties +start server --name=ServerOne --classpath=${CLASSPATH} --properties-file=${GEMFIRE_PROPERTIES} diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.sh b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.sh index 504fc00c..335881c4 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.sh +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.sh @@ -1,3 +1,3 @@ #!/bin/bash -gfsh -e "run --file=${SBDG_HOME}/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-secure-cluster.gfsh" +gfsh -e "run --file=@samples-dir@boot/configuration/build/resources/main/geode/bin/start-secure-cluster.gfsh" diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-simple-cluster.sh b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-simple-cluster.sh index 0226ada9..adc022ee 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-simple-cluster.sh +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-simple-cluster.sh @@ -1,3 +1,3 @@ #!/bin/bash -gfsh -e "run --file=${SBDG_HOME}/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/start-simple-cluster.gfsh" +gfsh -e "run --file=@samples-dir@boot/configuration/src/main/resources/geode/bin/start-simple-cluster.gfsh" diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/stop-cluster.sh b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/stop-cluster.sh index 9fdf3d3a..8ae6baef 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/stop-cluster.sh +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/stop-cluster.sh @@ -1,3 +1,3 @@ #!/bin/bash -gfsh -e "run --file=${SBDG_HOME}/spring-geode-samples/boot/configuration/src/main/resources/geode/bin/stop-cluster.gfsh" +gfsh -e "run --file=@samples-dir@boot/configuration/src/main/resources/geode/bin/stop-cluster.gfsh" diff --git a/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties b/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties index 084cfe62..58dc19a2 100644 --- a/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties +++ b/spring-geode-samples/boot/configuration/src/main/resources/geode/config/gemfire.properties @@ -7,8 +7,8 @@ security-username=test security-password=test ssl-enabled-components=locator,server ssl-require-authentication=false -ssl-keystore=/Users/jblum/pivdev/spring-boot-data-geode/spring-geode-samples/boot/configuration/src/main/resources/example-trusted.jks +ssl-keystore=@samples-dir@boot/configuration/build/resources/main/example-trusted-keystore.jks ssl-keystore-password=s3cr3t ssl-keystore-type=JKS -ssl-truststore=/Users/jblum/pivdev/spring-boot-data-geode/spring-geode-samples/boot/configuration/src/main/resources/example-trusted.jks +ssl-truststore=@samples-dir@boot/configuration/build/resources/main/example-trusted-keystore.jks ssl-truststore-password=s3cr3t