summaryrefslogtreecommitdiff
path: root/icu4j/main/localespi/pom.xml
blob: 198fca35909c24542d00a2a24a84003ee76aeaf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?xml version="1.0" encoding="UTF-8"?>
<!--
* © 2023 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.ibm.icu</groupId>
    <artifactId>icu4j-root</artifactId>
    <version>75.1</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <artifactId>icu4j-localespi</artifactId>
  <description>icu4j-localespi is a supplemental library for icu4j, implementing Java Locale SPI.</description>

  <properties>
    <proj.displayname>JDK locale service provider</proj.displayname>
    <icu4j.api.doc.root.dir>${project.basedir}/../..</icu4j.api.doc.root.dir>
    <mf.Automatic-Module-Name>com.ibm.icu.localespi</mf.Automatic-Module-Name>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>icu4j</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- Test -->
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>core</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>framework</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>currdata</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>langdata</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>regiondata</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!--
            Do not run localespi tests as unit tests because they depend on loading the main code via a .jar file
            via the Java extensions mechanism.
          -->
          <skipTests>true</skipTests>
        </configuration>
      </plugin>

      <!--
        Mainly for running localespi tests in Java 8:
        The easiest way to get the integration tests to pass (in particular, to get the JVM that is
        spawned with the `-Djava.ext.dirs` system property value to be interpreted properly in order
        for the extensions jars therein to be loaded correctly) was to copy the jars needed to a
        separate directory. (The alternative of pointing to the build directories of the respective
        submodules didn't seem to work.)

        This isn't of much use for Java 9+, in which extensions are deprecated and the regular
        classpath is to be used instead.
      -->
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>it-test-copy-localespi-extension-jars</id>
            <phase>integration-test</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>icu4j</artifactId>
                  <version>${project.version}</version>
                  <type>${project.packaging}</type>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>icu4j-localespi</artifactId>
                  <version>${project.version}</version>
                  <type>${project.packaging}</type>
                </artifactItem>
              </artifactItems>
              <!-- https://stackoverflow.com/questions/36181371/how-can-i-get-the-temp-folder-of-a-machine-running-maven -->
              <outputDirectory>${java.io.tmpdir}/ext-test-jars</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includes>
            <!-- treat localespi tests as integration tests because they depend on .jar files from package phase -->
            <include>**/*.java</include>
            <!-- default integration test wildcard patterns -->
            <include>**/IT*.java</include>
            <include>**/*IT.java</include>
            <include>**/*ITCase.java</include>
          </includes>

          <!--
            For Java 8:
            Set up the locale service provider using the .jar file of `icu4j-localespi` main code from the `package` phase

            Leave empty for Java 9+.
            Using the `java.ext.dirs` special Java system property on Java 9+ runtimes triggers an
             error that tells the user to place those jars on the classpath instead.
          -->
          <!--
              Notes:

              https://stackoverflow.com/a/5039973/2077918
              The `java.ext.dirs` is a special Java system property that activates the Java extension mechanism.
              The Java extension mechanism was deprecated in Java 8 (users are recommended to use `-classpath` instead),
              and the extension mechanism was removed in Java 9 altogether.
              For backwards compatibility testing for users of the Java extension mechansim,
              this configuration achieves the effect of having the localespi code in a .jar file that gets loaded
              by running this test in a phase following the `package` phase in which the .jar file is created.

              https://stackoverflow.com/questions/45223908/why-does-the-java-extension-mechanism-not-check-the-classpath-for-an-optional-pa

              For some reason, the plugin was effectively not honoring the values as expected that were set in
              <systemPropertyVariables>, so instead, the <argLine> value was used to set the JVM options. This
              approach was inspired by: https://stackoverflow.com/a/48213614/2077918
          -->
          <argLine>${localespi-tests.jvm.args}</argLine>

          <!--
              For Java 9+:
              Configure to use the locale service provider using the .jar file of `icu4j-localespi` main code from the `package` phase

              Leave empty for Java 8 to take defaults ("SPI,JRE").
              See: https://stackoverflow.com/questions/45223908/why-does-the-java-extension-mechanism-not-check-the-classpath-for-an-optional-pa
            -->
          <systemPropertyVariables>
            <java.locale.providers>${localespi-tests.locale-providers}</java.locale.providers>
          </systemPropertyVariables>

        </configuration>
      </plugin>

    </plugins>
  </build>

  <profiles>
    <!--
      For testing localespi using the Java extensions feature, which last existed in Java 8.
      ICU4J currently has a minimum supported version of 8.
    -->
    <profile>
      <id>localespi-tests-java8</id>
      <activation>
        <jdk>(,8]</jdk>
      </activation>
      <properties>
        <localespi-tests.jvm.args>-Djava.ext.dirs="${java.io.tmpdir}/ext-test-jars"</localespi-tests.jvm.args>
        <localespi-tests.locale-providers></localespi-tests.locale-providers>
      </properties>
    </profile>
    <!--
      For testing localespi using the classpath for Java 9+, since Java extensions were
      deprecated after Java 8.
    -->
    <profile>
      <id>localespi-tests-java9</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <properties>
        <localespi-tests.jvm.args></localespi-tests.jvm.args>
        <localespi-tests.locale-providers>CLDR,COMPAT,SPI</localespi-tests.locale-providers>
      </properties>
    </profile>
    <profile>
      <id>with_javadoc</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <!-- All files in com/ibm/icu/impl folders are exluded from javadoc.
                    So we need to bring back this one file, to match the previously published artifacts.
                    Without this all java files are excluded and no javadoc is generated.
                  -->
                  <sourceFileIncludes>
                    <include>ICULocaleServiceProvider.java</include>
                  </sourceFileIncludes>
                  <sourcepath>${basedir}/src/main/java/com/ibm/icu/impl/javaspi</sourcepath>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>