/wsdl2kotlin

Creates wrapper klasses in Kotlin for CXF java classes generated from WSDL specifications

Primary LanguageRustApache License 2.0Apache-2.0

wsdl2kotlin

Creates wrapper klasses in Kotlin for CXF java classes generated from WSDL specifications.

Features

  • Data classes for all DTO's
    • Even for inheritance
  • Enforces nullability in spec, with Kotlin nullability
  • Eliminates JAXBElement bonanza

How it works

It uses Tree-Sitter to parse Java-classes generated by Apache CXF wsdl2java, then converts it, and creates Kotlin-classes.

It does some enhancements in the conversion:

  • Reads required=true annotations on fields, and sets the nullability of the fields in the Kotlin version accordingly
  • Eliminates XMLElement bonanza
  • Converts inheritance to interfaces and data classes, so that every DTO have the data class abilities (automatic .equals, .copy-methods etc.)

Use

This in written in Rust, and can be cross-compiled to binaries that can be included in a gradle/maven plugin. This can be set up to be run after Apache CXF wsdl2java.

./wsdl2kotlin /path/to/folder/with/generated/java/classes

A more automatic setup would be to use the cxf-codegen-plugin, and have a similar gradle/maven plugin for this repo run after that.

TODO: add gradle/maven plugin

Develop

Build language parser

# clone https://github.com/tree-sitter/tree-sitter-java to the root of this repo
cd tree-sitter-java
npm install
npm run build-test

Build

cargo build

Run tests

cargo test

Cross-compile

This setup requires some installs, but does not require running in a docker-container, and is as a result dramatically faster.

Install prerequisites

  1. rustup
brew uninstall rust # conflicts with rustup
brew install rustup-init
rustup-init
  1. Install linux target
rustup target add x86_64-unknown-linux-musl
rustup target add x86_64-apple-darwin
  1. Install MUSL based GCC
brew install messense/macos-cross-toolchains/x86_64-unknown-linux-musl