提取“模型"中所有类.打包到一个单独的Maven模块 [英] Extract all classes under in "model" packages to a separate Maven module

查看:240
本文介绍了提取“模型"中所有类.打包到一个单独的Maven模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有src目录的maven模块,如下所示:

I have a maven module with a src directory that looks like this:

src/
  main/
   foo/
     model/
       ModelA.java
   bar/
     model/
       ModelB.java

将模型"包中的所有类提取到单独的Maven模块中的最简单方法是什么? (即,我想将ModelA和ModelB移到单独的模块中)

What is the easiest way to extract all classes under in "model" packages into a separate Maven module? (i.e. I want to move ModelA and ModelB into a separate module)

推荐答案

您可以在pom.xml中定义一个复制资源插件:

You can define a copy-resources plugin in your pom.xml:

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
    <execution>
        <id>copy-models</id>
        <phase>validate</phase>
        <goals>
            <goal>copy-resources</goal>
        </goals>
        <configuration>
            <outputDirectory>{code_base}/new-module/src/main/foo/model> <!-- location where models need to be copied -->
            <overWrite>true</overWrite>
            <resources>
                <resource>
                    <directory>src/main/*/model/*.java</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </configuration>
    </execution>
</executions>
</plugin>

这篇关于提取“模型"中所有类.打包到一个单独的Maven模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