From a7a2fdbcf257fa22c7a24cfae838675dafd5e071 Mon Sep 17 00:00:00 2001 From: Mihai Nita Date: Wed, 22 Feb 2023 00:08:00 -0800 Subject: [PATCH] ICU-22324 Script moving folders to maven structure --- icu4j/maven-migration/README_MAVEN.md | 49 +++ icu4j/maven-migration/demos/pom.xml | 38 ++ icu4j/maven-migration/main/charset/pom.xml | 58 ++++ icu4j/maven-migration/main/collate/pom.xml | 69 ++++ .../maven-migration/main/common_tests/pom.xml | 102 ++++++ icu4j/maven-migration/main/core/pom.xml | 59 ++++ icu4j/maven-migration/main/currdata/pom.xml | 29 ++ icu4j/maven-migration/main/framework/pom.xml | 45 +++ icu4j/maven-migration/main/icu4j/pom.xml | 77 +++++ icu4j/maven-migration/main/langdata/pom.xml | 29 ++ icu4j/maven-migration/main/localespi/pom.xml | 223 ++++++++++++ icu4j/maven-migration/main/pom.xml | 43 +++ icu4j/maven-migration/main/regiondata/pom.xml | 29 ++ icu4j/maven-migration/main/translit/pom.xml | 64 ++++ icu4j/maven-migration/pom.xml | 327 ++++++++++++++++++ icu4j/maven-migration/samples/pom.xml | 33 ++ icu4j/maven-migration/toMaven.sh | 290 ++++++++++++++++ icu4j/maven-migration/tools/build/pom.xml | 31 ++ icu4j/maven-migration/tools/misc/pom.xml | 34 ++ icu4j/maven-migration/unpack_jars.sh | 46 +++ 20 files changed, 1675 insertions(+) create mode 100644 icu4j/maven-migration/README_MAVEN.md create mode 100644 icu4j/maven-migration/demos/pom.xml create mode 100644 icu4j/maven-migration/main/charset/pom.xml create mode 100644 icu4j/maven-migration/main/collate/pom.xml create mode 100644 icu4j/maven-migration/main/common_tests/pom.xml create mode 100644 icu4j/maven-migration/main/core/pom.xml create mode 100644 icu4j/maven-migration/main/currdata/pom.xml create mode 100644 icu4j/maven-migration/main/framework/pom.xml create mode 100644 icu4j/maven-migration/main/icu4j/pom.xml create mode 100644 icu4j/maven-migration/main/langdata/pom.xml create mode 100644 icu4j/maven-migration/main/localespi/pom.xml create mode 100644 icu4j/maven-migration/main/pom.xml create mode 100644 icu4j/maven-migration/main/regiondata/pom.xml create mode 100644 icu4j/maven-migration/main/translit/pom.xml create mode 100644 icu4j/maven-migration/pom.xml create mode 100644 icu4j/maven-migration/samples/pom.xml create mode 100755 icu4j/maven-migration/toMaven.sh create mode 100644 icu4j/maven-migration/tools/build/pom.xml create mode 100644 icu4j/maven-migration/tools/misc/pom.xml create mode 100755 icu4j/maven-migration/unpack_jars.sh diff --git a/icu4j/maven-migration/README_MAVEN.md b/icu4j/maven-migration/README_MAVEN.md new file mode 100644 index 00000000000..2adf4d1fff8 --- /dev/null +++ b/icu4j/maven-migration/README_MAVEN.md @@ -0,0 +1,49 @@ +# Maven progress + +## Running the migration scripts + +Change the folder to `/icu4j/` and run `maven-migration/toMaven.sh`. + +For convenience you can copy the `maven-migration` folder somewhere else and +run the script from there. \ +But the current folder when running the script MUST be `/icu4j/`. \ +This is convenient if you work in a feature branch and don't want to integrate +from `main` at this point. \ +So you checkout `main`, copy the `maven-migration` folder somewhere else, +checkout ``, and run script from where you copied it. + +## TODO + +- Packaging the many data files in a jar is slow (especially core) +- The data files (.res & Co.) are spread out in the various modules. + So we would need a (non maven) step to distribute them. + Probably modify the step that produces the .jar files (in the C/C++ world) +- done: The tests for localespi should become integration tests +- We might want some integration tests to begin with +- `LICENSE`, `security.policy`, anything else from `main/shared/` => LICENSE should be symlink. +- done: The `.lst` files. All tests pass without, we can probably delete them. But need more testing. + If not, we need a way to generate them (right now I've copied them by hand) +- Double-check dependencies. + Also see https://stackoverflow.com/questions/27726779/declare-maven-dependency-as-test-runtime-only +- BOM (Bill of Materials). See https://reflectoring.io/maven-bom/ +- See the library shared with cldr tools +- Also to do: + - promote this one folder up? + - done: - build things in parent (demos, samples, tools) + - done: - from the parent folder these will go away + - `main/` ? + - `maven/` + - `maven-build/` + - `manifest.stub` + - `coverage-exclusion.txt` + - `build.xml` + - `ivy.xml` +- Change icu4j artifact description: \ + from "International Component for Unicode for Java" \ + to "International Components for Unicode for Java" (Components) \ + Fix all instances (found 6 instances, 4 in older pom.xml files, 2 in .md files) + +> Copyright © 2023 and later Unicode, Inc. and others. All Rights Reserved. +Unicode and the Unicode Logo are registered trademarks +of Unicode, Inc. in the U.S. and other countries. +[Terms of Use and License](http://www.unicode.org/copyright.html) diff --git a/icu4j/maven-migration/demos/pom.xml b/icu4j/maven-migration/demos/pom.xml new file mode 100644 index 00000000000..b393e620371 --- /dev/null +++ b/icu4j/maven-migration/demos/pom.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + + com.ibm.icu + icu4j-root + 74.0.1-SNAPSHOT + + + demos + + + ${project.basedir}/.. + + + + + com.ibm.icu + core + ${project.version} + + + com.ibm.icu + icu4j-charset + ${project.version} + + + com.ibm.icu + translit + ${project.version} + + + + diff --git a/icu4j/maven-migration/main/charset/pom.xml b/icu4j/maven-migration/main/charset/pom.xml new file mode 100644 index 00000000000..9280007fc30 --- /dev/null +++ b/icu4j/maven-migration/main/charset/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + icu4j-charset + + + ${project.basedir}/../.. + com.ibm.icu.charset + + + + + com.ibm.icu + core + ${project.version} + + + + com.ibm.icu + core + ${project.version} + test-jar + test + + + com.ibm.icu + framework + ${project.version} + test-jar + test + + + + junit + junit + ${junit.version} + test + + + pl.pragmatists + JUnitParams + ${junitparams.version} + test + + + + + diff --git a/icu4j/maven-migration/main/collate/pom.xml b/icu4j/maven-migration/main/collate/pom.xml new file mode 100644 index 00000000000..6d7ccfaae3c --- /dev/null +++ b/icu4j/maven-migration/main/collate/pom.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + collate + + + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + + com.ibm.icu + core + ${project.version} + test-jar + test + + + com.ibm.icu + framework + ${project.version} + test-jar + test + + + com.ibm.icu + langdata + ${project.version} + test + + + com.ibm.icu + regiondata + ${project.version} + test + + + com.ibm.icu + currdata + ${project.version} + test + + + + junit + junit + ${junit.version} + test + + + + diff --git a/icu4j/maven-migration/main/common_tests/pom.xml b/icu4j/maven-migration/main/common_tests/pom.xml new file mode 100644 index 00000000000..e70a1eefb70 --- /dev/null +++ b/icu4j/maven-migration/main/common_tests/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + common_tests + + + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + com.ibm.icu + core + ${project.version} + test-jar + test + + + com.ibm.icu + framework + ${project.version} + test-jar + test + + + com.ibm.icu + currdata + ${project.version} + test + + + com.ibm.icu + translit + ${project.version} + test + + + com.ibm.icu + langdata + ${project.version} + test + + + com.ibm.icu + collate + ${project.version} + test + + + com.ibm.icu + regiondata + ${project.version} + test + + + + junit + junit + ${junit.version} + test + + + pl.pragmatists + JUnitParams + ${junitparams.version} + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + diff --git a/icu4j/maven-migration/main/core/pom.xml b/icu4j/maven-migration/main/core/pom.xml new file mode 100644 index 00000000000..849205595a1 --- /dev/null +++ b/icu4j/maven-migration/main/core/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + core + + + ${project.basedir}/../.. + + + + + com.ibm.icu + framework + ${project.version} + test-jar + test + + + + junit + junit + ${junit.version} + test + + + pl.pragmatists + JUnitParams + ${junitparams.version} + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + diff --git a/icu4j/maven-migration/main/currdata/pom.xml b/icu4j/maven-migration/main/currdata/pom.xml new file mode 100644 index 00000000000..9ec3ef5871b --- /dev/null +++ b/icu4j/maven-migration/main/currdata/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + currdata + + + currency data + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + diff --git a/icu4j/maven-migration/main/framework/pom.xml b/icu4j/maven-migration/main/framework/pom.xml new file mode 100644 index 00000000000..e3eec4f8a61 --- /dev/null +++ b/icu4j/maven-migration/main/framework/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + framework + + + ${project.basedir}/../.. + + + + + junit + junit + ${junit.version} + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + diff --git a/icu4j/maven-migration/main/icu4j/pom.xml b/icu4j/maven-migration/main/icu4j/pom.xml new file mode 100644 index 00000000000..461d8a512e4 --- /dev/null +++ b/icu4j/maven-migration/main/icu4j/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + icu4j + + + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + com.ibm.icu + collate + ${project.version} + + + com.ibm.icu + currdata + ${project.version} + + + com.ibm.icu + langdata + ${project.version} + + + com.ibm.icu + regiondata + ${project.version} + + + com.ibm.icu + translit + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + + + + shade + + package + + true + ${project.build.directory}/dependency-reduced-pom.xml + true + + + + + + + + diff --git a/icu4j/maven-migration/main/langdata/pom.xml b/icu4j/maven-migration/main/langdata/pom.xml new file mode 100644 index 00000000000..f367b5505c9 --- /dev/null +++ b/icu4j/maven-migration/main/langdata/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + langdata + + + language data + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + diff --git a/icu4j/maven-migration/main/localespi/pom.xml b/icu4j/maven-migration/main/localespi/pom.xml new file mode 100644 index 00000000000..ae4b1364512 --- /dev/null +++ b/icu4j/maven-migration/main/localespi/pom.xml @@ -0,0 +1,223 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + icu4j-localespi + + + JDK locale service provider + ${project.basedir}/../.. + com.ibm.icu.localespi + + + + + com.ibm.icu + icu4j + ${project.version} + + + + + com.ibm.icu + core + ${project.version} + test-jar + test + + + com.ibm.icu + framework + ${project.version} + test-jar + test + + + com.ibm.icu + currdata + ${project.version} + test + + + com.ibm.icu + langdata + ${project.version} + test + + + com.ibm.icu + regiondata + ${project.version} + test + + + + junit + junit + ${junit.version} + test + + + + + + + maven-surefire-plugin + + + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + it-test-copy-localespi-extension-jars + integration-test + + copy + + + + + ${project.groupId} + icu4j + ${project.version} + ${project.packaging} + + + ${project.groupId} + icu4j-localespi + ${project.version} + ${project.packaging} + + + + ${java.io.tmpdir}/ext-test-jars + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + + integration-test + + + + + + + **/*.java + + **/IT*.java + **/*IT.java + **/*ITCase.java + + + + + ${localespi-tests.jvm.args} + + + + ${localespi-tests.locale-providers} + + + + + + + + + + + + localespi-tests-java8 + + (,8] + + + -Djava.ext.dirs="${java.io.tmpdir}/ext-test-jars" + + + + + + localespi-tests-java9 + + [9,) + + + + CLDR,COMPAT,SPI + + + + + diff --git a/icu4j/maven-migration/main/pom.xml b/icu4j/maven-migration/main/pom.xml new file mode 100644 index 00000000000..4bc19ce624b --- /dev/null +++ b/icu4j/maven-migration/main/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + com.ibm.icu + icu4j-root + 74.0.1-SNAPSHOT + + + main + pom + + + ${project.basedir}/.. + + + + framework + core + + + charset + collate + currdata + langdata + regiondata + translit + common_tests + + + icu4j + + + localespi + + + diff --git a/icu4j/maven-migration/main/regiondata/pom.xml b/icu4j/maven-migration/main/regiondata/pom.xml new file mode 100644 index 00000000000..179aa7ad805 --- /dev/null +++ b/icu4j/maven-migration/main/regiondata/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + regiondata + + + region data + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + diff --git a/icu4j/maven-migration/main/translit/pom.xml b/icu4j/maven-migration/main/translit/pom.xml new file mode 100644 index 00000000000..eee8980f4f9 --- /dev/null +++ b/icu4j/maven-migration/main/translit/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + com.ibm.icu + main + 74.0.1-SNAPSHOT + + + translit + + + transliteration + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + + + com.ibm.icu + core + ${project.version} + test-jar + test + + + com.ibm.icu + framework + ${project.version} + test-jar + test + + + com.ibm.icu + langdata + ${project.version} + test + + + + junit + junit + ${junit.version} + test + + + pl.pragmatists + JUnitParams + ${junitparams.version} + test + + + + diff --git a/icu4j/maven-migration/pom.xml b/icu4j/maven-migration/pom.xml new file mode 100644 index 00000000000..7c68b125cbb --- /dev/null +++ b/icu4j/maven-migration/pom.xml @@ -0,0 +1,327 @@ + + + + 4.0.0 + + com.ibm.icu + icu4j-root + 74.0.1-SNAPSHOT + pom + + ${proj-title} (${project.artifactId}) + International Component for Unicode for Java (ICU4J) is a mature, widely used Java library + providing Unicode and Globalization support + + + Unicode, Inc. + https://icu.unicode.org/ + + + + main + demos + samples + tools/build + tools/misc + + + + UTF-8 + 1.8 + 1.8 + + 4.13.2 + 1.1.1 + + International Components for Unicode for Java + ${project.artifactId} + + 1.0 + ${proj-title} (${proj.displayname}) + ${proj-title} (${proj.displayname}) + ${proj-title} (${proj.displayname}) + com.ibm.icu.${project.artifactId} + + 73 Release Candidate + + ICU4J ${api.doc.version} + ICU4J ${api.doc.version} + <font size=-1>Copyright © 2016 Unicode, Inc. and others.</font> + + ${project.basedir} + + 73 + 73.0.1 + 73.0.1 + + Unicode, Inc. + Unicode, Inc. + Unicode, Inc. + org.unicode + 2 + ICU4J ${proj.displayname} + + com.ibm.icu.${project.artifactId} + © 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html + JavaSE-1.8 + + + + + + + maven-clean-plugin + 3.3.1 + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.11.0 + + + maven-surefire-plugin + 3.1.2 + + + maven-install-plugin + 3.1.1 + + + maven-deploy-plugin + 3.1.1 + + + maven-site-plugin + 4.0.0-M9 + + + maven-source-plugin + 3.3.0 + + + maven-project-info-reports-plugin + 3.4.5 + + + maven-shade-plugin + 3.5.0 + + + maven-assembly-plugin + 3.6.0 + + + maven-dependency-plugin + 3.6.0 + + + maven-release-plugin + 3.0.1 + + + maven-enforcer-plugin + 3.3.0 + + + maven-javadoc-plugin + 3.5.0 + + com.ibm.icu.impl,com.ibm.icu.impl.*,com.ibm.icu.dev.*,com.ibm.icu.samples,com.ibm.icu.samples.* + + html + true + true + true + ${icu4j.api.doc.window.title} + ${icu4j.api.doc.window.title} +
${icu4j.api.doc.header}
+ ${icu4j.api.doc.copyright.footer} + stylesheet8.css + UTF-8 + UTF-8 + UTF-8 + true + true + + + -J-Djcitesourcepath=${icu4j.api.doc.root.dir}/samples/src/main/java${path.separator}${icu4j.api.doc.root.dir}/demos/src/main/java${path.separator}${icu4j.api.doc.root.dir}/main/core/src/main/java + -J-Dfile.encoding=UTF-8 + -J-Djciteverbose=true + + + + com.ibm.icu.dev.tool.docs.ICUTaglet + + ${icu4j.api.doc.root.dir}/tools/build/target/classes + + + ch.arrenbrecht.jcite.JCiteTaglet + + + + + org.mcraig + jcite + 1.13.0 + + + + commons-discovery + commons-discovery + 0.5 + + + commons-logging + commons-logging + 1.2 + + + + + category + a + Category: + + +
+
+ + maven-jar-plugin + 3.3.0 + + + + true + true + + + ${mf.Automatic-Module-Name} + ${mf.Bundle-Copyright} + ${mf.Specification-Title} + ${mf.Specification-Version} + ${mf.Specification-Vendor} + ${mf.Implementation-Title} + ${mf.Implementation-Version} + ${mf.Implementation-Vendor} + ${mf.Implementation-Vendor-Id} + ${mf.Bundle-ManifestVersion} + ${mf.Bundle-Name} + ${mf.Bundle-Description} + ${mf.Bundle-SymbolicName} + ${mf.Bundle-Version} + ${mf.Bundle-Vendor} + ${mf.Bundle-Copyright} + ${mf.Bundle-RequiredExecutionEnvironment} + + + + +
+
+ + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-maven + + enforce + + + + + 3.2.5 + + + + + + + + +
+ + + + + + + with_sources + + + + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + + + + + + + with_javadoc + + + + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + + + + + + with_full_javadoc + + + + maven-javadoc-plugin + + + aggregate + site + + aggregate + + + + + + + + + + +
diff --git a/icu4j/maven-migration/samples/pom.xml b/icu4j/maven-migration/samples/pom.xml new file mode 100644 index 00000000000..353d9c09078 --- /dev/null +++ b/icu4j/maven-migration/samples/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + + com.ibm.icu + icu4j-root + 74.0.1-SNAPSHOT + + + samples + + + ${project.basedir}/.. + + + + + com.ibm.icu + core + ${project.version} + + + com.ibm.icu + collate + ${project.version} + + + + diff --git a/icu4j/maven-migration/toMaven.sh b/icu4j/maven-migration/toMaven.sh new file mode 100755 index 00000000000..2008871a58e --- /dev/null +++ b/icu4j/maven-migration/toMaven.sh @@ -0,0 +1,290 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 and later: Unicode, Inc. and others. +# License & terms of use: http://www.unicode.org/copyright.html + +# Move the sources from main/classes and main/tests into a maven structure +# - `main/classes/foo/src/java` go to `foo/src/main`, then split into `java` and `resources` +# - `main/tests/foo/src/java` go to `foo/src/test`, then split into `java` and `resources` +# - `main/tests/foo/src/META-INF` goes to ... `resources` +# +# From this: +# classes/ +# / +# src/ +# test/ +# / +# src/ +# +# To this (standard maven structure): +# / +# main/ +# src/ +# java/ +# resources/ +# test/ +# src/ +# java/ +# resources/ +# +# Then we cleanup older Eclipse project & launcher files, ant scripts, manifest.stub + +function rmDirIfExists() { + [ -d "$1" ] && rm -fr "$1" +} + +function rmFileIfExists() { + [ -f "$1" ] && rm "$1" +} + +function safeMoveDir() { + export FOLDER_NAME=$1 + export FROM_FOLDER=$2 + export TO_FOLDER=$3 + + if [ ! -d "$FROM_FOLDER/$FOLDER_NAME" ]; then + echo " No '$FROM_FOLDER/$FOLDER_NAME' to move." + return + fi + if [ -e "$TO_FOLDER/$FOLDER_NAME" ]; then + echo " Error: folder '$TO_FOLDER/$FOLDER_NAME' already exists!" + exit + else + mkdir -p $TO_FOLDER + mv $FROM_FOLDER/$FOLDER_NAME $TO_FOLDER/ + echo " Moving '$FOLDER_NAME' folder from '$FROM_FOLDER' to '$TO_FOLDER'" + fi +} + +# 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 + + echo " Splitting '$BASE_FOLDER/java/' into '$BASE_FOLDER/java/' and '$BASE_FOLDER/resources/'" + # copy `java` to `resources` + cp -R $BASE_FOLDER/java/ $BASE_FOLDER/resources/ + # delete all not `.java` from `java` + find $BASE_FOLDER/java/ -type f -not -name *.java -exec rm {} \; + # delete all `.java` from `resources` + find $BASE_FOLDER/resources/ -type f -name *.java -exec rm {} \; +} + +function removeEclipseProjectFiles() { + # Should point to the old folder (to be moved), containing the eclipse / ant files + export BASE_FOLDER=$1 + + # Cleanup Eclipse project & launcher files, ant projects, other stuff + # Eclipse + rmDirIfExists "$BASE_FOLDER/.externalToolBuilders/" + rmDirIfExists "$BASE_FOLDER/.settings/" + rmFileIfExists "$BASE_FOLDER/.project" + rmFileIfExists "$BASE_FOLDER/.classpath" + # Ant + rmFileIfExists "$BASE_FOLDER/build.properties" + rmFileIfExists "$BASE_FOLDER/build.xml" + rmFileIfExists "$BASE_FOLDER/manifest.stub" + rmFileIfExists "$BASE_FOLDER/findbugs-exclude.xml" + find $BASE_FOLDER/ -type f -name '*.launch' -exec rm {} \; +} + +# Takes a folder as parameter and removes the all the empty sub-folders. +function removeEmptyFolders() { + export 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. + # If I call this with `main/classes/` then I need a loop: + # loop 1: + # rm `main/classes/` => FAILS, not empty + # rm `main/classes/core/` => FAILS, not empty + # rm `main/classes/core/src/` => OK + # loop 2: + # rm `main/classes/` => FAILS, not empty + # rm `main/classes/core/` => OK + # loop 3: + # rm `main/classes/` => OK + # If there is any file left in some folder, that (and the parent folders) are not deleted. + # That's why we loop here (although 15 might be a bit much :-) + for ((n = 0; n < 15; n++)) do + find $BASE_FOLDER -type d -exec rm -d {} \; 2> /dev/null + done +} + +function moveMainModuleToMaven() { + # 1. $1: component name (core, charset, etc) + export MODULE_NAME=$1 + # 2. folder name in the pre-maven structure (`classes` or `tests`) + export SRC_TYPE=$2 + # 3. folder name in the maven standard structure (`main` or `test`) + export 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'" + return + fi + + safeMoveDir com main/$SRC_TYPE/$MODULE_NAME/src main/$MODULE_NAME/src/$TRG_TYPE/java + splitJavaToResources main/$MODULE_NAME/src/$TRG_TYPE + safeMoveDir META-INF main/$SRC_TYPE/$MODULE_NAME/src main/$MODULE_NAME/src/$TRG_TYPE/resources + + removeEclipseProjectFiles main/$SRC_TYPE/$MODULE_NAME + + # Remove the original (pre-maven) folders that were left empty after we moved stuff out + # For example if all we had was source code + Eclipse files the folder will be left empty. + # e.g. main/classes/collate + echo " Remove all empty pre-maven folders from 'main/$SRC_TYPE/$MODULE_NAME'" + removeEmptyFolders main/$SRC_TYPE/$MODULE_NAME + + # Remove folders that didn't receive any content in the new structure. + # For example when we copy the `java` folder to `resources`, then remove + # all the *.java files, we might end up with empty `resources` folder + # if there was no data file mixed-in with the code to begin with. + # e.g. main/collate/src/main + echo " Remove all empty post-maven folders from 'main/$MODULE_NAME/src/$TRG_TYPE'" + removeEmptyFolders main/$MODULE_NAME/src/$TRG_TYPE +} + +function mainModuleToMaven() { + echo "Migrating $1 to maven" + moveMainModuleToMaven $1 classes main + moveMainModuleToMaven $1 tests test +} + +function simpleModuleToMaven() { + # 1. $1: component name (core, charset, etc) + export MODULE_NAME=$1 + echo "Migrating $MODULE_NAME to maven" + + safeMoveDir com $MODULE_NAME/src $MODULE_NAME/src/main/java + splitJavaToResources $MODULE_NAME/src/main + + removeEclipseProjectFiles $MODULE_NAME + + echo " Remove empty folders from '$MODULE_NAME'" + removeEmptyFolders $MODULE_NAME +} + +function moveCoreTestFileToCommon() { + export FOLDER_NAME=$1 + export FILE_NAME=$2 + mkdir -p $COMMON_TEST_FOLDER/$FOLDER_NAME + mv $CORE_TEST_FOLDER/$FOLDER_NAME/$FILE_NAME $COMMON_TEST_FOLDER/$FOLDER_NAME/ +} + +function moveCircDepTestOutOfCore() { + export CORE_TEST_FOLDER=main/core/src/test/java/com/ibm/icu/dev/test + export COMMON_TEST_FOLDER=main/common_tests/src/test/java/com/ibm/icu/dev/test + + mkdir -p $CORE_TEST_FOLDER + + moveCoreTestFileToCommon calendar DataDrivenCalendarTest.java + moveCoreTestFileToCommon format CompactDecimalFormatTest.java + moveCoreTestFileToCommon format DataDrivenFormatTest.java + moveCoreTestFileToCommon format DateFormatTest.java + moveCoreTestFileToCommon format MeasureUnitTest.java + moveCoreTestFileToCommon format NumberFormatDataDrivenTest.java + moveCoreTestFileToCommon format NumberFormatRegressionTest.java + moveCoreTestFileToCommon format NumberFormatSpecificationTest.java + moveCoreTestFileToCommon format NumberFormatTest.java + moveCoreTestFileToCommon format NumberRegressionTests.java + moveCoreTestFileToCommon format PluralRangesTest.java + moveCoreTestFileToCommon format PluralRulesTest.java + moveCoreTestFileToCommon format RbnfTest.java + moveCoreTestFileToCommon format TestMessageFormat.java + moveCoreTestFileToCommon format TimeZoneFormatTest.java + moveCoreTestFileToCommon message2 Mf2FeaturesTest.java + moveCoreTestFileToCommon normalizer BasicTest.java + moveCoreTestFileToCommon number ModifierTest.java + moveCoreTestFileToCommon number NumberFormatterApiTest.java + moveCoreTestFileToCommon number NumberParserTest.java + moveCoreTestFileToCommon number NumberPermutationTest.java + moveCoreTestFileToCommon number NumberRangeFormatterTest.java + moveCoreTestFileToCommon number PatternStringTest.java + moveCoreTestFileToCommon number PropertiesTest.java + moveCoreTestFileToCommon rbbi LSTMBreakEngineTest.java + moveCoreTestFileToCommon serializable CalendarHandler.java + moveCoreTestFileToCommon serializable CompatibilityTest.java + moveCoreTestFileToCommon serializable CoverageTest.java + moveCoreTestFileToCommon serializable ExceptionHandler.java + moveCoreTestFileToCommon serializable FormatHandler.java + moveCoreTestFileToCommon serializable SerializableChecker.java + moveCoreTestFileToCommon serializable SerializableTestUtility.java + moveCoreTestFileToCommon serializable SerializableWriter.java + moveCoreTestFileToCommon stringprep TestIDNARef.java + moveCoreTestFileToCommon stringprep TestStringPrep.java + moveCoreTestFileToCommon util CurrencyTest.java + moveCoreTestFileToCommon util ICUResourceBundleTest.java + moveCoreTestFileToCommon util ICUServiceTest.java + moveCoreTestFileToCommon util LocaleDataTest.java + moveCoreTestFileToCommon util ULocaleTest.java + + # Looks like the packaging project was already some kind of test for how things come together. + # Should we move all the files in this project instead of common_tests? + mv main/tests/packaging/src/com/ibm/icu/dev/test/* $COMMON_TEST_FOLDER/ + removeEclipseProjectFiles main/tests/packaging + + # At this point this folder should be empty + # So remove if empty (-d) should work + rm -d main/core/src/test/java/com/ibm/icu/dev/test/serializable +} + +# =============================================================== +# Here starts the real script execution + +if [ ! -f "main/classes/core/build.xml" ]; then + echo "ERROR: the current folder when running this script should be /icu4j" + echo "It is currently $PWD." + exit +fi +if [ -f "main/core/pom.xml" ]; then + echo "ERROR: looks like the structure was already migrated to maven?" + exit +fi + +MVN_MIG_DIR="$(dirname "${BASH_SOURCE[0]}")" + +cp -R ${MVN_MIG_DIR}/* . +# Don't copy files that are only used for migration +rm README_MAVEN.md +rm toMaven.sh +rm unpack_jars.sh + +# Migrate the modules in icu4j/main, which have code (in main/classes) & unit tests (in main/test) +echo "====================================" +echo "==== Migrating the main modules ====" +echo "====================================" +mainModuleToMaven core +mainModuleToMaven langdata +mainModuleToMaven charset +mainModuleToMaven collate +mainModuleToMaven localespi +mainModuleToMaven translit +# main only +mainModuleToMaven currdata +mainModuleToMaven regiondata +# test only +mainModuleToMaven framework + +# Migrate the modules in icu4j, which have only code and no unit tests +echo "====================================" +echo "==== Migrating the root modules ====" +echo "====================================" +simpleModuleToMaven demos +simpleModuleToMaven samples +simpleModuleToMaven tools/build +simpleModuleToMaven tools/misc + +echo "=================================================================================" +echo "==== Moving core unit tests that depend on non-core (circular dependencies) =====" +echo "=================================================================================" + +moveCircDepTestOutOfCore + +# Some final cleanup for any empty folders +removeEmptyFolders main/classes +removeEmptyFolders main/tests + +# Unpack the CLDR data from the shared .jar files +${MVN_MIG_DIR}/unpack_jars.sh + +echo DONE diff --git a/icu4j/maven-migration/tools/build/pom.xml b/icu4j/maven-migration/tools/build/pom.xml new file mode 100644 index 00000000000..b55f3db3e65 --- /dev/null +++ b/icu4j/maven-migration/tools/build/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + com.ibm.icu + icu4j-root + 74.0.1-SNAPSHOT + ../../pom.xml + + + tools_build + + + ${project.basedir}/../.. + + + + + jdk.tools + jdk.tools + 1.8 + system + ${JAVA_HOME}/lib/tools.jar + + + + diff --git a/icu4j/maven-migration/tools/misc/pom.xml b/icu4j/maven-migration/tools/misc/pom.xml new file mode 100644 index 00000000000..766ebcaf251 --- /dev/null +++ b/icu4j/maven-migration/tools/misc/pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + + com.ibm.icu + icu4j-root + 74.0.1-SNAPSHOT + ../../pom.xml + + + tools_misc + + + ${project.basedir}/../.. + + + + + com.ibm.icu + core + ${project.version} + + + com.ibm.icu + translit + ${project.version} + + + + diff --git a/icu4j/maven-migration/unpack_jars.sh b/icu4j/maven-migration/unpack_jars.sh new file mode 100755 index 00000000000..7fafb154b1a --- /dev/null +++ b/icu4j/maven-migration/unpack_jars.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 and later: Unicode, Inc. and others. +# License & terms of use: http://www.unicode.org/copyright.html + +# Unpack the pre-built .jar files with data only + +ICU_DATA_VER=icudt74b + +echo "Unpacking icudata.jar" +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" +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" +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" +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" +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" +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" +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 icutzudata.jar" +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" +unzip -q -d main/core/src/test/resources/ main/shared/data/testdata.jar +rm -fr main/core/src/test/resources/META-INF + +echo DONE