Maven2/TIPS集
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents
** -source 1.3 でサポートされていません とか言われる場合 ...
[[ソースのバージョン - TzlTTqTjの日記>http://d.hatena.ne....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
さらにtargetタグにつづけて
<encoding>Windows-31J</encoding>
とか指定すれば、文字エンコーディングによるコンパイルエラ...
**フェーズ [#i93a5c7c]
フェーズとは mvn complieとかmvn installとか、プロジェクト...
-[[Maven 2.0を知る、使う>http://www.itarchitect.jp/enterp...
またフェーズには validate -> compile -> test -> deployな...
デフォルトのライフサイクルは
${MAVEN_HOME}/lib/maven-core-2.0.7-uber.jar#META-INF/ple...
に定義されている。[[components.xml>http://svn.apache.org/...
**リポジトリにプロキシ経由で接続する [#q56c97dc]
~/.m2/settings.xml
に以下の記述を書いておきます。
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hogehoge.jp</host>
<port>81</port>
<username>fuga</username>
<password>fuga</password>
<nonProxyHosts>www.google.com|*.hoge.jp</nonProxyH...
</proxy>
</proxies>
</settings>
-[[Maven事始め>http://www.limy.org/program/java/maven/fir...
**プロジェクト作成。 [#bf93876d]
mvn archetype:create -DgroupId=nu.mine.kino.mavensample ...
グループIDとプラグインIDを指定するんですね。
**pom.xmlからEclipseのプロジェクトを生成する。 [#gab0f1a9]
mvn eclipse:eclipse
これでEclipse関連のファイルができあがります。以後、Eclips...
出力されるファイル内で
M2_REPO
という変数を使用しているので、Eclipseの変数としてM2_REPO...
**プロジェクトの構成を出力する [#ka7ac4ca]
通常pom.xmlはデフォルト値は省略されますが、それを省略しな...
mvn projecthelp:effective-pom
コンソールに
<?xml version="1.0"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>nu.mine.kino.mavensample</groupId>
<artifactId>kino-app</artifactId>
<name>kino-app</name>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<build>
<sourceDirectory>t:\workspace3.2\kino-app\src\main\j...
<scriptSourceDirectory>src/main/scripts</scriptSourc...
<testSourceDirectory>t:\workspace3.2\kino-app\src\te...
<outputDirectory>t:\workspace3.2\kino-app\target\cla...
<testOutputDirectory>t:\workspace3.2\kino-app\target...
<resources>
<resource>
<directory>t:\workspace3.2\kino-app\src\main\res...
</resource>
</resources>
<testResources>
<testResource>
<directory>t:\workspace3.2\kino-app\src\test\res...
</testResource>
</testResources>
<directory>t:\workspace3.2\kino-app\target</directory>
<finalName>kino-app-1.0-SNAPSHOT</finalName>
<plugins>
<plugin>
<artifactId>maven-projecthelp-plugin</artifactId>
<version>2.0-beta-1</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<outputDirectory>target/site</outputDirectory>
</reporting>
</project>
が出力されました。ファイルにリダイレクトして、ちょこちょ...
**settings.xmlの構成を出力する [#g669e4e0]
mvn help:effective-settings -Doutput=effective-settings....
でデフォルトのsettings.xmlが出力される
**ローカルリポジトリを変更する [#ha9a3300]
デフォルトは
~/.m2/repository
のヤツ。Mavenのインストールディレクトリ配下などにある、se...
<?xml version="1.0"?><settings>
<localRepository>~/.m2/repositoryNew</localRepository> ...
<servers>...
</servers>
</settings>
http://slashdot.jp/~pluto/journal/328571
**依存するライブラリを追加する [#lf96b8c4]
Mavenは必要なライブラリがローカルにあるかを探し、なかった...
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency> dependencies内に複数かける
</dependencies>
<groupId />
<artifactId />
<version />
は必須みたいですね。
**サイトを作成する [#d4edf8f0]
**作成したサイトに、様々な情報を載せる [#a02f8db3]
**ソースをjarにする [#m37c1720]
mvn package
でjarが作成されます。
**ローカルリポジトリにjarを配置する [#nbd0b05a]
mvn install
で該当プロジェクトがローカルリポジトリ(~/.m2のことです)に...
ProjectA
ProjectB <- ProjectAに依存してる
場合、まずProjectAをinstallして、んでProjectBはpom.xmlでP...
-[[依存Jarをローカルリポジトリに追加する>http://72.14.235...
ちなみにインストールしたときのディレクトリ構成ですが
groupId(の.を/で切ったモノ)/artifactId
となるのでgroupIdは適度な長さにしておいた方が良さそうです...
**ローカルリポジトリに任意のjarを追加する [#k7968584]
たとえば以下のコマンドで
mvn install:install-file -DgroupId=javax.transaction -Da...
-Dversion=1.0.1B -Dpackaging=jar -Dfile=jta-1_0_1B.jar
jta-1_0_1B.jar というファイルが上のグループID,プラグインI...
**Mavenのpom.xmlのスキーマ [#pff8c406]
-[[Maven Model>http://maven.apache.org/ref/2.0.4/maven-mo...
**pom.xmlの説明 [#id206df3]
-[[pom.xml>http://www.limy.org/program/java/maven/project...
**site:deployで、作成したサイトをWEBに公開する。 [#nf134d...
mvn clean site-deploy
で、htmlドキュメントを作成して所定のサーバにアップするこ...
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nu.mine.kino.mavensample</groupId>
<artifactId>kino-app</artifactId>
<name>kino-app</name>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<ciManagement>
略
<distributionManagement>
<site>
<id>ftp-site</id> ↓プット先のディレクトリ
<url>ftp://[サーバ名]/var/www/html/hoge</url>
</site>
</distributionManagement>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<sourceDirectory>source</sourceDirectory>
略
</project>
上の例ではFTPでアップするよう指定しているので、
~/.m2/settings.xml
にアップするFTPアカウントを指定しておく必要があります。
-settings.xml
<settings>
<!--
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hogehoge.jp</host>
<port>81</port>
<username>fuga</username>
<password>fuga</password>
<nonProxyHosts>www.google.com|*.hoge.jp</nonProxyH...
</proxy>
</proxies>
-->
<servers>
<server>
<id>ftp-site</id>
<username>hogehoge</username> <-FTPアカウント
<password>fugafuga</password>
</server>
</servers>
</settings>
以上でOKです。。っていいたいところですが、なぜかこれだ...
bash-3.2$ mvn site:deploy
[INFO] [site:deploy]
[INFO] -------------------------------------------------...
[ERROR] BUILD ERROR
[INFO] -------------------------------------------------...
[INFO] Wagon protocol 'ftp' doesn't support directory co...
[INFO] -------------------------------------------------...
[INFO] For more information, run Maven with the -e switch
[INFO] -------------------------------------------------...
というように、なぜか
Wagon protocol 'ftp' doesn't support directory copying
ってでちゃうんですね。
**site:deployでFTPに失敗する。 [#e0ba4f36]
さて
Wagon protocol 'ftp' doesn't support directory copying
の話です。どうも調べていくと [[Maven Wagon>http://maven.a...
結局MavenのSubversionのtrunkから最新のソースを取ってきて...
[[Wagonのサイト>http://maven.apache.org/wagon/source-repo...
[[/trunk/wagon-providers>http://svn.apache.org/repos/asf/...
cd wagon-1.0-beta-2/wagon-providers/wagon-ftp
mvn clean package
でjarを作り直してローカルリポジトリのjarを差し替えちゃい...
これでめでたくFTPプットができるようになりました。
**jarに同梱するリソースを指定する。 [#ac7722ce]
デフォルトではsrc/main/resources/内のファイルはパッケージ...
例えばEclipseのプラグインのようにプロジェクト直下(つまりp...
<build>
<sourceDirectory>source</sourceDirectory>
<scriptSourceDirectory>main/scripts</scriptSourceDire...
<testSourceDirectory>test</testSourceDirectory>
<outputDirectory>classes</outputDirectory>
<testOutputDirectory>target\test-classes</testOutputD...
<resources>
<resource>
<directory>.</directory> <-ここ↓
<includes>
<include>plugin.xml</include>
<include>plugin.properties</include>
</includes>
</resource>
</resources>
................
</build>
とすればよい。
**独自のMANIFEST.MFを同梱したい。 [#k31d7db2]
MANIFEST.MFはMavenが勝手に同梱しちゃうけど、Eclipseのプラ...
<build>
.......
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
<manifest>
<addDefaultSpecificationEntries>false</addDef...
<addDefaultImplementationEntries>false</addDe...
</manifest> ↑この二つはまだ用途不明。
</archive>
</configuration>
</plugin>
...........
</plugins>
</build>
でもどうもMANIFEST.MFを読み込んでMavenが勝手にいじってし...
http://maven.apache.org/plugins/maven-jar-plugin/source-r...
自分で作っちゃう?
-[[Maven2 で JAR の Manifest ファイルを設定する方法をメモ...
**プラグインのソースコードを入手する [#ze9e3d68]
基本的にhttp://maven.apache.org/plugins/のプラグインの一...
----
この記事は
#vote(おもしろかった[26],そうでもない[4])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
終了行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents
** -source 1.3 でサポートされていません とか言われる場合 ...
[[ソースのバージョン - TzlTTqTjの日記>http://d.hatena.ne....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
さらにtargetタグにつづけて
<encoding>Windows-31J</encoding>
とか指定すれば、文字エンコーディングによるコンパイルエラ...
**フェーズ [#i93a5c7c]
フェーズとは mvn complieとかmvn installとか、プロジェクト...
-[[Maven 2.0を知る、使う>http://www.itarchitect.jp/enterp...
またフェーズには validate -> compile -> test -> deployな...
デフォルトのライフサイクルは
${MAVEN_HOME}/lib/maven-core-2.0.7-uber.jar#META-INF/ple...
に定義されている。[[components.xml>http://svn.apache.org/...
**リポジトリにプロキシ経由で接続する [#q56c97dc]
~/.m2/settings.xml
に以下の記述を書いておきます。
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hogehoge.jp</host>
<port>81</port>
<username>fuga</username>
<password>fuga</password>
<nonProxyHosts>www.google.com|*.hoge.jp</nonProxyH...
</proxy>
</proxies>
</settings>
-[[Maven事始め>http://www.limy.org/program/java/maven/fir...
**プロジェクト作成。 [#bf93876d]
mvn archetype:create -DgroupId=nu.mine.kino.mavensample ...
グループIDとプラグインIDを指定するんですね。
**pom.xmlからEclipseのプロジェクトを生成する。 [#gab0f1a9]
mvn eclipse:eclipse
これでEclipse関連のファイルができあがります。以後、Eclips...
出力されるファイル内で
M2_REPO
という変数を使用しているので、Eclipseの変数としてM2_REPO...
**プロジェクトの構成を出力する [#ka7ac4ca]
通常pom.xmlはデフォルト値は省略されますが、それを省略しな...
mvn projecthelp:effective-pom
コンソールに
<?xml version="1.0"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>nu.mine.kino.mavensample</groupId>
<artifactId>kino-app</artifactId>
<name>kino-app</name>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<build>
<sourceDirectory>t:\workspace3.2\kino-app\src\main\j...
<scriptSourceDirectory>src/main/scripts</scriptSourc...
<testSourceDirectory>t:\workspace3.2\kino-app\src\te...
<outputDirectory>t:\workspace3.2\kino-app\target\cla...
<testOutputDirectory>t:\workspace3.2\kino-app\target...
<resources>
<resource>
<directory>t:\workspace3.2\kino-app\src\main\res...
</resource>
</resources>
<testResources>
<testResource>
<directory>t:\workspace3.2\kino-app\src\test\res...
</testResource>
</testResources>
<directory>t:\workspace3.2\kino-app\target</directory>
<finalName>kino-app-1.0-SNAPSHOT</finalName>
<plugins>
<plugin>
<artifactId>maven-projecthelp-plugin</artifactId>
<version>2.0-beta-1</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<outputDirectory>target/site</outputDirectory>
</reporting>
</project>
が出力されました。ファイルにリダイレクトして、ちょこちょ...
**settings.xmlの構成を出力する [#g669e4e0]
mvn help:effective-settings -Doutput=effective-settings....
でデフォルトのsettings.xmlが出力される
**ローカルリポジトリを変更する [#ha9a3300]
デフォルトは
~/.m2/repository
のヤツ。Mavenのインストールディレクトリ配下などにある、se...
<?xml version="1.0"?><settings>
<localRepository>~/.m2/repositoryNew</localRepository> ...
<servers>...
</servers>
</settings>
http://slashdot.jp/~pluto/journal/328571
**依存するライブラリを追加する [#lf96b8c4]
Mavenは必要なライブラリがローカルにあるかを探し、なかった...
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency> dependencies内に複数かける
</dependencies>
<groupId />
<artifactId />
<version />
は必須みたいですね。
**サイトを作成する [#d4edf8f0]
**作成したサイトに、様々な情報を載せる [#a02f8db3]
**ソースをjarにする [#m37c1720]
mvn package
でjarが作成されます。
**ローカルリポジトリにjarを配置する [#nbd0b05a]
mvn install
で該当プロジェクトがローカルリポジトリ(~/.m2のことです)に...
ProjectA
ProjectB <- ProjectAに依存してる
場合、まずProjectAをinstallして、んでProjectBはpom.xmlでP...
-[[依存Jarをローカルリポジトリに追加する>http://72.14.235...
ちなみにインストールしたときのディレクトリ構成ですが
groupId(の.を/で切ったモノ)/artifactId
となるのでgroupIdは適度な長さにしておいた方が良さそうです...
**ローカルリポジトリに任意のjarを追加する [#k7968584]
たとえば以下のコマンドで
mvn install:install-file -DgroupId=javax.transaction -Da...
-Dversion=1.0.1B -Dpackaging=jar -Dfile=jta-1_0_1B.jar
jta-1_0_1B.jar というファイルが上のグループID,プラグインI...
**Mavenのpom.xmlのスキーマ [#pff8c406]
-[[Maven Model>http://maven.apache.org/ref/2.0.4/maven-mo...
**pom.xmlの説明 [#id206df3]
-[[pom.xml>http://www.limy.org/program/java/maven/project...
**site:deployで、作成したサイトをWEBに公開する。 [#nf134d...
mvn clean site-deploy
で、htmlドキュメントを作成して所定のサーバにアップするこ...
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nu.mine.kino.mavensample</groupId>
<artifactId>kino-app</artifactId>
<name>kino-app</name>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<ciManagement>
略
<distributionManagement>
<site>
<id>ftp-site</id> ↓プット先のディレクトリ
<url>ftp://[サーバ名]/var/www/html/hoge</url>
</site>
</distributionManagement>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<sourceDirectory>source</sourceDirectory>
略
</project>
上の例ではFTPでアップするよう指定しているので、
~/.m2/settings.xml
にアップするFTPアカウントを指定しておく必要があります。
-settings.xml
<settings>
<!--
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hogehoge.jp</host>
<port>81</port>
<username>fuga</username>
<password>fuga</password>
<nonProxyHosts>www.google.com|*.hoge.jp</nonProxyH...
</proxy>
</proxies>
-->
<servers>
<server>
<id>ftp-site</id>
<username>hogehoge</username> <-FTPアカウント
<password>fugafuga</password>
</server>
</servers>
</settings>
以上でOKです。。っていいたいところですが、なぜかこれだ...
bash-3.2$ mvn site:deploy
[INFO] [site:deploy]
[INFO] -------------------------------------------------...
[ERROR] BUILD ERROR
[INFO] -------------------------------------------------...
[INFO] Wagon protocol 'ftp' doesn't support directory co...
[INFO] -------------------------------------------------...
[INFO] For more information, run Maven with the -e switch
[INFO] -------------------------------------------------...
というように、なぜか
Wagon protocol 'ftp' doesn't support directory copying
ってでちゃうんですね。
**site:deployでFTPに失敗する。 [#e0ba4f36]
さて
Wagon protocol 'ftp' doesn't support directory copying
の話です。どうも調べていくと [[Maven Wagon>http://maven.a...
結局MavenのSubversionのtrunkから最新のソースを取ってきて...
[[Wagonのサイト>http://maven.apache.org/wagon/source-repo...
[[/trunk/wagon-providers>http://svn.apache.org/repos/asf/...
cd wagon-1.0-beta-2/wagon-providers/wagon-ftp
mvn clean package
でjarを作り直してローカルリポジトリのjarを差し替えちゃい...
これでめでたくFTPプットができるようになりました。
**jarに同梱するリソースを指定する。 [#ac7722ce]
デフォルトではsrc/main/resources/内のファイルはパッケージ...
例えばEclipseのプラグインのようにプロジェクト直下(つまりp...
<build>
<sourceDirectory>source</sourceDirectory>
<scriptSourceDirectory>main/scripts</scriptSourceDire...
<testSourceDirectory>test</testSourceDirectory>
<outputDirectory>classes</outputDirectory>
<testOutputDirectory>target\test-classes</testOutputD...
<resources>
<resource>
<directory>.</directory> <-ここ↓
<includes>
<include>plugin.xml</include>
<include>plugin.properties</include>
</includes>
</resource>
</resources>
................
</build>
とすればよい。
**独自のMANIFEST.MFを同梱したい。 [#k31d7db2]
MANIFEST.MFはMavenが勝手に同梱しちゃうけど、Eclipseのプラ...
<build>
.......
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
<manifest>
<addDefaultSpecificationEntries>false</addDef...
<addDefaultImplementationEntries>false</addDe...
</manifest> ↑この二つはまだ用途不明。
</archive>
</configuration>
</plugin>
...........
</plugins>
</build>
でもどうもMANIFEST.MFを読み込んでMavenが勝手にいじってし...
http://maven.apache.org/plugins/maven-jar-plugin/source-r...
自分で作っちゃう?
-[[Maven2 で JAR の Manifest ファイルを設定する方法をメモ...
**プラグインのソースコードを入手する [#ze9e3d68]
基本的にhttp://maven.apache.org/plugins/のプラグインの一...
----
この記事は
#vote(おもしろかった[26],そうでもない[4])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
ページ名: