From 9468f7b325b60089b90d96a8309b2e0e1ccbd251 Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Thu, 5 Oct 2023 11:40:23 -0700 Subject: [PATCH] ICU-22324 Apply review feedback --- icu4j/extract-data-files.sh | 84 ++++++++++++++++++++++++++++++++ icu4j/maven-migration/toMaven.sh | 61 +++++++++++------------ 2 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 icu4j/extract-data-files.sh diff --git a/icu4j/extract-data-files.sh b/icu4j/extract-data-files.sh new file mode 100644 index 000000000000..01e491249dc9 --- /dev/null +++ b/icu4j/extract-data-files.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 and later: Unicode, Inc. and others. +# License & terms of use: http://www.unicode.org/copyright.html + +if [ -z "$ICU_DATA_VER" ]; then + echo "ICU_DATA_VER must be set to the icu folder name (for example icudt74b)" + exit +fi + +# Check that all the .jar files are present +JAR_FILE=main/shared/data/icudata.jar +if [ ! -f "$JAR_FILE" ]; then + echo "Missing $JAR_FILE" + exit +fi +JAR_FILE=main/shared/data/icutzdata.jar +if [ ! -f "$JAR_FILE" ]; then + echo "Missing $JAR_FILE" + exit +fi +JAR_FILE=main/shared/data/testdata.jar +if [ ! -f "$JAR_FILE" ]; then + echo "Missing $JAR_FILE" + exit +fi + +# Unpack the pre-built .jar files with data only + +echo "Unpacking icudata.jar" +rm -fr main/core/src/main/resources/com/ibm/icu/impl/data/icudt* +unzip -q -d main/core/src/main/resources/ main/shared/data/icudata.jar +rm -fr main/core/src/main/resources/META-INF + +echo " Moving charset data" +rm -fr main/charset/src/main/resources/com/ibm/icu/impl/data/icudt* +mkdir -p main/charset/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/*.cnv main/charset/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/cnvalias.icu main/charset/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ + +echo " Moving currency data" +rm -fr main/currdata/src/main/resources/com/ibm/icu/impl/data/icudt* +mkdir -p main/currdata/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/curr main/currdata/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/curr + +echo " Moving collate data" +rm -fr main/collate/src/main/resources/com/ibm/icu/impl/data/icudt* +mkdir -p main/collate/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/coll main/collate/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/coll + +echo " Moving langdata data" +rm -fr main/langdata/src/main/resources/com/ibm/icu/impl/data/icudt* +mkdir -p main/langdata/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/lang main/langdata/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/lang + +echo " Moving regiondata data" +rm -fr main/regiondata/src/main/resources/com/ibm/icu/impl/data/icudt* +mkdir -p main/regiondata/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/region main/regiondata/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/region + +echo " Moving translit data" +rm -fr main/translit/src/main/resources/com/ibm/icu/impl/data/icudt* +mkdir -p main/translit/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/ +mv main/core/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/translit main/translit/src/main/resources/com/ibm/icu/impl/data/${ICU_DATA_VER}/translit + +echo "Unpacking icutzdata.jar" +# This unzips together with other existing core files +# So we don't remove the folder +unzip -q -d main/core/src/main/resources/ main/shared/data/icutzdata.jar +rm -fr main/core/src/main/resources/META-INF + +echo "Unpacking testdata.jar" +rm -fr main/core/src/test/resources/com/ibm/icu/dev/data/testdata/ +unzip -q -d main/core/src/test/resources/ main/shared/data/testdata.jar +rm -fr main/core/src/test/resources/META-INF + +echo "Removing jar files" +echo " icudata.jar" +rm main/shared/data/icudata.jar +echo " icutzdata.jar" +rm main/shared/data/icutzdata.jar +echo " testdata.jar" +rm main/shared/data/testdata.jar + +echo DONE diff --git a/icu4j/maven-migration/toMaven.sh b/icu4j/maven-migration/toMaven.sh index 33912b5db647..b7f8899001ac 100755 --- a/icu4j/maven-migration/toMaven.sh +++ b/icu4j/maven-migration/toMaven.sh @@ -33,10 +33,10 @@ function safeMkdir() { } function moveOrRename() { - SRC=$1 - DEST=$2 + local SRC=$1 + local DEST=$2 - mv "$1" "$2" + mv "$SRC" "$DEST" } function rmDirIfExists() { @@ -48,16 +48,16 @@ function rmFileIfExists() { } function copyRecursive() { - SRC=$1 - DEST=$2 + local SRC=$1 + local DEST=$2 - cp -R "$1" "$2" + cp -R "$SRC" "$DEST" } function safeMoveDir() { - export FOLDER_NAME=$1 - export FROM_FOLDER=$2 - export TO_FOLDER=$3 + local FOLDER_NAME=$1 + local FROM_FOLDER=$2 + local TO_FOLDER=$3 if [ ! -d "$FROM_FOLDER/$FOLDER_NAME" ]; then echo " No '$FROM_FOLDER/$FOLDER_NAME' to move." @@ -74,15 +74,15 @@ function safeMoveDir() { } function rmFileGlobInDir() { - DIR=$1 - PATTERN=$2 + local DIR=$1 + local PATTERN=$2 - find "$DIR" -type f -name "$PATTERN" -exec rm {} \; + find "$DIR" -type f -name "$PATTERN" -exec rm {} \; } function keepOnlyFileGlobInDir() { - DIR=$1 - PATTERN=$2 + local DIR=$1 + local PATTERN=$2 find "$DIR" -type f -not -name "$PATTERN" -exec rm {} \; } @@ -90,7 +90,7 @@ function keepOnlyFileGlobInDir() { # Split the content of the `java` foldert into `java` and `resources`, the way maven wants it function splitJavaToResources() { # Should point to the folder containing `java`, either main/ or test/ - export BASE_FOLDER=$1 + local BASE_FOLDER=$1 echo " Splitting '$BASE_FOLDER/java/' into '$BASE_FOLDER/java/' and '$BASE_FOLDER/resources/'" # copy `java` to `resources` @@ -103,7 +103,7 @@ function splitJavaToResources() { function removeEclipseProjectFiles() { # Should point to the old folder (to be moved), containing the eclipse / ant files - export BASE_FOLDER=$1 + local BASE_FOLDER=$1 # Cleanup Eclipse project & launcher files, ant projects, other stuff # Eclipse @@ -121,7 +121,7 @@ function removeEclipseProjectFiles() { # Takes a folder as parameter and removes the all the empty sub-folders. function removeEmptyFolders() { - export BASE_FOLDER=$1 + local BASE_FOLDER=$1 # `find -type d .` finds all subfolders, empty or not. # We can't just force delete (-r), as that would also delete non-empty folders. # And the find iteration is not children first, but parent first. @@ -144,11 +144,11 @@ function removeEmptyFolders() { function moveMainModuleToMaven() { # 1. $1: component name (core, charset, etc) - export MODULE_NAME=$1 + local MODULE_NAME=$1 # 2. folder name in the pre-maven structure (`classes` or `tests`) - export SRC_TYPE=$2 + local SRC_TYPE=$2 # 3. folder name in the maven standard structure (`main` or `test`) - export TRG_TYPE=$3 + local TRG_TYPE=$3 if [ ! -d main/$SRC_TYPE/$MODULE_NAME ]; then echo " Module '$MODULE_NAME' does not have '$SRC_TYPE' to move to '$TRG_TYPE'" @@ -186,8 +186,8 @@ function mainModuleToMaven() { function simpleModuleToMaven() { # 1. $1: component name (core, charset, etc) - export MODULE_NAME=$1 - export LICENSE_PATH=$2 + local MODULE_NAME=$1 + local LICENSE_PATH=$2 echo "Migrating $MODULE_NAME to maven" safeMoveDir com $MODULE_NAME/src $MODULE_NAME/src/main/java @@ -203,8 +203,8 @@ function simpleModuleToMaven() { } function moveCoreTestFileToCommon() { - export FOLDER_NAME=$1 - export FILE_NAME=$2 + local FOLDER_NAME=$1 + local FILE_NAME=$2 safeMkdir $COMMON_TEST_FOLDER/$FOLDER_NAME moveOrRename $CORE_TEST_FOLDER/$FOLDER_NAME/$FILE_NAME $COMMON_TEST_FOLDER/$FOLDER_NAME/ } @@ -268,17 +268,12 @@ function moveCircDepTestOutOfCore() { rm -d main/core/src/test/java/com/ibm/icu/dev/test/serializable } -function moveToolsFile() { - export FILE_NAME=$1 - safeMkdir $TOOLS_SRC_SHARED_SUBFOLDER - moveOrRename $TOOLS_SRC_ROOT_FOLDER/$FILE_NAME $TOOLS_SRC_SHARED_SUBFOLDER/ -} - function moveFilesInTools() { - export TOOLS_SRC_ROOT_FOLDER=tools/misc/src/main/java/com/ibm/icu/dev/tool - export TOOLS_SRC_SHARED_SUBFOLDER=tools/misc/src/main/java/com/ibm/icu/dev/tool/shared + local TOOLS_SRC_ROOT_FOLDER=tools/misc/src/main/java/com/ibm/icu/dev/tool + local TOOLS_SRC_SHARED_SUBFOLDER=tools/misc/src/main/java/com/ibm/icu/dev/tool/shared - moveToolsFile UOption.java + safeMkdir $TOOLS_SRC_SHARED_SUBFOLDER + moveOrRename $TOOLS_SRC_ROOT_FOLDER/UOption.java $TOOLS_SRC_SHARED_SUBFOLDER/ } # ===============================================================