Skip to content

Commit

Permalink
ICU-22324 Mavenization, minimize the places that need a version
Browse files Browse the repository at this point in the history
  • Loading branch information
mihnita committed Sep 22, 2023
1 parent 6e0468d commit 8c4af50
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 17 deletions.
51 changes: 43 additions & 8 deletions icu4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,24 @@
<proj-title>International Components for Unicode for Java</proj-title>
<proj.displayname>${project.artifactId}</proj.displayname>

<!-- Version update! -->
<icu.major.version>74</icu.major.version>

<!-- Variables used to generate the javadoc -->
<api.doc.version>74 Release Candidate</api.doc.version>
<!-- Version update! -->
<api.doc.version>${icu.major.version} Release Candidate</api.doc.version>
<icu4j.api.doc.window.title>ICU4J ${api.doc.version}</icu4j.api.doc.window.title>
<icu4j.api.doc.header>ICU4J ${api.doc.version}</icu4j.api.doc.header>
<icu4j.api.doc.copyright.footer>&lt;font size=-1&gt;Copyright © 2016 Unicode, Inc. and others.&lt;/font&gt;</icu4j.api.doc.copyright.footer>

<!-- Needs to be overriden in sub-modules -->
<icu4j.api.doc.root.dir>${project.basedir}</icu4j.api.doc.root.dir>
<icu4j.api.report.version>74</icu4j.api.report.version>
<icu4j.api.report.version>${icu.major.version}</icu4j.api.report.version>

<!-- Used for the .jar Manifest files -->

<mf.Specification-Version>74</mf.Specification-Version>
<mf.Implementation-Version>74.0.1</mf.Implementation-Version>
<mf.Bundle-Version>74.0.1</mf.Bundle-Version>

<mf.Specification-Version>${icu.major.version}</mf.Specification-Version>
<mf.Implementation-Version>${project.version}</mf.Implementation-Version>
<mf.Bundle-Version>${project.version}</mf.Bundle-Version>
<mf.Bundle-RequiredExecutionEnvironment>JavaSE-1.8</mf.Bundle-RequiredExecutionEnvironment>

<!-- For most modules artifactId does not have an "icu4j" prefix, so this is a good default -->
Expand Down Expand Up @@ -187,6 +190,13 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<!-- Plugin bug, maven.compiler.* properties are not honored, see
https://issues.apache.org/jira/browse/MCOMPILER-545
-->
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -506,7 +516,7 @@
<!-- The tools/build module depends on the old tools.jar (jdk 1.8)
The com.sun.javadoc package was deprecated in Java 11, and has been removed for Java 17.
JDK 11 does not include tools.jar anymore. The code must be updated, see migration guide at
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.javadoc/jdk/javadoc/doclet/package-summary.html#migration
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.javadoc/jdk/javadoc/doclet/package-summary.html#migration
-->
<profile>
<id>old_jdk_taglet</id>
Expand All @@ -517,6 +527,31 @@
<module>tools/build</module>
</modules>
</profile>

<!-- Starting with JDK 9, the Java compiler supports the −−release version.
Unlike source (checking the language features) and target (the version of the classes generated),
this option also checks that newer APIs are not used.
https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html
Would be nice if the maven-compiler-plugin would filter this out below JDK 9, but it does not.
So we must use an auto-activated profile for this option.
-->
<profile>
<id>newer_jdk</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>

</project>
68 changes: 59 additions & 9 deletions icu4j/releases_tools/api_reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@

export MAVEN_ARGS='--no-transfer-progress'

# Version update!
export artifact_version='74.0.1-SNAPSHOT'
export api_report_version='74'
export api_report_prev_version='73'
export out_dir=target


function checkThatJdk8IsDefault() {
javac -version appPath 2>&1 | grep -E 'javac 1\.8\.' > /dev/null
if [ $? -eq 0 ]; then
echo "The default JDK is JDK 8, all good!"
javac -version
else
echo "This step can only be executed with JDK 8!"
echo "Make sure that you have the PATH pointing to a JDK 8!"
javac -version
exit
fi

}

