来自 Maven 项目的 IntelliJ IDEA 不使用 Maven 构建
IntelliJ IDEA from Maven project doesn't build with Maven
我有一个 Web 应用程序并完成了:
- Maven 项目 IDEA > 新建 > 来自源码(maven 项目)
已配置 pom 以生成清单条目:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>timestamp-property</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>current.time</name>
<pattern>yyyy-MM-dd HH:mm:ss Z</pattern>
<timeZone>GMT+0</timeZone>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<git-sha>${buildNumber}</git-sha>
<git-branch>${scmBranch}</git-branch>
<build-date>${current.time}</build-date>
</manifestEntries>
</archive>
</configuration>
</plugin>
它在命令行中工作,清单中有所需的条目。像这样的东西:
git-branch: master
build-date: 2016-05-30 07:19:43 +0000
Implementation-Version: 1.0.0-SNAPSHOT
Archiver-Version: Plexus Archiver
git-sha: 7c248cbc66303e4e2574112049deef03a03856cd
当我在 IDEA 中选择 Maven 生命周期 'clean' 和 'install' 并且 运行 它们时,Manifest 也正确生成。
但是当我尝试通过 运行 配置(使用 Tomcat 配置)运行 网络应用程序时,清单包含
等变量
git-branch: ${scmBranch}
build-date: ${current.time}
Implementation-Version: 1.0.0-SNAPSHOT
git-sha:
我在应用程序中使用这些条目。我可以一直使用命令行,但它很难调试。
IDEA Make好像没有使用Maven。有什么方法可以让 IDEA Make 进入 运行 Maven 安装或我可以做的其他事情吗?
我之前写过 'solution of sorts' 回答。现在我有一个更好的,所以正在编辑这个 post。
这并不明显,但您可以将项目添加到 'Run Configurations' 中的 'Before Launch' 框中(我已经向 IntelliJ 建议他们将明确的“+”和“-”放在盒子)。在 Mac 上点击 Command-N
并选择 'add Maven goal'。我添加了 'clean package'。现在插件 运行 并且清单属性已设置。
我有一个 Web 应用程序并完成了:
- Maven 项目 IDEA > 新建 > 来自源码(maven 项目)
已配置 pom 以生成清单条目:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <id>timestamp-property</id> <goals> <goal>timestamp-property</goal> </goals> <configuration> <name>current.time</name> <pattern>yyyy-MM-dd HH:mm:ss Z</pattern> <timeZone>GMT+0</timeZone> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> </plugin> <plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <git-sha>${buildNumber}</git-sha> <git-branch>${scmBranch}</git-branch> <build-date>${current.time}</build-date> </manifestEntries> </archive> </configuration> </plugin>
它在命令行中工作,清单中有所需的条目。像这样的东西:
git-branch: master
build-date: 2016-05-30 07:19:43 +0000
Implementation-Version: 1.0.0-SNAPSHOT
Archiver-Version: Plexus Archiver
git-sha: 7c248cbc66303e4e2574112049deef03a03856cd
当我在 IDEA 中选择 Maven 生命周期 'clean' 和 'install' 并且 运行 它们时,Manifest 也正确生成。
但是当我尝试通过 运行 配置(使用 Tomcat 配置)运行 网络应用程序时,清单包含
等变量git-branch: ${scmBranch}
build-date: ${current.time}
Implementation-Version: 1.0.0-SNAPSHOT
git-sha:
我在应用程序中使用这些条目。我可以一直使用命令行,但它很难调试。
IDEA Make好像没有使用Maven。有什么方法可以让 IDEA Make 进入 运行 Maven 安装或我可以做的其他事情吗?
我之前写过 'solution of sorts' 回答。现在我有一个更好的,所以正在编辑这个 post。
这并不明显,但您可以将项目添加到 'Run Configurations' 中的 'Before Launch' 框中(我已经向 IntelliJ 建议他们将明确的“+”和“-”放在盒子)。在 Mac 上点击 Command-N
并选择 'add Maven goal'。我添加了 'clean package'。现在插件 运行 并且清单属性已设置。