Maven「Unknown lifecycle phase」の原因と直し方
Unknown lifecycle phase は、引用符の中の語を正しいフェーズ名に直せば消える。
PowerShell で .test.skip=true のような語が出たら、-D の引数を引用符で囲む。
公開: 更新:
mvn clean-install … [ERROR] Unknown lifecycle phase "clean-install". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2026-11-02 に maven:3-eclipse-temurin-21(Git 2.53.0) で実際に打って取った出力。検証環境の詳細
要約
mvn に渡した語のうち、フェーズとしてもプラグインのゴールとしても解釈できないものがあると、ビルドが始まる前に止まる。
Maven 3.10.0 で mvn clean-install を実行すると次の行が出る(後半のフェーズの一覧は途中を省いた)。
[ERROR] Unknown lifecycle phase "clean-install". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, ... site-deploy. -> [Help 1]Unknown lifecycle phase の後ろの引用符の中が、Maven がフェーズとして受け取った語だ。
まずここを見る。clean-install のような打ち間違いならすぐ分かるが、".test.skip=true" のように自分では打ったつもりのない断片が出ていたら、シェルが引数を分けている。
実行例
maven:3-eclipse-temurin-21 のコンテナで、mvn clean-install と打つと、Unknown lifecycle phase "clean-install" で終了コード 1 になった。-Dmaven .test.skip=true のように途中に空白を入れた場合も、.test.skip=true がフェーズ名として扱われて終了コード 1 になった。
$ mvn -v
Apache Maven 3.10.0 (c43a36b8d67be7e0805a411bc0898af1a51f5472)
Maven home: /usr/share/maven
Java version: 21.0.13, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en_US, platform encoding: UTF-8, time zone: Etc/UTC
OS name: "linux", version: "6.6.87.2-microsoft-standard-wsl2", arch: "amd64", family: "unix"$ mvn clean-install
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 1.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.060 s
[INFO] Finished at: 2026-11-02T00:22:01Z
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "clean-install". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
$ echo $?
1$ mvn clean install -Dmaven .test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 1.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.058 s
[INFO] Finished at: 2026-11-02T00:22:02Z
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".test.skip=true". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
$ echo $?
1— 2026-11-02 時点の出力
検証環境Git 2.53.0 / 2026-11-02 検証
- 検証日
- 実行環境
maven:3-eclipse-temurin-21Ubuntu 26.04.1 LTS- バージョン
- Git 2.53.0
この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。
解決策
1. 引用符の中の語を正しいフェーズ名に直す
使えるフェーズはエラーの Available lifecycle phases are: の後ろに並んでいる。
よく使うのは clean・compile・test・package・verify・install だ(Introduction to the Build Lifecycle(新しいタブで開く))。
mvn clean install2. PowerShell では -D の引数を引用符で囲む
引数全体を引用符で囲むと、1 つの引数として渡る。
mvn clean install "-Dmaven.test.skip=true"ほかに、先頭にバッククォートを置いて `-Dmaven.test.skip=true と書く方法(PowerShell のエスケープ)と、--%(stop-parsing token)を置く方法がある。--% はそれ以降の行をそのまま渡すので、同じ行に ; で別のコマンドをつなぐと、それも引数になってしまう(about_Parsing(新しいタブで開く))。
mvn --% clean install -Dmaven.test.skip=trueドットを含む別のプロパティでも同じことが起きる。
Windows PowerShell 5.1 で -Dspring-boot.run.profiles=dev を引用符なしで渡すと、-Dspring-boot と .run.profiles=dev に分かれた。
3. -D は空白を入れずに書く
mvn -DskipTests=true package4. プラグインのゴールはコロンでつなぐ
プラグインのゴールは プレフィックス:ゴール の形で 1 語にする。
LifecyclePhaseNotFoundException(新しいタブで開く) では、mvn compiler:compile や、プラグインの groupId と artifactId まで書く形が挙げられている。
Spring Boot のプラグインを使うプロジェクトなら、次のように書く。
mvn spring-boot:runよくある原因
- フェーズ名を打ち間違えている。
complieのような綴りの誤りや、cleanとinstallをハイフンでつないだclean-installがこれに当たる。
複数のフェーズは空白で区切って並べる。 - PowerShell が
-Dの引数を分けている。
Windows PowerShell 5.1 と PowerShell 7.4 で確かめたところ、-Dmaven.test.skip=trueを引用符なしで書くと、ドットの手前で-Dmavenと.test.skip=trueの 2 つに分かれて渡された。
Maven 3.10.0 にこの 2 つを渡すと、.test.skip=trueがフェーズとして扱われ、Unknown lifecycle phase ".test.skip=true"になる。
ドットを含まない-DskipTestsは分かれなかった。 =の前後に空白がある。-DskipTests = trueと書くと、=とtrueが別の引数になる。
Maven 3.10.0 ではUnknown lifecycle phase "="が出た。- ゴールの書き方が違う。
mvn spring-boot runはspring-bootとrunの 2 つのフェーズとして扱われ、Unknown lifecycle phase "spring-boot"になる。