Mavenベースのプロジェクトのソースコードjarを生成する
「http://maven.apache.org/plugins/maven-source-plugin/[maven-source]」プラグインを使用して、ソースコードをパックし、プロジェクトとともにデプロイします。 これは、デプロイしたプロジェクトを使用し、ソースコードをデバッグ用に添付したい開発者にとって非常に便利です。
1. Mavenソースプラグイン
pom.xml
ファイルにmaven-source-plugin
を追加します。
pom.xml
org.apache.maven.plugins maven-source-plugin attach-sources jar
2. 配備する
「mvn install
」を発行して、プロジェクトをパッケージ化し、ローカルリポジトリにデプロイします。
D:\exampleweb-core>mvn install [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building examplecore project [INFO] task-segment: [install] [INFO] ------------------------------------------------------------------------ //... [INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: D:\exampleweb-core\target\examplecore-1.0.jar [INFO] Preparing source:jar [WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation. [INFO] No goals needed for project - skipping [INFO] [source:jar {execution: attach-sources}] [INFO] Building jar: D:\exampleweb-core\target\examplecore-1.0-sources.jar [INFO] [install:install {execution: default-install}] [INFO] Installing D:\exampleweb-core\target\examplecore-1.0.jar to D:\maven\repo\com\mky ong\examplecore\1.0\examplecore-1.0.jar [INFO] Installing D:\exampleweb-core\target\examplecore-1.0-sources.jar to D:\maven\repo \com\example\examplecore\1.0\examplecore-1.0-sources.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL
3. 出力
ローカルリポジトリを参照すると、2つのjarファイルが作成されます。
-
examplecore-1.0.jar (classes)
-
examplecore-1.0-sources.jar (source code)