[英]XMLBeans creates different code when running via Ant and Maven
Apache POI usually compiles via Ant and has some steps where the xmlbeans-Ant-task is used to transform OfficeOpenXML Schemas into code. Apache POI通常通过Ant进行编译,并具有一些步骤,其中使用xmlbeans-Ant-task将OfficeOpenXML Schema转换为代码。
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. 我目前正在构建一组相应的Maven pom.xml文件,这些文件还可以编译代码,以便更轻松地在Apache POI上运行Sonar检查。
However a few of the generated classes look different when XMLBeans generates the code. 但是,当XMLBeans生成代码时,一些生成的类看起来有所不同。
In the Ant-file the statement is: 在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>
In Maven I use 在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>
Most classes are equal, but one has differently named getters/setters, ie 大多数类是平等的,但其中一个具有不同名称的getters / setters,即
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: 但是Maven会产生不同的getter,请注意不同命名的方法:
/**
* 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...
就我所见,使用的是完全相同的source-XSD,尽管我对XMLBeans知之甚少,所以这里使用的设置可能有所不同。
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 ... ...所以ant任务在与.xsds相同的目录中查找.xsdconfig文件,但是需要明确指示maven ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.