Skip to content

Commit

Permalink
ICU-22324 Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
echeran committed Oct 5, 2023
1 parent 6129054 commit 9468f7b
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 33 deletions.
84 changes: 84 additions & 0 deletions icu4j/extract-data-files.sh
Original file line number Diff line number Diff line change
@@ -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
61 changes: 28 additions & 33 deletions icu4j/maven-migration/toMaven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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."
Expand All @@ -74,23 +74,23 @@ 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 {} \;
}

# 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`
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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'"
Expand Down Expand Up @@ -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
Expand All @@ -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/
}
Expand Down Expand Up @@ -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/
}

# ===============================================================
Expand Down

0 comments on commit 9468f7b

Please sign in to comment.