[英]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.