Prev / Next / たまにっき。

maven-resources-plugin に native2ascii 機能を加えるパッチ

Category: [Maven2][Java]
2006-09-13

A patch of maven-resources-plugin 2.2 for executing native2ascii.

これは何?
このパッチは maven-resources-plugin に native2ascii と同等の機能を追加します.

何でこんなのがいるの?
- Maven2 は native2ascii を実行するためのプラグインやら機能やらが標準では提供されていません.
- 有志が maven native2ascii plugin を提供していますが,これには一つの問題があります.それは native2ascii に渡されるプロパティファイルはフィルタリングされないというものです.プロパティファイルに ${pom.version} と書くとその部分を pom.xml の version タグの中身に置き換えてくれる機能が使えないのです.これはイタイ.

そのため,フィルタリングしつつ native2ascii もやってくれるようなプラグインが必要なのです.

このパッチを使う上での制限は

このパッチ自体に著作権を主張するつもりはありません.パッチを当てるプロダクト(maven-resources-plugin)のライセンスを確認して使ってください(多分 apache ライセンスだと思います).

パッチの使い方
1. このリンク からパッチをダウンロードします.
2. maven2 の subversion リポジトリから maven-resources-plugin バージョン 2.2 をダウンロードします.詳細は このページ を参照してください.
3. チェックアウトにより作成されたディレクトリに移動します.
4. patch コマンドを実行し,パッチを当てます.

$ patch -p1 < ../maven-resources-plugin-native2ascii.patch


5. maven2 を install ゴールで実行し,パッチを当てた maven-resources-plugin をローカルリポジトリにインストールします.

$ mvn install



パッチが適用されたプラグインの使い方
pom.xml に以下のような xml タグを追加してください.

  <build>
    <plugins>
        :
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <native2ascii>true</native2ascii>
        </configuration>
      </plugin>
        :
    </plugins>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>


src/main/resources に含まれているプロパティファイルがフィルタリングされた後,native2ascii 機能が実行されます.もし,native2ascii を実行しないならば,native2ascii タグを消すか,native2ascii タグの中身を false にしてください.フィルタリングしたくなければ,同じく filtering タグを消すか,filtering タグの中身を false にしてください.

以下は英語での説明.Following link described above description in English.


A patch of maven-resources-plugin 2.2 for executing native2ascii.

What is this

This patch can be add a new feature which is equivalent of executing native2ascii command to maven-resources-plugin.

Motivation
- Maven2 has no native2ascii plugin.
- Other maven native2ascii plugin are available. However, this plugin have one problem which native2asciied properties file cannot be filtered.

Therefore, we want a new plugin which have both features
(filtering, native2asciiing).

License
This patch is place on public domain. I never claims intellectual property about this patch.

How to use this patch

1. Download patch file from this link.
2. Checkout maven-resources-plugin 2.2 from subversion repository. For more details see this page.
3. Change directory to the checked out directory.
4. Execute patch command with downloaded file, such as

$ patch -p1 < ../maven-resources-plugin-native2ascii.patch


5. Run maven2 to install maven-resources-plugin into your local maven2 repository, such as

$ mvn install



How to use the patched plugin

In your pom.xml add following tags.

  <build>
    <plugins>
        :
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <native2ascii>true</native2ascii>
        </configuration>
      </plugin>
        :
    </plugins>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>


Then, properties files in `src/main/resources' are filtered and native2asciied. If you do not execute `native2ascii,' you will delete the `native2ascii' tag or change the content of `native2ascii' tag to false.

Category: [Maven2][Java]