创建文件夹到Maven包中

时间:2019-05-28 14:50:01

标签: maven package maven-package

我想将包含在“”中的所有文件夹包含在将在软件包中创建的文件夹中,该文件夹将被称为“公共”。

更明确地说,我希望树结构采用以下形式:

mypackage.jar
    | common
        | library
        | public
        | layout
        | application
        | rss
        | config
        | package.properties
        | .htaccess

目前,该交付件具有以下形式:

mypackage.jar
    | library
    | public
    | layout
    | application
    | rss
    | config
    | package.properties
    | .htaccess

我不知道如何执行此操作,这似乎很简单。抱歉,这是我第一次完成Maven脚本。

非常感谢您的时间:)

这是我的代码:

    <build>
        <directory>target</directory>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <outputDirectory>${project.build.directory}/pdc</outputDirectory>
        <resources>
            <resource>
            <directory>${project.basedir}</directory>
                <includes>
                    <include>library/</include>
                    <include>public/</include>
                    <include>layout/</include>
                    <include>application/</include>
                    <include>rss/</include>
                    <include>config/include.php</include>
                    <include>config/constant.php</include>
                    <include>.htaccess</include>
                    <include>package.properties</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <outputDirectory>target</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

1 个答案:

答案 0 :(得分:1)

如下添加targetPath

<project>
   <build>
       ...
      <resources>
         <resource>
             <targetPath>common</targetPath>
               ...
          </resource>
      </resources>

      <testResources>
           ...
      </testResources>
      ...
  </build>
</project>