maven 从不带命名空间的XSD生成类

e37o9pze  于 12个月前  发布在  Maven
关注(0)|答案(1)|浏览(88)

我目前正在将一个大型构建从Maven转换到Gradle。我们有一个代码生成步骤,它使用JAXB从一组XSD生成类。在Maven构建中,生成的类没有命名空间,这是正确的,因为相同的类将在两个不同的命名空间中使用。在Gradle构建中,生成的类在其XMLRootElement注解中添加了一个命名空间,如何更改Gradle构建步骤,使生成的类没有命名空间?
Maven的设置看起来像这样:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.14.0</version>
    <configuration>
        <schemaDirectory>${project.build.directory}/classes/xmlbuild</schemaDirectory>
        <bindingDirectory>${project.build.directory}/classes/xmlbuild</bindingDirectory>
        <strict>false</strict>
        <schemaIncludes>
            <include>**/*.xsd</include>
        </schemaIncludes>
        <bindingIncludes>
            <include>**/*.xjb</include>
        </bindingIncludes>
        <args>
            <arg>-Xannotate</arg>
            <arg>-Xvalue-constructor</arg>
            <arg>-XtoString</arg>
            <arg>-Xequals</arg>
            <arg>-XhashCode</arg>
            <arg>-Xcopyable</arg>
            <arg>-Xmergeable</arg>
            <arg>-Xdefault-value</arg>
            <arg>-Xfluent-api</arg>
        </args>
        <extension>true</extension>
    </configuration>

字符串
在Gradle中,我使用的是com.intershop.gradle.jaxb插件。对我来说,配置看起来是一样的:

jaxb {
  javaGen {
    apiModelClasses {
        schemas = fileTree("$buildDir/path/to/xsds") {
            include '*.xsd'
        }
        bindings = fileTree("$buildDir/path/to/xsds") {
            include '*.xjb'
        }
        extension = true
        antTaskClassName = 'org.jvnet.jaxb2_commons.xjc.XJC2Task'
        args = [
                '-npa',                     
                '-Xannotate',
                '-Xvalue-constructor',
                '-XtoString',
                '-Xequals',
                '-XhashCode',
                '-Xcopyable',
                '-Xmergeable',
                '-Xdefault-value',
                '-Xfluent-api',
                '-verbose'
        ]
    }
  }
}

gwbalxhn

gwbalxhn1#

您是否尝试添加此选项:
“--”

args = [
                '-npa',                     
                '-Xannotate',
                '-Xvalue-constructor',
                '-XtoString',
                '-Xequals',
                '-XhashCode',
                '-Xcopyable',
                '-Xmergeable',
                '-Xdefault-value',
                '-Xfluent-api',
                '-verbose'
        ]

字符串
成为

args = [
            '-npa',
            '-nv',             
            '-Xannotate',
            '-Xvalue-constructor',
            '-XtoString',
            '-Xequals',
            '-XhashCode',
            '-Xcopyable',
            '-Xmergeable',
            '-Xdefault-value',
            '-Xfluent-api',
            '-verbose'
        ]

相关问题