【问题标题】:Maven Copy Folder Before War File Generation战前文件生成Maven复制文件夹
【发布时间】:2015-04-19 12:04:22
【问题描述】:

我有两个 Git 存储库。一个存储库是 java 服务(maven web 项目),另一个存储库由 UI {HTML,JS,CSS}(非 maven)组成,在构建 java 服务存储库时,我想将最新的 UI(主)包含到 war 文件中.我试过maven-resources-plugin

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>install</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>/home/srinivas/AAA/bb/</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

mvn 安装

它将资源复制到目标文件夹,但没有将它们放在war文件中

【问题讨论】:

    标签: java maven maven-resources-plugin


    【解决方案1】:

    您在执行中使用了错误的阶段,因为package 阶段实际上是创建战争的阶段,因此您需要在较早的阶段执行,例如prepare-package.

    您绝对应该阅读Introduction to the Build Lifecycle 以进行澄清。

    此外,您不应该习惯于通过 maven-resources-plugin 从文件系统中提取资源。这通常被认为是不好的做法,因为其他开发人员将无法重现您的构建。

    使用存储库管理器来存储您的依赖项是这里的方法。阅读Why do I need a Repository Manager? 以开始使用。

    【讨论】:

    • 但是依赖的 repo 不是 maven 项目
    • 即便如此,您也可以选择将战争工件上传到本地存储库。大多数存储库管理器都允许通过其 GUI 进行此类操作。
    • 是的,您可以将 zip 工件存储在存储库中并解压缩它们。
    • 你能提供一些参考吗
    【解决方案2】:

    乍一看,改变:

    <phase>install</phase>
    

    <phase>prepare-package</phase>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-19
    • 1970-01-01
    • 2018-01-04
    • 2013-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-07
    相关资源
    最近更新 更多