jsp 是在哪个 Maven 阶段放在目标上的?

During which maven's phase the jsp are put on the target?

我需要知道 jsp 在 maven 周期的哪个阶段被放到目标目录,以及通过哪个进程。

我使用 grunt-maven-plugin 对我的 .jsp 文件进行转换(如果您想知道,我会生成 js 脚本的插入)。

Grunt 在临时目录中复制 jsp 文件,完成它的工作并将更新后的 jsp 放在 target/${project.build.name} 目录中。 (如果我只启动 grunt,我可以检查它的工作)

我的问题是更新后的文件被移动到同一存储库的原始 jsp 覆盖。

如果我只启动 grunt(我做了一个 mvn compile,谁启动了 grunt 任务),我可以检查我的 grunt 工作是否正常。但是,如果我执行 mvn install,文件将被覆盖。

我想我可以在原来的 jsp 移动后启动 grunt 来纠正它。

问题:您知道在maven 周期 的哪个阶段jsp 被放在目标目录中吗?

顺便说一句,我的项目是来自maven神器webapp的webapp。

I need to know during which phase of the maven cycle the jsp are put on the target directory, and by which process.

package 阶段 Maven War Plugin and its war 目标。

打包 war 后,Maven 构建将默认 调用 war:war(Maven War 插件的 war ) 在 package 阶段,根据 default packaging bindings。因此,无需在 POM 文件中明确指定它。

Maven War 插件将

  • 根据其 webappDirectory 配置条目
  • 的指定,默认在 ${project.build.directory}/${project.build.finalName} 下构建完整的 webapp
  • 默认将其打包为 ${project.build.directory} 下的 .war 文件,如其 outputDirectory 配置条目所指定

My issue is that the updated file is overwritten by the original jsp who is moved on this same repository.

在这种情况下,您遇到了文件冲突,同一目标文件夹中的相同文件(具有不同的内容)(您提到的 target/${project.build.name} 与上面的默认 War 插件输出目录相同).

您可以将修改后的 .jsp 文件重定向到不同的目录下,例如 target/grunt,然后配置 Maven War 插件以从该目录获取资源。这些额外的资源将添加到 默认资源之后,因此会覆盖它们(以防发生冲突)。

例如,您可以在 POM 文件中添加以下内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <webResources>
            <resource>
                <!-- this is relative to the pom.xml directory -->
                <directory>target/grunt</directory>
            </resource>
        </webResources>
    </configuration>
</plugin>

全局配置也将应用于作为上述绑定的一部分执行的默认 Maven War 插件。

在上面的代码片段中,我们告诉 Maven War 插件也包括来自 target/grunt 文件夹的资源。该文件夹中存在的任何 .jsp 文件将被添加到构建的 webapp(作为文件夹和 .war 文件)并覆盖原始 .jsp 文件(如您实际需要)。