2016-07-01 10 views
0

私はあなたの助けが必要です。 Mavenによるビルドアプリケーション中にサブプロジェクトのバージョンをMANIFEST.MFファイルに追加するスクリプトを書く必要があります。Mavenビルド中にMANIFEST.MFファイルに自分の情報を追加

私は必要な情報を取得するMojoクラスを作成しました(私はGenerateVersionPropertyFile.classという名前です)。今、私はこの情報をマニフェストファイルに入れる方法を知っておく必要があります。

は、ここに私のpom.xml次のとおりです。

<build> 
    <finalName>${project.artifactId}</finalName> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ejb-plugin</artifactId> 
      <configuration> 
       <ejbVersion>3.1</ejbVersion> 
       <generateClient>true</generateClient> 
       <archive> 
        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile> 
        <!-- 
        <manifest> 
         <addClasspath>true</addClasspath> 
         <classpathPrefix>lib</classpathPrefix> 
        </manifest> 
        --> 
        <manifestEntries> 
         <Built-By /> 
        </manifestEntries> 
        <manifestSections> 
         <manifestSection> 
          <Name>appName</Name> 
          <manifestEntries> 
           <Implementation-Title>${project.name}</Implementation-Title> 
           <Implementation-Version>${project.version}</Implementation-Version> 
           <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id> 
           <Implementation-Vendor>${project.organization.name}</Implementation-Vendor> 
          </manifestEntries> 
         </manifestSection> 
         <manifestSection> 
          <Name>exampleApp</Name> 
          <manifestEntries> 
           <Implementation-Title>exampleEntry</Implementation-Title> 
           <Implementation-Version>dupa2</Implementation-Version> 
           <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id> 
           <Implementation-Vendor>${project.organization.name}</Implementation-Vendor> 
          </manifestEntries> 
         </manifestSection> 
        </manifestSections> 
       </archive> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.1.1</version> 
      <executions> 
      <execution> 
      <phase>test</phase> 
      <goals> 
       <goal>java</goal> 
      </goals> 
      <configuration> 
       <mainClass>maven.GenerateVersionPropertyFile</mainClass> 
       <arguments> 
       <argument>${project.basedir}\src</argument> 
       <argument>${project.build.directory}</argument> 
       </arguments> 
      </configuration> 
      </execution> 
      </executions> 
      </plugin> 
    </plugins> 
</build> 

<profiles> 
    <profile> 
     <id>server-ejb-build-devel</id> 
     <activation> 
      <property> 
       <name>build-devel</name> 
      </property> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-ejb-plugin</artifactId> 
        <configuration> 
         <archive> 
          <manifestSections> 
           <manifestSection> 
            <Name>app1</Name> 
            <manifestEntries> 
             <Implementation-Build>${buildNumber}</Implementation-Build> 
             <Implementation-Timestamp>${timestamp}</Implementation-Timestamp> 
            </manifestEntries> 
           </manifestSection> 
          </manifestSections> 
         </archive> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles> 
+0

? – Apostolos

+0

申し訳ありませんmayby私はそれを間違って説明しました。私がサブプロジェクトを言ったとき、私はプロジェクトからjsonスキーマについて考えます。私はこのファイルを解析し、それらから情報を得る必要があるので、私はこれにJavaクラスを使いました。 – user2420602

+0

hmmグラデーションに移動する可能性はありますか?それはそのようなもののために非常に強力です。ただの考え – Apostolos

答えて

0

があなたのポンポン上のmaven-jarファイル・プラグインを使用する必要があります。

例は、Javaクラスを使用してサブモジュールポンポンバージョンタグから直接それを得ることはありませんなぜ

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
    <archive> 
     <manifest> 
     <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 
     <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> 
     </manifest> 
     <manifestEntries> 
     <key>value</key> 
     </manifestEntries> 
    </archive> 
</configuration> 
</plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ejb-plugin</artifactId> 
      <version>${maven-ejb-plugin.version}</version> 
      <configuration> 
       <ejbVersion>3.1</ejbVersion> 
      </configuration> 
     </plugin> 
関連する問題