Packaging ICU4J

Overview

This chapter describes, for the advanced user, how to package ICU4J for distribution.

Making ICU4J Smaller

The ICU project is intended to provide everything an application might need in order to process Unicode. However, in doing so, the results may become quite large on disk. A default build of ICU4J normally results in nearly 16 MB of data, and a substantial amount of binary code. To reduce the amount of data used, see the ICU Data chapter.

Modularization of ICU4J

Some clients may not wish to ship all of ICU4J with their application, since the application might only use a small part of ICU4J. ICU4J release 2.6 and later provide build options to build individual ICU4J 'modules' for a more compact distribution. The modules are based on a service and the APIs that define it, e.g., the normalizer module supports all the APIs of the Normalizer class (and some others). Tests can be run to verify that the APIs supported by the module function correctly. Because of internal code dependencies, a module contains extra classes that are not part of the module's core service API. Some or most of the APIs of these extra classes will not work. Only the module's core service API is guaranteed. Other APIs may work partially or not at all, so client code should avoid them.

Individual modules are not built directly into their own separate jar files. Since their dependencies often overlap, using separate modules to 'add on' ICU4J functionality would result in unwanted duplication of class files. Instead, building a module causes a subset of ICU4J's classes to be built and put into ICU4J's standard build directory. After one or more module targets are built, the 'moduleJar' target can then be built, which packages the class files into a 'module jar.' Other than the fact that it contains fewer class files, little distinguishes this jar file from a full ICU4J jar file, and in fact they share the same name.

Currently ICU4J can be divided into the following modules:

Key:

Module NameAnt TargetsTest Package SupportedSize‡
Package* Main Classes†
Note*com.ibm. should be prepended to the package name listed.

†Class in bold indicates core service API. Only APIs in this column are fully supported.

‡Sizes are of the compressed jar file containing only this module. These sizes are approximate for release3.6, they may change in future releases.

Modules:

Normalizernormalizer, normalizerTestscom.ibm.icu.dev.test.normalizer465KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, Uscript
icu.text:BreakIterator, CanonicalIterator, Normalizer, Replaceable, ReplaceableString, SymbolTable, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
Collatorcollator, collatorTestscom.ibm.icu.dev.test.collator1,911KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, Uscript
icu.text:BreakDictionary, BreakIterator, CanonicalIterator, CollationElementIterator, CollationKey, Collator, DictionaryBasedBreakIterator, Normalizer, RawCollationKey, Replaceable, ReplaceableString, RuleBasedBreakIterator, RuleBasedCollator, SymbolTable, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:ByteArrayWrapper, CompactByteArray, Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
Calendarcalendar, calendarTestscom.ibm.icu.dev.test.calendar2,176KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript
icu.math:BigDecimal, MathContext
icu.text:BreakIterator, CanonicalIterator, ChineseDateFormat, ChineseDateFormatSymbols, CollationElementIterator, CollationKey, Collator, DateFormat, DateFormatSymbols, DecimalFormat, DecimalFormatSymbols, MessageFormat, Normalizer, NumberFormat, PluralFormat, PluralRules, RawCollationKey, Replaceable, ReplaceableString, RuleBasedCollator, RuleBasedNumberFormat, RuleBasedTransliterator, SimpleDateFormat, SymbolTable, UCharacterIterator, UFormat, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:AnnualTimeZoneRule, BasicTimeZone, BuddhistCalendar, ByteArrayWrapper, Calendar, ChineseCalendar, CopticCalendar, Currency, CurrencyAmount, DateRule, DateTimeRule, EasterHoliday, EthiopicCalendar, Freezable, GregorianCalendar, HebrewCalendar, HebrewHoliday, Holiday, IndianCalendar, InitialTimeZoneRule, IslamicCalendar, JapaneseCalendar, Measure, MeasureUnit, RangeDateRule, RangeValueIterator, SimpleDateRule, SimpleHoliday, SimpleTimeZone, StringTokenizer, TaiwanCalendar, TimeZone, TimeZoneRule, TimeZoneTransition, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
BreakIteratorbreakIterator, breakIteratorTestscom.ibm.icu.dev.test.breakiterator1,889KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript
icu.text:BreakDictionary, BreakIterator, CanonicalIterator, DictionaryBasedBreakIterator, Normalizer, Replaceable, ReplaceableString, RuleBasedBreakIterator, SymbolTable, Transliterator, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:CompactByteArray, Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
Formattingformat, formatTestscom.ibm.icu.dev.test.format3,443KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript
icu.math:BigDecimal, MathContext
icu.text:BreakIterator, CanonicalIterator, ChineseDateFormat, ChineseDateFormatSymbols, CollationElementIterator, CollationKey, Collator, DateFormat, DateFormatSymbols, DecimalFormat, DecimalFormatSymbols, DurationFormat, MeasureFormat, MessageFormat, Normalizer, NumberFormat, PluralFormat, PluralRules, RawCollationKey, Replaceable, ReplaceableString, RuleBasedCollator, RuleBasedNumberFormat, SimpleDateFormat, SymbolTable, UCharacterIterator, UFormat, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:AnnualTimeZoneRule, BasicTimeZone, BuddhistCalendar, ByteArrayWrapper, Calendar, ChineseCalendar, CopticCalendar, Currency, CurrencyAmount, DateTimeRule, EthiopicCalendar, Freezable, GregorianCalendar, HebrewCalendar, IndianCalendar, InitialTimeZoneRule, IslamicCalendar, JapaneseCalendar, Measure, MeasureUnit, RangeValueIterator, SimpleTimeZone, StringTokenizer, TaiwanCalendar, TimeArrayTimeZoneRule, TimeZone, TimeZoneRule, TimeZoneTransition, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
Basic PropertiespropertiesBasic, propertiesBasicTestscom.ibm.icu.dev.test.lang554KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript, UScriptRun
icu.text:BreakDictionary, BreakIterator, DictionaryBasedBreakIterator, Normalizer, Replaceable, ReplaceableString, RuleBasedBreakIterator, SymbolTable, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:CompactByteArray, Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo

  

