kofucii
kofucii

Reputation: 7653

How to "put" maven command line in pom.xml?

How can I "put" a command line parameter to be executed from pom.xml. For example I have:

mvn clean install -Dmyparameter

And I wish It to be executed from pom.xml instead from command line.

Upvotes: 5

Views: 4837

Answers (2)

om39a
om39a

Reputation: 1406

It depends on which phase you need to use the args. It can be done on plugins by changing the configuration parameter.

<pluginManagement>
    <plugin>
        ......
        ......
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <arguments>-Dmaven.test.skip=true -D[other arguments that u need to include]</arguments>
        </configuration>
        ......
        ......
</plugin> </pluginManagement>

Same way in the sure fire plugin u can skip test and so on!!

Upvotes: 4

Andriy Plokhotnyuk
Andriy Plokhotnyuk

Reputation: 7989

You can try to use maven-exec-plugin:

mvn clean install exec:exec -Dexecutable=<absolute path to binary>

Also it can be bound to some phase of lifecycle to be executed in the middle of the build (without explicit call by exec:exec) and defined in profile with activation if property exists to run optionally:

   <profiles>
  <profile>
    <id>exec</id>
    <activation>
      <property>
        <name>executable</name>
      </property>
    </activation>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <id>exec</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
        <configuration>
          <executable>${executable}</executable>
        </configuration>
      </plugin>
    </plugins>
  </profile>
</profiles>

Upvotes: 4

Related Questions