Lifecycle prerequisite for maven plugin execution?

I use the maven-properties-plugin during the initialization phase to read the property bundle from the properties file.

I also have a plug-in for consoles configured to set a couple of project properties, including those that are read above, as system properties for the pier.

If I run the result as

mvn initialize jetty:run-war

it works.

If I just say

mvn jetty:run-war

he fails. How can I get the target specified on the command line to work in a life cycle that includes the initialization phase?

+3
source share
2 answers

If I just say mvn jetty:run-war, he fails.

, . jetty:run-war, , :

package .

, , package package, , , . , POM:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.stackoverflow</groupId>
  <artifactId>q2488581</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>q2488581 Maven Webapp</name>
  <build>
    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.10</version>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>etc/config/dev.properties</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

mvn jetty:run-war :

$ 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}]
...

, properties:read-project-properties initialize ( process-resources, resources:resources).

, (, , ).

0

. . file: pom.xml

<profiles>
    <profile>
        <!-- mvn -Plocal -->
        <id>local</id>
        <build>
            <defaultGoal>package</defaultGoal>
            <plugins>
                <plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>run-war</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
+1

Source: https://habr.com/ru/post/1737943/


All Articles