Maven Setup

Introduction
Historically, CLDR has used ant for its build process. For a number of reasons, CLDR is switching to Maven.

Note: As of this writing, both Ant and Maven may be used at the same time, but Ant is expected to be phased out.
As Eclipse is not working well with the current state of the Maven build, this document will not address using Maven with Eclipse, but only Maven from the command line.

CLDR-11585 is the main ticket which adds Maven support in the CLDR 38/39 time frame.

The purpose of this document is to assist with initial configuration of Maven.
CLDR pulls pre-release ICU4J jars from ICU's GitHub Maven repository.

At present, GitHub requires authentication even for publicly accessible repositories.

A. Getting Started - GitHub token

We are going to create a token. A token is used like a password, and should be kept secret as one. You can revoke a token independently from all other tokens, so we will create a token specifically for this use.

1. go to https://github.com/settings/tokens - you may need to login with a 2nd factor.

2. click "generate new token".
  • update the Note, something you will remember such as "Maven settings on my laptop"
  • give the token "read:packages" scope (permission). 
  • Click the "Generate Token" button at the bottom.
  • You will see the new token (random numbers and letters) at the top of the page. Copy it down for the following steps, but you will not need to save it permanently. 
  • You're done with this page now.
B. Installing Maven

You can run "mvn --version" from the command line to see if Maven is already installed. If you see "Apache Maven 3…" then you are ready to go.

Otherwise, install the "maven" package from your OS or other package manager, or see instructions under https://maven.apache.org/

C. Configuring Maven

It might be helpful to refer to the GitHub documentation and the Maven documentation for settings during this step.

The file you will be modifying is .m2/settings.xml (the .m2 directory is in your HOME directory, create it if it does not exist).

If the file doesn't exist, create it with this content.  If it does exist, add the <server> stanza into the <servers> section.
Keep the id "githubicu" as it is.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

 <servers>

  <server>

   <id>githubicu</id>
   <username>your github id</username>
   <password>your access token</password>
  </server>

 </servers>

</settings>

D. Try It Out

go into the cldr/tools directory and run:

mvn package

This will create tools/java/target/cldr*.jar, as well as tools/cldr-apps/target/cldr-apps.war

E. More details

Running specific tests:

    Example to run only one test from the main unit tests and one test in the web tests: (one long command line, two separate parameters)

        mvn test '-Dorg.unicode.cldr.unittest.testArgs=-f:TestUntimedCounter -n -q' 
                 
'-Dorg.unicode.cldr.unittest.web.testArgs=-f:TestMisc -n -q'

Running a specific tool:

mvn -DCLDR_DIR=$HOME/src/cldr exec:java -pl java -Dexec.mainClass=org.unicode.cldr.json.Ldml2JsonConverter -Dexec.args='-p true -r true -t main -m "de"'



Comments