简体   繁体   English

Maven Xmlbeans插件-生成并保留指定架构的文件

[英]Maven Xmlbeans Plugin - Generate & Retain files for specified schemas

I'm trying to develop XML-based software. 我正在尝试开发基于XML的软件。 I'm using Maven & XmlBeans. 我正在使用Maven和XmlBeans。

I have a base-project which provides base-xml-schemas which define some elements, abstract types, etc,. 我有一个base-project ,它提供了base-xml-schemas ,它定义了一些元素,抽象类型等。

All other sub-projects also provides xml-schemas. 所有其他sub-projects也提供xml模式。 But, these sub-projects imports/refers the base-xml-schemas to use & extend the elements / types defined by base-schemas . 但是,这些子项目导入/引用base-xml-schemas以使用和扩展base-schemas定义的元素/类型。

Even though my sub-projects depends on base-project , xmlbeans plugin requires the base-xml-schemas to be present in schemaDirectory for its usage. 即使我的sub-projects 依赖base-project ,xmlbeans插件也需要在schemaDirectory存在base-xml-schemas才能使用。 As an implication, all my sub-projects now carry the duplicate content generated/compiled due to base-xml-schemas . 这意味着,我的所有子项目现在都携带了由于base-xml-schemas而生成/编译的重复内容。

I want my sub-projects to have only those sub-project-specific schemas & content in their jar, as My base-project will be available to all applications in my Jboss & the types can be resolved in runtime. 我希望我的sub-projects jar中仅包含那些特定于子项目的架构和内容,因为我的base-project将对Jboss中的所有应用程序都可用,并且类型可以在运行时解析。

Having understood that the xmlbean needs all the schemas referred to be present for code generation, now I want to delete all xmlbean-generated code due to the present of base-xml-schema and retain files related to sub-project specific schemas. 了解了xmlbean需要引用的所有模式以进行代码生成之后,由于存在base-xml-schema ,现在我想删除所有xmlbean生成的代码,并保留与sub-project特定模式相关的文件。

I have manually done this and my project compilation & runtime works fine, as my maven has dependency & classes are available in runtime. 我已经手动完成此操作,并且我的项目编译和运行时工作正常,因为我的maven具有依赖项,并且类在运行时可用。

My question is - How to automate this using maven so the files generated due to base-schema is deleted just after generation. 我的问题是-如何使用Maven自动执行此操作,以便在生成后立即删除由于base-schema生成的文件。

Maven xmlbeans plugin binds by default to the lifecycle phase: generate-sources. Maven xmlbeans插件默认绑定到生命周期阶段:generate-sources。

You will need to bind clean goal of the clean plugin to the above lifecycle phase. 您将需要将清洁插件的清洁目标绑定到上述生命周期阶段。

Refer to the link - Remove or delete resource files from target directory using pom file 请参阅链接- 使用pom文件从目标目录中删除或删除资源文件

Configuration will be like this: 配置将如下所示:

      <execution>
        <id>clean-autogenerated-code</id>
        <phase>generate-sources</phase>
        <goals>
          <goal>clean</goal>
        </goals>
        <configuration>
         <filesets>
            <fileset>
              <directory>some/relative/path/location/of/autogeneratd/code</directory>
            </fileset>
          </filesets>
        </configuration>
    </execution>

directory location - provide exact directory location of the auto-generated classes. 目录位置-提供自动生成的类的确切目录位置。

This you will need to configure in your all sub-projects from where you need to delete your auto-generated xml beans files. 您将需要在所有子项目中进行配置,从中删除自动生成的xml bean文件。 If you have any parent-pom all of your sub-projects, configure in that pom.xml file. 如果您的所有子项目都具有父pom,请在该pom.xml文件中进行配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用hibernate4-maven-plugin生成多个方言模式? - How to use hibernate4-maven-plugin to generate multiple dialects schemas? hibernate4-maven-plugin生成PostgreSQL模式的正确配置是什么? - What is the right configuration for hibernate4-maven-plugin to generate PostgreSQL schemas? XSD未被XMLBeans Maven插件选取 - XSD Not Picked Up by XMLBeans Maven Plugin 如何解决Maven xmlbeans插件依赖性问题 - How to solve the maven xmlbeans plugin dependency issue xmlbeans-maven-plugin 不为列表生成 getter - xmlbeans-maven-plugin not generating getters for Lists Maven2:使用xmlbeans插件时,不会从.xsd文件生成列表返回类型方法 - Maven2:List return type methods not getting generated from .xsd files while using xmlbeans plugin 在Maven-jaxb2-plugin的&#39;src&#39;中生成文件 - Generate files in 'src' for maven-jaxb2-plugin 使用 xmlbeans、inst2xsd 和 Maven 从 XML 生成 XSD - Generate XSD from XML using xmlbeans, inst2xsd and Maven Maven编译器插件,构建帮助器插件不会生成类文件 - Maven compiler plugin, build helper plugin does not generate class files 生成校验和并使用maven存储MD5文件是指定的文件夹 - generate checksum and store the MD5 files is specified folder using maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM