Eclipse Transformer による jakarta ネームスペースへの変換手順


Eclipse Transformer とは

javaxjakarta へのネームスペース変更を行うツールで、以下のファイルの変換を行うことができる。

  • Java class files
  • OSGi feature manifest files
  • Properties files
  • Service loader configuration files
  • Text files (of several types: java source, XML, TLD, HTML, and JSP)

jarwarear などのアーカイブを変換したり、プロジェクトディレクトリを指定してソースを変換することができる。

https://github.com/eclipse/transformer


Eclipse Transformer の準備

org.eclipse.transformer.cli-1.0.0-distribution.jar をダウンロードして アーカイブをExtract

jar -xf ./org.eclipse.transformer.cli-1.0.0-distribution.jar

以下の構成として抽出される

├ libs
│  ├ biz.aQute.bnd.transform-7.0.0.jar
│  ├ commons-cli-1.9.0.jar
│  ├ org.eclipse.transformer.jakarta-1.0.0.jar
│  ├ org.eclipse.transformer-1.0.0.jar
│  ├ slf4j-api-1.7.36.jar
│  └ slf4j-simple-1.7.36.jar
├ META-INF
│  └ MANIFEST.MF
└ org.eclipse.transformer.cli-1.0.0.jar

org.eclipse.transformer.cli-1.0.0.jar を実行すれば良い。

ヘルプは以下の通り。

$ java -jar .\org.eclipse.transformer.cli-1.0.0.jar --help
Copyright (c) Contributors to the Eclipse Foundation
org.eclipse.transformer.cli.JakartaTransformerCLI Version [ 1.0.0 ]


usage: org.eclipse.transformer.cli.JakartaTransformerCLI input [ output ] [ options ]
Options:
 -d,--dryrun                      Dry run
 -h,--help                        Display help
 -i,--invert                      Invert transformation rules
 -ldt,--logShowDateTime           Show date and time in log statements.
                                  Shortcut for -lp bellow with showDateTime and
                                  dateTimeFormat.
 -lf,--logFile <arg>              Logging file
 -ll,--logLevel <arg>             Logging level
 -ln,--logName <arg>              Logger name
 -lp,--logProperty <arg>          Logging property
 -lpf,--logPropertyFile <arg>     Logging properties file
 -o,--overwrite                   Overwrite
 -q,--quiet                       Display quiet output: error level logging
 -s,--stripSignatures             Strips signatures from signed jar files
 -t,--type <arg>                  Input file type
 -tb,--bundles <arg>              Transformation bundle updates URL
 -td,--direct <arg>               Transformation direct string replacements
 -tf,--text <arg>                 Map of filenames to property files
 -ti,--immediate <arg>            Immediate rule data
 -tp,--per-class-constant <arg>   Transformation per class constant string
                                  replacements
 -tr,--renames <arg>              Transformation package renames URL
 -ts,--selection <arg>            Transformation selections URL
 -tv,--versions <arg>             Transformation package versions URL
 -u,--usage                       Display usage
 -v,--verbose                     Display verbose output: debug level logging
 -w,--widen                       Widen archive nesting
 -x,--trace                       Display trace output: trace level logging

Actions:
  [ RENAME ]
  [ CLASS ]
  [ MANIFEST ]
  [ FEATURE ]
  [ SERVICE_LOADER_CONFIG ]
  [ PROPERTIES ]
  [ TEXT ]
  [ JAVA ]
  [ JSP ]
  [ XML ]
  [ ZIP ]
  [ JAR ]
  [ WAR ]
  [ RAR ]
  [ EAR ]
  [ DIRECTORY ]

Logging Properties:
  [ org.slf4j.simpleLogger.logFile ]
  [ org.slf4j.simpleLogger.cacheOutputStream ]
  [ org.slf4j.simpleLogger.defaultLogLevel ]
  [ org.slf4j.simpleLogger.log. ]
  [ org.slf4j.simpleLogger.levelInBrackets ]
  [ org.slf4j.simpleLogger.showDateTime ]
  [ org.slf4j.simpleLogger.dateTimeFormat ]
  [ org.slf4j.simpleLogger.showThreadName ]
  [ org.slf4j.simpleLogger.showLogName ]
  [ org.slf4j.simpleLogger.showShortLogName ]
  [ org.slf4j.simpleLogger.warnLevelString ]
[main] INFO Transformer - TransformerCLI Return Code [ 0 ] [ Success ]


Eclipse Transformer による変換

example.war を変換

java -jar .\org.eclipse.transformer.cli-1.0.0.jar example.war

[main] INFO Transformer - ...
[main] INFO Transformer - Stop processing [ ./example.war ] using [ WAR Action ] took [ 23146ms ]: Name and content changes
[main] INFO Transformer - Input  [ ./example.war ] as [ ...\example.war ]
[main] INFO Transformer - Output [ .../output_example.war ] as [ ...\output_example.war ] took [ 00:00:23 ]
[main] INFO Transformer - [  All Resources ] [  28907 ] Unaccepted [      0 ]   Accepted [  28907 ]
[main] INFO Transformer - [  All Unchanged ] [  28139 ]     Failed [      0 ] Duplicated [      8 ]
[main] INFO Transformer - [    All Changed ] [    768 ]    Renamed [      1 ]    Content [    768 ]
[main] WARN Transformer - Duplicates were processed [ 8 ]
[main] INFO Transformer - Transformer Return Code [ 0 ] [ Success ]

変換後のファイルとして output_example.war が生成される。


プロジェクトのディレクトリも同様に変換可能。

java -jar .\org.eclipse.transformer.cli-1.0.0.jar example

この場合はビルドの成果物など全てが変換対象になってしまうため、./gradlew cleanmvnw clean などを行ってから変換すると良い。