0
我試圖把我的EAR的MANIFEST.MF中的內部版本號,基於從SCM檢索的版本號(在這種情況下是svn) 。 我有一個嵌套的項目,其中一個是負責創建EAR的Maven父項目。在MANIFEST.MF buildNumber與buildnumber-maven-plugin和svn沒有生成
這是我父母的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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<sourceVersion>1.8</sourceVersion>
<targetVersion>1.8</targetVersion>
</properties>
<scm>
<connection>scm:svn:svn://[email protected]/example/branches/tryRevision</connection>
</scm>
<modules>
...
<module>app-ear</module>
</modules>
<build>
<!-- plugins used by this POM and all inheriting POMs -->
<pluginManagement>
<plugins>
<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>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>no-revision</revisionOnScmFailure>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.5</version>
<configuration>
<connectionType>connection</connectionType>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
,這是應用程序耳/ pom.xml中:
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>com.example</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app-ear</artifactId>
<packaging>ear</packaging>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${sourceVersion}</source>
<target>${targetVersion}</target>
<verbose>true</verbose>
<fork>true</fork>
<executable>${compilerLocation}</executable>
</configuration>
</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>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>no-revision</revisionOnScmFailure>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<skinnyWars>true</skinnyWars>
<finalName>myapp</finalName>
<version>7</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<archive>
<manifestEntries>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
...
</dependencies>
</project>
我建立與MVN清潔包的項目,尋找裏面的耳META-INF/MANIFEST.MF我得到這個:
Manifest-Version: 1.0
SCM-Revision:
Archiver-Version: Plexus Archiver
Built-By: me
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_102
正如你可以看到,從buildnumber Maven的p-p的buildNumber財產魯金是空的。 有什麼建議嗎?
您需要執行buildnumber-maven-plugin,但您只在pluginManagement中定義了它。所以沒有發生對生命週期的約束。 – khmarbaise
我已經更改了app-ear/pom.xml,包括buildnumber-maven-plugin。 MANIFEST.MF – chess4ever
沒有任何改變請將示例項目放在github上,這樣我可以看一下它... – khmarbaise