title: How do I generate equals and hashCode with the CXF xjcplugin
body: <p>I am trying to generate a Java class containing the methods toString, equals and hashCode from an XSD file. I got toString working, but I am not able to figure out how to get the CXF plugin to generate the equals and the hashCode methods.</p>
  
  <p>This is my XSD file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/messagedefinitions"
             xmlns="http://www.example.com/messagedefinitions"&gt;
  
  
      &lt;xs:element name="Message"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="status" type="Status"/&gt;
                  &lt;xs:element name="id" type="Identifier"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:simpleType name="Status"&gt;
          &lt;xs:restriction base="xs:string"&gt;
              &lt;xs:maxLength value="4"/&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  
      &lt;xs:simpleType name="Identifier"&gt;
          &lt;xs:restriction base="xs:int"/&gt;
      &lt;/xs:simpleType&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>My working POM (what does not work is commented out) :</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;xsd-demo&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;xsd-demo&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;cxf.version&gt;2.6.1&lt;/cxf.version&gt;
          &lt;cxf.xjc.plugin.version&gt;2.6.1&lt;/cxf.xjc.plugin.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-tools-common&lt;/artifactId&gt;
              &lt;version&gt;${cxf.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf.xjc-utils&lt;/groupId&gt;
              &lt;artifactId&gt;xjc-utils&lt;/artifactId&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;version&gt;${cxf.xjc.plugin.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf.xjc-utils&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-xjc-runtime&lt;/artifactId&gt;
              &lt;version&gt;${cxf.xjc.plugin.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;inherited&gt;true&lt;/inherited&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
                  &lt;artifactId&gt;cxf-xjc-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${cxf.xjc.plugin.version}&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;generate-sources&lt;/id&gt;
                          &lt;phase&gt;generate-sources&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;xsdtojava&lt;/goal&gt;
                          &lt;/goals&gt;
  
                          &lt;configuration&gt;
                              &lt;sourceRoot&gt;${basedir}/target/generated-sources&lt;/sourceRoot&gt;
                              &lt;xsdOptions&gt;
                                  &lt;xsdOption&gt;
                                      &lt;extension&gt;true&lt;/extension&gt;
                                      &lt;xsd&gt;${basedir}/src/main/resources/xsd/Message.xsd&lt;/xsd&gt;
                                      &lt;bindingFile&gt;${basedir}/src/main/resources/bindings.xml&lt;/bindingFile&gt;
                                      &lt;extensionArgs&gt;
                                          &lt;arg&gt;-Xts:style:multiline&lt;/arg&gt;
                                          &lt;!--&lt;arg&gt;-Xequals&lt;/arg&gt;--&gt;
                                          &lt;!--&lt;arg&gt;-XhashCode&lt;/arg&gt;--&gt;
                                      &lt;/extensionArgs&gt;
                                  &lt;/xsdOption&gt;
                              &lt;/xsdOptions&gt;
                              &lt;extensions&gt;
                                  &lt;extension&gt;org.apache.cxf.xjcplugins:cxf-xjc-ts:${cxf.xjc.plugin.version}&lt;/extension&gt;
                                  &lt;!--&lt;extension&gt;org.apache.cxf.xjcplugins:cxf-xjc-XhashCode:${cxf.xjc.plugin.version}--&gt;
                                  &lt;!--&lt;/extension&gt;--&gt;
                                  &lt;!--&lt;extension&gt;org.apache.cxf.xjcplugins:cxf-xjc-Xequals:${cxf.xjc.plugin.version}--&gt;
                                  &lt;!--&lt;/extension&gt;--&gt;
                              &lt;/extensions&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>The bindings file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jaxb:bindings
          xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
          xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
          jaxb:version="2.1"&gt;
      &lt;jaxb:globalBindings&gt;
          &lt;xjc:serializable uid="1234"/&gt;
      &lt;/jaxb:globalBindings&gt;
  &lt;/jaxb:bindings&gt;
  </code></pre>
  
  <p>If I un-comment the commented-out lines for the Xequals I get this error :</p>
  
  <p>[ERROR] Failed to execute goal org.apache.cxf:cxf-xjc-plugin:2.6.1:xsdtojava (generate-sources) on project xsd-demo: Could not download extension artifact: Requested download does not exist. Could not find artifact org.apache.cxf.xjcplugins:cxf-xjc-Xequals:jar:2.6.1 in central (<a href="http://repo1.maven.org/maven2" rel="nofollow">http://repo1.maven.org/maven2</a>)</p>
  
  <p>Fine, I realise that the artifact does not exist, but I do not know then how to configure the CXF plugin to generate the equals and hashCode methods. Do you know how I can configure the CXF plugin to generate the equals and hashCode methods ? Thanks in advance for any help.</p>