更新我的源代码后,我目前必须手动执行两个操作:
- 使用 Alt+F5 更新我的 Maven 项目(这会使用 pom.xml 文件中的相应设置覆盖 Eclipse 项目设置,例如更新类路径文件)
- 使用 maven 运行配置运行我的主 pom.xml 文件(这会执行 pom.xml 文件的所有插件)
有没有办法
- 更新 m2e 项目后自动执行运行配置?或者
- 在运行配置中包含 m2e 项目更新或
- 编写一个 ant 文件来执行 m2e 项目更新和 maven 构建或
- 调整 m2e 插件以不仅更新 Eclipse 设置,而且执行 pom.xml 文件的所有插件(我使用打包 pom,而不是 jar)?
如果我为 Maven 构建导出我的运行配置,它看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="clean install "/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="true"/>
<intAttribute key="M2_THREADS" value="4"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value="../PowerShare/maven_settings.xml"/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dmaven.multiModuleProjectDirectory="/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:PowerTools}"/>
</launchConfiguration>
这是一个示例主 pom.xml 文件:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- HEADER **************************************************************************************************************** -->
<modelVersion>4.0.0</modelVersion>
<groupId>isi.power.tools</groupId>
<artifactId>PowerTools</artifactId>
<version>0.0.1-SNAPSHOT</version> <!-- is available as variable ${project.version} -->
<packaging>pom</packaging>
<!-- CUSTOM PROPERTIES ***************************************************************************************************** -->
<properties>
<!-- set encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<!-- RESOURCES *********************************************************************************************************** -->
<resources>
<resource>
<!-- add java source folder as resource to copy fxml files -->
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<!-- enable replacement of variable place holders with values, e.g. to include version information -->
<filtering>true</filtering>
</resource>
</resources>
<!-- PLUGINS ************************************************************************************************************** -->
<plugins>
<!-- ### RESOURCES ### phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>resource-execution</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ### COMPILE ### phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- specify current java version here: -->
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile-execution</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>isi.power.ace.test-compile-execution</id>
<phase>isi.power.ace.test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ### PACKAGE ### phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>package-execution</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ### INSTALL ### phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-execution</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
<execution>
<id>install-file-execution</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>isi.power.tools</groupId>
<artifactId>PowerTools</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<file>${project.basedir}/target/PowerTools-${project.version}.jar</file>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- MODULES ************************************************************************************************************** -->
<modules>
<module>../PowerCluster</module>
</modules>
<!-- DEPENDENCIES ********************************************************************************************************* -->
<dependencies>
<!-- Dependencies on other workspace projects -->
<dependency>
<groupId>isi.power.share</groupId>
<artifactId>PowerShare</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>PowerACEISI_trunk</groupId>
<artifactId>PowerACEISI_trunk</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>isi.power.cluster</groupId>
<artifactId>PowerCluster</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>