logo Exec Maven Plugin

A plugin to allow execution of system and Java programs

homepage: www.mojohaus.org/exec-maven-plugin
fresh index:
last release: 2 years ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central nuxeo
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
exec:exec

A Plugin for executing external programs.

exec:help

Display help information on exec-maven-plugin. Call mvn exec:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

exec:java

Executes the supplied java class in the current VM with the enclosing project's dependencies as classpath.

Often used code snippets:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <configuration>
    <mainClass>org.test.int1.Main</mainClass>
  </configuration>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <version>1.6.0</version>
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>npm install (initialize)</id>
      <phase/>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
    <execution>
      <id>unpack-dependencies</id>
      <phase>package</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>${java.home}/../bin/javafxpackager</executable>
        <arguments>
          <argument>-createjar</argument>
          <argument>-nocss2bin</argument>
          <argument>-appclass</argument>
          <argument>${mainClass}</argument>
          <argument>-srcdir</argument>
          <argument>${project.build.directory}/classes</argument>
          <argument>-outdir</argument>
          <argument>${project.build.directory}</argument>
          <argument>-outfile</argument>
          <argument>${project.build.finalName}.jar</argument>
        </arguments>
      </configuration>
    </execution>
    <execution>
      <id>default-cli</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>${java.home}/bin/java</executable>
        <commandlineArgs>${runfx.args}</commandlineArgs>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.5.0</version>
  <executions>
    <execution>
      <id>npm install (initialize)</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <phase>initialize</phase>
      <configuration>
        <executable>${npm.executable}</executable>
        <arguments>
          <argument>install</argument>
        </arguments>
      </configuration>
    </execution>
    <execution>
      <id>npm install rimraf (clean)</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <phase>pre-clean</phase>
      <configuration>
        <executable>${npm.executable}</executable>
        <arguments>
          <argument>install</argument>
          <argument>rimraf</argument>
        </arguments>
      </configuration>
    </execution>
    <execution>
      <id>npm run clean (clean)</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <phase>clean</phase>
      <configuration>
        <executable>${npm.executable}</executable>
        <arguments>
          <argument>run</argument>
          <argument>clean</argument>
        </arguments>
      </configuration>
    </execution>
    <execution>
      <id>npm run dev (compile)</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <phase>generate-resources</phase>
      <configuration>
        <executable>${npm.executable}</executable>
        <arguments>
          <argument>run</argument>
          <argument>${npm.build.command}</argument>
        </arguments>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <version>1.6.0</version>
  <artifactId>exec-maven-plugin</artifactId>
  <inherited>false</inherited>
  <executions>
    <execution>
      <id>npm install (initialize)</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <phase>initialize</phase>
      <configuration>
        <executable>npm</executable>
        <arguments>
          <argument>install</argument>
        </arguments>
        <workingDirectory>${basedir}</workingDirectory>
      </configuration>
    </execution>
    <execution>
      <id>npm run build (compile)</id>
      <goals>
        <goal>exec</goal>
      </goals>
      <phase>compile</phase>
      <configuration>
        <executable>npm</executable>
        <arguments>
          <argument>run</argument>
          <argument>build</argument>
        </arguments>
        <workingDirectory>${basedir}</workingDirectory>
      </configuration>
    </execution>
  </executions>
  <configuration>
    <environmentVariables>
      <NPM_CONFIG_PREFIX>${basedir}/npm</NPM_CONFIG_PREFIX>
      <NPM_CONFIG_CACHE>${NPM_CONFIG_PREFIX}/cache</NPM_CONFIG_CACHE>
      <NPM_CONFIG_TMP>${project.build.directory}/npmtmp</NPM_CONFIG_TMP>
    </environmentVariables>
  </configuration>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.