diff --git a/bin/dwh-migration-dumper b/bin/dwh-migration-dumper index e56127d7b..f7a1981f5 100755 --- a/bin/dwh-migration-dumper +++ b/bin/dwh-migration-dumper @@ -1,12 +1,27 @@ -#!/bin/sh -ex +#!/bin/bash +# Copyright 2024 Google LLC +# +# 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 +# +# 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. + +set -e BASE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>&1 > /dev/null && cd .. && pwd) -. "${BASE_DIR}/dumper/app/src/main/sh/java_versioning.sh" -BASE_BIN_DIR="${BASE_DIR}/dumper/app/build/install/app/bin" -BIN=$(is_java_greater_than_8 && echo "${BASE_BIN_DIR}/dwh-migration-dumper" || echo "${BASE_BIN_DIR}/dwh-migration-dumper-java8") +BIN="${BASE_DIR}/dumper/app/build/install/app/bin/dwh-migration-dumper-starter" if [ ! -x "$BIN" ] ; then (cd "${BASE_DIR}" && ./gradlew --parallel :dumper:app:installDist) fi -exec "$BIN" "$@" \ No newline at end of file +export JDK_JAVA_OPTIONS="--add-opens=java.base/java.nio=ALL-UNNAMED" + +exec "$BIN" "$@" diff --git a/bin/dwh-migration-dumper.bat b/bin/dwh-migration-dumper.bat new file mode 100755 index 000000000..e1a9544a9 --- /dev/null +++ b/bin/dwh-migration-dumper.bat @@ -0,0 +1,19 @@ +@rem Copyright 2024 Google LLC +@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 http://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. + +@if "%DEBUG%"=="" @echo off +set JDK_JAVA_OPTIONS="--add-opens=java.base/java.nio=ALL-UNNAMED" + +set "DIRNAME=%~dp0..\dumper\app\build\install\app\bin" +"%DIRNAME%\dwh-migration-dumper-starter.bat" %* diff --git a/dumper/app/build.gradle b/dumper/app/build.gradle index a567312d8..7c0703ced 100644 --- a/dumper/app/build.gradle +++ b/dumper/app/build.gradle @@ -123,19 +123,11 @@ jacocoTestReport { } startScripts { + applicationName = "dwh-migration-dumper-starter" classpath = files('$APP_HOME/lib/*') - defaultJvmOpts = ["--add-opens=java.base/java.nio=ALL-UNNAMED"] -} - -task createStartScriptForJava8(type: CreateStartScripts) { - mainClass = tasks.startScripts.mainClass - applicationName = 'dwh-migration-dumper-java8' - outputDir = tasks.startScripts.outputDir - classpath = tasks.startScripts.classpath } tasks.named('installDist') { - dependsOn 'createStartScriptForJava8' dependsOn 'cloudExtractorStartScripts' dependsOn 'cloudExtractorStartScriptsForJava8' } @@ -944,6 +936,12 @@ distributions { from(cloudExtractorStartScripts) { into "bin" } + from("src/main/sh/dwh-migration-dumper") { + into "bin" + } + from("src/main/sh/dwh-migration-dumper.bat") { + into "bin" + } from(generateLicenseReport) { into "docs/licenses" } diff --git a/dumper/app/src/main/sh/dwh-migration-dumper b/dumper/app/src/main/sh/dwh-migration-dumper new file mode 100755 index 000000000..9576df858 --- /dev/null +++ b/dumper/app/src/main/sh/dwh-migration-dumper @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright 2024 Google LLC +# +# 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 +# +# 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. + +set -e + +BASE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>&1 > /dev/null && cd .. && pwd) +BIN="${BASE_DIR}/bin/dwh-migration-dumper-starter" + +export JDK_JAVA_OPTIONS="--add-opens=java.base/java.nio=ALL-UNNAMED" + +exec "$BIN" "$@" diff --git a/dumper/app/src/main/sh/dwh-migration-dumper.bat b/dumper/app/src/main/sh/dwh-migration-dumper.bat new file mode 100755 index 000000000..153d32175 --- /dev/null +++ b/dumper/app/src/main/sh/dwh-migration-dumper.bat @@ -0,0 +1,19 @@ +@rem Copyright 2024 Google LLC +@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 http://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. + +@if "%DEBUG%"=="" @echo off +set JDK_JAVA_OPTIONS="--add-opens=java.base/java.nio=ALL-UNNAMED" + +set "DIRNAME=%~dp0" +"%DIRNAME%\dwh-migration-dumper-starter.bat" %* diff --git a/dumper/app/src/main/sh/java_versioning.sh b/dumper/app/src/main/sh/java_versioning.sh index 7a54d2d40..8a5473507 100755 --- a/dumper/app/src/main/sh/java_versioning.sh +++ b/dumper/app/src/main/sh/java_versioning.sh @@ -1,16 +1,28 @@ #!/bin/bash +# Copyright 2024 Google LLC +# +# 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 +# +# 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. function is_java_greater_than_8() { - java_path=$(which java) - java_version_output=$($java_path -version 2>&1) + java_version_output="$(java -version 2>&1)" - # Will return 1 for all versions before Java 9, but we do not care. - java_major_version=$(echo "$java_version_output" | grep -Eoi 'version "?([0-9]+)' | head -1 | cut -d'"' -f2 | cut -d'.' -f1) + # Will return 1 for all versions before Java 9. + java_major_version="$(echo "$java_version_output" | grep -Eoi 'version "?([0-9]+)' | head -1 | cut -d'"' -f2 | cut -d'.' -f1)" # Check if the major version is greater than 8. - if [[ $java_major_version -gt 8 ]]; then + if [[ "$java_major_version" -gt 8 ]]; then return 0 # True else return 1 # False fi -} \ No newline at end of file +}