简体   繁体   English

保存文件时,如何使eclipse m2e构建当前项目以及引用该文件的EAR项目?

[英]On saving a file, how to make eclipse m2e build the current project AND the EAR project that references it?

Apparently, I can easily configure m2e in Eclipse so that when I save a file, Eclipse will "build" the project with Maven. 显然,我可以轻松地在Eclipse中配置m2e,以便在保存文件时,Eclipse将使用Maven“构建”项目。 I'm not sure what goal it's going to specify. 我不确定会指定什么目标。

What I'd really like to know is how to make it not only build the artifact for that single project, but to also run the Maven build for a DIFFERENT project. 我真正想知道的是如何使它不仅为单个项目构建工件,而且还为不同项目运行Maven构建。 For instance, if I have a "app-war" project which my source file is in, and I also have a "app-ear" project that has "app-war" as a dependency, I'd like to see if it's possible on saving a file to first build the WAR, then the EAR, and finally use the appserver-specific protocol to deploy or redeploy the app on a local appserver. 例如,如果我有一个源文件位于其中的“ app-war”项目,并且我还有一个“ app-ear”项目具有“ app-war”作为依赖项,我想看看它是否保存文件以首先构建WAR,然后构建EAR,最后使用特定于应用服务器的协议在本地应用服务器上部署或重新部署该应用程序是可能的。

You can hook plugin's execution with m2e's lifecycle 您可以将插件的执行与m2e的生命周期挂钩

<pluginManagement>
<plugins>
<plugin>
 <groupId>org.eclipse.m2e</groupId>
 <artifactId>lifecycle-mapping</artifactId>
 <version>1.0.0</version>
 <configuration>
   <lifecycleMappingMetadata>
     <pluginExecutions>
       <pluginExecution>
         <pluginExecutionFilter>
           <groupId>some-group-id</groupId>
           <artifactId>some-artifact-id</artifactId>
           <versionRange>[1.0.0,)</versionRange>
           <goals>
             <goal>some-goal</goal>
           </goals>
         </pluginExecutionFilter>
         <action>
             <!-- here -->
         </action>
       </pluginExecution>
     </pluginExecutions>
   </lifecycleMappingMetadata>
 </configuration>
</plugin>
</plugins>
</pluginManagement>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM