A plugin for CXF codegen plugin that adds #hashCode
and #equals
implementations with zero runtime dependencies for the generated classes.
If you are looking for a library that generates #toString
, we recommend you to take a look at Apache CXF XJC Utils. It does have a dependency, but it's Apache Commons Lang3, which is commonly used anyway.
Example profile in pom.xml
:
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>...</wsdl>
<extraargs>
<extraarg>-xjc-Xhashcode-equals</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.viskan</groupId>
<artifactId>cxf-xjc-hce</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
And generate as usual:
$ mvn generate-sources -Pgenerate
Majors and minors:
$ mvn versions:set versions:set-scm-tag -DnewVersion=1.0.0 -DnewTag=v1.0.0 -DgenerateBackupPoms=false
$ git add pom.xml && commit -m "release: 1.0.0"
$ git tag v1.0.0
$ mvn deploy -Psonatype-oss-release
$ mvn versions:set versions:set-scm-tag -DnewVersion=1.1.0-SNAPSHOT -DnewTag=HEAD -DgenerateBackupPoms=false
$ git add pom.xml && commit -m "chore: Prepare for the next development iteration"
$ git push origin master && git push origin v1.0.0
Patches:
$ git checkout v1.0.0
$ git cherry-pick <Commit SHA of whatever commit you want to patch in>
$ mvn versions:set versions:set-scm-tag -DnewVersion=1.0.1 -DnewTag=v1.0.1 -DgenerateBackupPoms=false
$ git add pom.xml && commit -m "release: 1.0.1"
$ git tag v1.0.1
$ mvn deploy -Psonatype-oss-release
$ git push origin v1.0.1
Apache License 2.0 © Viskan System AB