How can I make the exec-maven-plugin goal be invoked with the Maven package phase?

81 Views Asked by At

I've configured exec-mavein-plugin in my module's pom.xml file, but something isn't quite right.

I can invoke the goal directory mvn exec:exec and it works correctly and creates an executable file.

I believe it is configured correctly to be attached to the package phase. But when the package phase is invoked the output file is not created. I'm hoping a small tweak to the configuration will fix it.

Here is the pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.exache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    ...
  </parent>

  <artifactId>rmqcm</artifactId>
  <packaging>jar</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>rmqcm</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>3.0.0</version>
      <type>maven-plugin</type>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        ...
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>3.0.0</version>
          <executions>
            <execution>
              <id>Create Executable</id>
              <phase>package</phase>
              <goals>
                <goal>exec</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <executable>${project.basedir}/scripts/make_rmqcm.bat</executable>
            <arguments>
              <argument>${project.basedir}\scripts\executable_java_stub.sh</argument>
              <argument>${project.build.directory}\${project.build.finalName}.jar</argument>
              <argument>${project.build.directory}\${project.name}</argument>
            </arguments>
          </configuration>
        </plugin>        
      </plugins>
    </pluginManagement>
  </build>
</project>

I appreciate your help.

Russ Petersen

0

There are 0 best solutions below