Full PropertiespropertiesFull, propertiesFullTestscom.ibm.icu.dev.test.lang1,829KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript, UScriptRun
icu.text:BreakDictionary, BreakIterator, DictionaryBasedBreakIterator, Normalizer, Replaceable, ReplaceableString, RuleBasedBreakIterator, SymbolTable, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:CompactByteArray, Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
StringPrep, IDNAstringPrep, stringPrepTestscom.ibm.icu.dev.test.stringprep488KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript
icu.text:StringPrep, StringParseException, SymbolTable, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo
Transformstransliterator, transliteratorTestscom.ibm.icu.dev.test.translit890KB
icu.lang:UCharacter, UCharacterCategory, UCharacterDirection, UCharacterEnums, UProperty, UScript
icu.text:BreakDictionary, BreakIterator, DictionaryBasedBreakIterator, Normalizer, Replaceable, ReplaceableString, RuleBasedBreakIterator, RuleBasedCollator, RuleBasedTransliterator, StringTransform, SymbolTable, Transliterator, UCharacterIterator, UForwardCharacterIterator, UnicodeFilter, UnicodeMatcher, UnicodeSet, UnicodeSetIterator, UTF16
icu.util:CaseInsensitiveString, CompactByteArray, Freezable, RangeValueIterator, StringTokenizer, ULocale, UResourceBundle, UResourceBundleIterator, UResourceTypeMismatchException, ValueIterator, VersionInfo

Building any of these modules is as easy as specifying a build target to the Ant build system, e.g:
To build a module that contains only the Normalizer API:

  1. Build the module.
    ant normalizer

  2. Build the jar containing the module.
    ant moduleJar

  3. Build the tests for the module.
    ant normalizerTests

  4. Run the tests and verify that the self tests pass.
    java -classpath classes com.ibm.icu.dev.test.TestAll -nothrow -w

If more than one module is required, the module build targets can be concatenated, e.g:

  1. Build the modules.
    ant normalizer collator

  2. Build the jar containing the modules.
    ant moduleJar

  3. Build the tests for the module.
    ant normalizerTests collatorTests

  4. Run the tests and verify that they pass.
    java -classpath classes com.ibm.icu.dev.test.TestAll -nothrow -w

The jar should be built before the tests, since for some targets building the tests will cause additional classes to be compiled that are not strictly necessary for the module itself.

NoteRegardless of whether ICU4J is built as a whole or as a modules, the jar file produced is named icu4j.jar.

To ascertain if an icu4j.jar contains all of ICU4J or not, please see the manifest file in the jar

The target moduleJar does not depend on any other target. It just creates a jar of all class files under $icu4j_root/classes/com/ibm/icu/, excluding the classes files in $icu4j_root/classes/com/ibm/icu/dev folder

The list of module build targets can be obtained by running the command: ant -projecthelp


Comments