1

Apache POI は通常、Ant を介してコンパイルされ、xmlbeans-Ant-task を使用して OfficeOpenXML スキーマをコードに変換するいくつかのステップがあります。

現在、Apache POI で Sonar チェックをより簡単に実行するためにコードをコンパイルする、対応する一連の Maven pom.xml ファイルを作成中です。

ただし、生成されたクラスのいくつかは、XMLBeans がコードを生成するときに異なるように見えます。

Ant ファイルのステートメントは次のとおりです。

<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>

Mavenで私が使用する

<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>

ほとんどのクラスは同じですが、getter/setter の名前が異なるものがあります。

アリが生産する

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

ただし、Maven は別のゲッターを生成します。別の名前のメソッドに注意してください。

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

これを修正する方法はありますか?XMLBeansについてはほとんど知らないので、ここで使用されている設定が異なる可能性がありますが、まったく同じsource-XSDが使用されていることがわかります...

4

1 に答える 1