[[FrontPage]] #contents 2008/03/10からのアクセス回数 &counter; * mavenプロジェクトの作成 [#r66f1b45] ** archetypeプラグインを使ったプロジェクトの生成 [#t9fed2d2] 最初にarchetypeプラグインを使ってjarライブラリをターゲットとする一般的なjavaプロジェクト を作成します。 #pre{{ $ mvn archetype:create -DgroupId=sample.itext.app -DartifactId=app -Dversion=0.0.1 }} ** 必要なライブラリの追加 [#m72da741] ここでは、iTextの例題を実行するため、itextのmavenリポジトリをpom.xmlに追加する必要があります。 必要なライブラリは、[[MVNRepository>http://mvnrepository.com/]]で検索します。 #ref(mvnrepository.jpg); "itext"を入力して、Searchボタンを押すと、 - com.lowagie >> itext と表示されるので、これをクリックします。 "iText in Action"のバージョンが1.4であり、POM Dependencyの項目 #pre{{ <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>1.4</version> </dependency> }} をpom.xmlにコピーします。 残念ながらiTextAsian.jarは検索できませんでしたので、あとで別途install_fileをします。 最後にEclipseのプロジェクトにします。 #pre{{ mvn eclipse:eclipse -DdownloadSources=true }} ** 必要なjarファイルを別ディレクトリにコピーしたい [#md4b0bbd] 依存するjarファイルを[Project-dir]/dist/libにコピーする場合、以下のコマンドを実行する。 #pre{{ $ mvn dependency:copy-dependencies -DoutputDirectory=dist/lib }} パッケージをビルドするときに、依存するライブラリのパスをpom.xmlで以下の様に指定すると便利です。 #pre{{ <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>jarファイルのメインクラス</mainClass> <packageName>jarファイルのパッケージ名</packageName> <addClasspath>true</addClasspath> <addExtensions>true</addExtensions> <classpathPrefix>./lib</classpathPrefix> </manifest> </archive> </configuration> </plugin> </plugins> </build> }} ** コメント [#i0cf0193] この記事は、 #vote(おもしろかった,そうでもない,わかりずらい) 皆様のご意見、ご希望をお待ちしております。 ##comment_kcaptcha #comment_kcaptcha