1

Apache POI usually compiles via Ant and has some steps where the xmlbeans-Ant-task is used to transform OfficeOpenXML Schemas into code.

I am currently in the process of building a corresponding set of Maven pom.xml files which also compile the code in order to more easily run Sonar checks on Apache POI.

However a few of the generated classes look different when XMLBeans generates the code.

In the Ant-file the statement is:

<xmlbean
        schema="${ooxml.encryption.xsd.dir}"
        srcgendir="${ooxml.encryption.src.dir}"
        optimize="yes"
        destfile="${ooxml.encryption.jar}"
        javasource="1.5"
        failonerror="true"
        fork="true"
        memoryMaximumSize="${ooxml.memory}"
        >
    <classpath refid="ooxml.classpath"/>
</xmlbean>

In Maven I use

<plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>xmlbeans-maven-plugin</artifactId>
          <version>2.3.3</version>
          <executions>
             <execution>
                <phase>generate-sources</phase>
                <goals>
                  <goal>xmlbeans</goal>
                </goals>
             </execution>
          </executions>
            <configuration>
                <schemaDirectory>target/schemas</schemaDirectory>
                <javaSource>1.5</javaSource>
                <optimize>yes</optimize>
            </configuration>
        </plugin>

Most classes are equal, but one has differently named getters/setters, i.e.

Ant produces

/**
 * Gets the "encryptedKey" element
 */
com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor 
    getEncryptedPasswordKey();

But Maven produces a different getter, note the differently named method:

/**
 * Gets the "encryptedKey" element
 */
com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor 
    getEncryptedKey();

Is there any way I can fix this? As far as I see the exact same source-XSD is used, although I know very little about XMLBeans so it could be some different setting in use here...

centic
  • 15,565
  • 9
  • 68
  • 125
  • An obvious question. Are you using the same version of XMLbeans? Check the ANT build. – Mark O'Connor Feb 15 '14 at 13:17
  • Yes, it is 2.3.0 on both sides, and I verified with 2.6.0 as well, no luck there either... – centic Feb 15 '14 at 21:17
  • Sorry Dominik, I've just seen this question linked from our sonar sources. the method naming is configured by the .xsdconfig files (encryptionCertificate.xsdconfig and encryptionPassword.xsdconfig). I haven't checked it yet, but it seems that ant has a different lookup dir than maven. – kiwiwings Aug 17 '15 at 23:15
  • Thanks a lot, that sounds like it may be related here, in the meantime I built some quite ugly workaround, I will see if we can get rid of this, XMLBeans is still a mystery to me sometimes... – centic Aug 18 '15 at 12:55

1 Answers1

1

Just for the sake of completness ... this could be fixed by adding the below to the configuration part:

<xmlConfigs>
    <xmlConfig implementation="java.io.File">../../src/ooxml/resources/org/apache/poi/poifs/crypt</xmlConfig>
</xmlConfigs>

... so the ant task looks for the .xsdconfig files in the same dir as the .xsds, but maven needs to be instructed explicitly ...

kiwiwings
  • 3,386
  • 1
  • 21
  • 57