2016-09-19 12 views
0

SCM(ここではsvn)から取得したリビジョン番号に基づいて、ビルド番号を自分のEARのMANIFEST.MFに入れようとしています。 。 私はいくつかのネストされたプロジェクトを持つmaven親プロジェクトを持っています。その1つはEARの作成を担当しています。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をプロパティBuildNumberを-のmaven-Pからルーギンは空です。 提案がありますか?

+0

buildnumber-maven-pluginを実行する必要がありますが、pluginManagementでのみ定義しています。したがって、ライフサイクルへの拘束は起こっていません。 – khmarbaise

+0

build-number-maven-pluginを含むapp-ear/pom.xmlを変更しました。 MANIFEST.MFで何も変更されていません – chess4ever

+0

サンプルプロジェクトをgithubに入れて見てください。 – khmarbaise

答えて

0

別の<plugins> tag </plugins><pluginManagement>の外側に作成し、そこにbuildnumber mavenプラグインを個別に配置します。それが私のためにしたことなのですが、理由は問いません。

関連する問題