I use the maven-properties-plugin during the initialization phase to read in a bunch of properties from a properties file.
I also have the jetty plugin configured to set a couple of the project properties – including those read in above – as system properties to jetty.
If I run the result as
mvn initialize jetty:run-war
it works.
If I just say
mvn jetty:run-war
it fails. How can I force a goal specified on the command line to run in a lifecycle that includes the initialization phase?
That’s not what I’m experiencing. If you look at the documentation of the
jetty:run-wargoal, you’ll see that it:So all the phases preceding
packageplus thepackageitself are run and, consequently, the plugins bound to them. And indeed, with the following POM:Running
mvn jetty:run-warproduces the following output:$ mvn jetty:run-war [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building q2488581 - Maven Webapp [INFO] task-segment: [jetty:run-war] [INFO] ------------------------------------------------------------------------ [INFO] Preparing jetty:run-war [INFO] [properties:read-project-properties {execution: default}] [INFO] [resources:resources {execution: default-resources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [compiler:compile {execution: default-compile}] [INFO] No sources to compile [INFO] [resources:testResources {execution: default-testResources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/pascal/Projects/stackoverflow/q2488581/src/test/resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] No sources to compile [INFO] [surefire:test {execution: default-test}] [INFO] No tests to run. [INFO] [war:war {execution: default-war}] [INFO] Packaging webapp [INFO] Assembling webapp[q2488581] in [/home/pascal/Projects/stackoverflow/q2488581/target/q2488581] [INFO] Processing war project [INFO] Copying webapp resources[/home/pascal/Projects/stackoverflow/q2488581/src/main/webapp] [INFO] Webapp assembled in[76 msecs] [INFO] Building war: /home/pascal/Projects/stackoverflow/q2488581/target/q2488581.war [INFO] [jetty:run-war {execution: default-cli}] ...As we can see,
properties:read-project-propertiesis invoked during theinitializephase (beforeprocess-resourcesto whichresources:resourcesis bound) as expected.In other words, I cannot reproduce your problem (or maybe you should be more specific).