From 3b17a492be7d54b47768c4ab9815754987e7805f Mon Sep 17 00:00:00 2001 From: David Beaumont Date: Thu, 18 Jun 2020 20:11:53 +0000 Subject: [PATCH] ICU-21142 Improving Maven handling of CLDR API Jar file for new tools. --- tools/cldr/cldr-to-icu/build-icu-data.xml | 2 +- tools/cldr/lib/README.txt | 25 ++++++++++++++++++++--- tools/cldr/lib/install-cldr-jars.sh | 5 ++++- tools/cldr/lib/pom.xml | 8 +++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tools/cldr/cldr-to-icu/build-icu-data.xml b/tools/cldr/cldr-to-icu/build-icu-data.xml index 5917adf7bf..244191ae96 100644 --- a/tools/cldr/cldr-to-icu/build-icu-data.xml +++ b/tools/cldr/cldr-to-icu/build-icu-data.xml @@ -83,7 +83,7 @@ - + diff --git a/tools/cldr/lib/README.txt b/tools/cldr/lib/README.txt index 1d5d980cb0..66df9c6232 100644 --- a/tools/cldr/lib/README.txt +++ b/tools/cldr/lib/README.txt @@ -55,6 +55,7 @@ To update the local Maven repository (e.g. to install the CLDR jar) then from this directory (lib/) you should run: $ mvn install:install-file \ + -Dproject.parent.relativePath="" \ -DgroupId=org.unicode.cldr \ -DartifactId=cldr-api \ -Dversion=0.1-SNAPSHOT \ @@ -63,10 +64,11 @@ $ mvn install:install-file \ -DlocalRepositoryPath=. \ -Dfile=/tools/java/cldr.jar -And if you have updated one of these libraries then from the main project -directory (i.e. the directory the Maven pom.xml file(s) are in) run: +And if you have updated one of these libraries then from this directory run: -$ mvn dependency:purge-local-repository -DsnapshotsOnly=true +$ mvn dependency:purge-local-repository \ + -Dproject.parent.relativePath="" \ + -DmanualIncludes=org.unicode.cldr:cldr-api:jar After doing this, you should see something like the following list of files in this directory: @@ -80,3 +82,20 @@ org/unicode/cldr/cldr-api/0.1-SNAPSHOT/cldr-api-0.1-SNAPSHOT.jar Finally, if you choose to update the version number of the snapshot, then also update all the the pom.xml files which reference it (but this is unlikely to be necessary). + +Troubleshooting +--------------- + +While the Maven system should keep the CLDR JAR up to date, there is a chance +that you may have an out of date JAR installed elsewhere. If you have any +issues with the JAR not being the expected version (e.g. after making changes) +then run the above "purge" step again, from this directory. + +This should re-resolve the current JAR snapshot from the repository in this +directory. Having purged the Maven cache, next time you build a project, you +should see something like: + +[exec] Downloading from : /org/unicode/cldr/cldr-api/0.1-SNAPSHOT/maven-metadata.xml +[exec] [INFO] Building jar: /tools/cldr/cldr-to-icu/target/cldr-to-icu-1.0-SNAPSHOT-jar-with-dependencies.jar + +This shows that it has had to re-fetch the JAR file. diff --git a/tools/cldr/lib/install-cldr-jars.sh b/tools/cldr/lib/install-cldr-jars.sh index 16f7732fd8..7b63064399 100755 --- a/tools/cldr/lib/install-cldr-jars.sh +++ b/tools/cldr/lib/install-cldr-jars.sh @@ -84,6 +84,7 @@ popd > /dev/null # The -B flag is "batch" mode and won't mess about with escape codes in the log file. echo "Installing CLDR JAR file..." run_with_logging mvn -B install:install-file \ + -Dproject.parent.relativePath="" \ -DgroupId=org.unicode.cldr \ -DartifactId=cldr-api \ -Dversion=0.1-SNAPSHOT \ @@ -93,7 +94,9 @@ run_with_logging mvn -B install:install-file \ -Dfile="${CLDR_TOOLS_DIR}/cldr.jar" echo "Syncing local Maven repository..." -run_with_logging mvn -B dependency:purge-local-repository -DsnapshotsOnly=true +run_with_logging mvn -B dependency:purge-local-repository \ + -Dproject.parent.relativePath="" \ + -DmanualIncludes=org.unicode.cldr:cldr-api:jar mv -f "${LOG_FILE}" "last_log.txt" echo "All done! (log file: last_log.txt)" diff --git a/tools/cldr/lib/pom.xml b/tools/cldr/lib/pom.xml index 41da0b1271..842e226dc3 100644 --- a/tools/cldr/lib/pom.xml +++ b/tools/cldr/lib/pom.xml @@ -26,7 +26,13 @@ to identify the absolute path of a parent POM file). However since child POM files should have a declaration with the relative path in it, we can use that. Note however that this is a bit fragile - and relies on being a directory, not a POM file. --> + and relies on being a directory, not a POM file. + + In order to allow the local repository to work either when it is used + by a child POM file or when it's used directly (e.g. for installing + or purging the cache) when it is invoked from this directory, the + -Dproject.parent.relativePath="" + argument must be given. --> local-maven-repo