# Copy the icu artifacts from the local maven repo to the lib folder,
# so that we can use it as classpath.
function copyArtifacts() {
rm -fr ${out_dir}/lib/
mkdir -p ${out_dir}/lib/
Expand All @@ -23,37 +41,64 @@ function copyArtifacts() {
mvn dependency:copy -q -Dartifact=com.ibm.icu:translit:${artifact_version} -DoutputDirectory=${out_dir}/lib/
}

function checkFileCreated() {
local OUT_FILE=$1
if [ -f "$OUT_FILE" ]; then
echo " Output file $OUT_FILE generated"
else
echo " Error generating output file $OUT_FILE"
exit
fi
}

function reportTitle() {
echo ""
echo "=============================================="
echo $*
echo "=============================================="
echo ""
}

# ====================================================================================
# The start of the script proper

reportTitle "Checking the JDK version (must be 8)"
checkThatJdk8IsDefault

# ====================================================================================

reportTitle gatherapi :: Collect API information

mvn clean -q --batch-mode
# Build everything
mvn install -DskipITs -DskipTests
mvn install -q --batch-mode -DskipITs -DskipTests
# Gather API info
mvn site -q -DskipITs -DskipTests -P gatherapi
mvn site -q --batch-mode -DskipITs -DskipTests -P gatherapi > /dev/null

copyArtifacts
checkFileCreated "${out_dir}/icu4j${api_report_version}.api3.gz"

export toolcp=${out_dir}/lib/collate-74.0.1-SNAPSHOT.jar:${out_dir}/lib/core-74.0.1-SNAPSHOT.jar:${out_dir}/lib/currdata-74.0.1-SNAPSHOT.jar:${out_dir}/lib/icu4j-charset-74.0.1-SNAPSHOT.jar:${out_dir}/lib/langdata-74.0.1-SNAPSHOT.jar:${out_dir}/lib/regiondata-74.0.1-SNAPSHOT.jar:${out_dir}/lib/tools_build-74.0.1-SNAPSHOT.jar:${out_dir}/lib/translit-74.0.1-SNAPSHOT.jar
# Prepare classpath folder to run the tools
copyArtifacts
export toolcp="${out_dir}/lib/*"

# ====================================================================================

reportTitle apireport :: Run API report generator tool

java -cp $toolcp \
java -cp "$toolcp" \
com.ibm.icu.dev.tool.docs.ReportAPI \
-old: tools/build/icu4j${api_report_prev_version}.api3.gz \
-new: ${out_dir}/icu4j${api_report_version}.api3.gz \
-html \
-out: ${out_dir}/icu4j_compare_${api_report_prev_version}_${api_report_version}.html

checkFileCreated "${out_dir}/icu4j_compare_${api_report_prev_version}_${api_report_version}.html"

# ====================================================================================

reportTitle checkDeprecated :: Check consistency between javadoc @deprecated and @Deprecated annotation

java -cp $toolcp \
java -cp "$toolcp" \
com.ibm.icu.dev.tool.docs.DeprecatedAPIChecker \
${out_dir}/icu4j${api_report_version}.api3.gz

Expand All @@ -64,7 +109,7 @@ reportTitle checkAPIStatusConsistency :: Check consistency between API class sta
# If you need classes excluded from this check, define following property in build-local.properties.
# e.g. checkAPIStatusConsistency.skip.classes=com.ibm.icu.text.Normalizer;com.ibm.icu.util.ULocale

java -cp $toolcp \
java -cp "$toolcp" \
com.ibm.icu.dev.tool.docs.APIStatusConsistencyChecker \
${out_dir}/icu4j${api_report_version}.api3.gz \
checkAPIStatusConsistency.skip.classes=
Expand All @@ -73,18 +118,23 @@ java -cp $toolcp \

reportTitle draftAPIs :: Run API collector tool and generate draft API report in html

java -cp $toolcp \
java -cp "$toolcp" \
com.ibm.icu.dev.tool.docs.CollectAPI \
-f Draft \
-o ${out_dir}/draftAPIs.html \
${out_dir}/icu4j${api_report_version}.api3.gz

checkFileCreated "${out_dir}/draftAPIs.html"

# ====================================================================================

reportTitle draftAPIsTSV :: Run API collector tool and generate draft API report in TSV

java -cp $toolcp \
java -cp "$toolcp" \
com.ibm.icu.dev.tool.docs.CollectAPI \
-f Draft \
-o ${out_dir}/draftAPIs.tsv \
-t ${out_dir}/icu4j${api_report_version}.api3.gz

checkFileCreated "${out_dir}/draftAPIs.tsv"

0 comments on commit 8c4af50

Please sign in to comment.