Getting Maven exec: java plugin to use project module dependencies

I am using Maven exec: java to run jline for one of my projects (the current POM is attached below). The project was a single component, so all dependencies were in the same POM as the exec: java plugin definition. This worked great and all dependencies were picked up and mapped to the classpath when I ran "mvn exec: java". However, I have now split the project into multiple modules and would like the dependencies for each module to be picked up when exec: java is running, but I can't figure out how to set it up. The advice would be greatly appreciated!

thanks Nick


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>Lensfield</name>
    <groupId>org.lensfield</groupId>
    <artifactId>lensfield-pom</artifactId>
    <version>0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includeProjectDependencies>true</includeProjectDependencies>
                    <includePluginDependencies>true</includePluginDependencies>
                    <executableDependency>
                        <groupId>jline</groupId>
                        <artifactId>jline</artifactId>
                    </executableDependency>
                    <mainClass>jline.ConsoleRunner</mainClass>
                    <arguments>
                        <argument>clojure.lang.Repl</argument>
                    </arguments>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>jline</groupId>
                        <artifactId>jline</artifactId>
                        <version>0.9.94</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <modules>
        <module>lensfield-share</module>
        <module>lensfield-build</module>
        <module>lensfield-webapp</module>
    </modules>
</project>


      

+2


source to share


1 answer


You can specify the parent POM for the project and define the exec plugin in pluginManagement

the parent section. This means that the plugin configuration will be available to any child POM that declares the minimum plugin configuration. The following would be enough.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
</plugin>

      



When the child process is processed, it will inherit the configuration from the parent, and the exec-plugin will execute with the current project dependencies.

+2


source







All Articles