xjc extension – @Generated

A lot of projects depend on generated code. We use XmlBeans, JAXB, doclet and various modelling tools on a daily basis. A lot of projects use static code analysis for code quality checking, test coverage reports etc.  Usually we don’t want to calculate metrics of generated code. It distracts developers from real issues and makes comparison between project at least hard.

JAXB generator offers set of extenstions (e.g. fluent api), for internal purposes I created simple extension for adding @Generated annotation to JAXB classes. It can be obtained from top.touk.pl maven2 repository. To use it in a maven project add one more dependency to cxf-codegen-plugin and enable it by adding extraarg with content “-xjc-Xmg”.

    org.apache.cxf
    cxf-codegen-plugin
    2.2.6

            net.java.dev.jaxb2-commons
            jaxb-fluent-api
            2.1.8

            org.apache.cxf
            cxf-xjc-dv
            2.2.6

            pl.touk.cxf.xjcplugins
            xjc-mark-generated
            1.0.0

                        -xjc-Xfluent-api
                        -xjc-Xdv
                        -xjc-Xmg

                        ${basedir}/target/unpacked-wsdls/X.wsdl

                            ${basedir}/src/main/bindings/x-bindings-jaxws.xml
                            ${basedir}/src/main/bindings/bindings.xjb

                wsdl2java

Done.

One thought on “xjc extension – @Generated

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.