Add jar to maven exec: java classpath

I have a batch file that runs the java class using maven, which depends on tools.jar (on the JDK).
For example:
mvn -f. \ Pom.xml -e exec: java -Dfile.encoding = "UTF-8" -Dexec.mainclass = MyClass -Dexec.args = "% 1% 2% 3% 4% 5% 6% 7% 8% 9 "-Dexec.classpathScope = runtime
My program uses tools.jar from the JDK, and I added a system dependency in maven that points to it.
Since the exec: java target does not include system dependencies, I want to add the dependency from the command line manually.
Although I expected this to be trivial, I could find a way to do this. Any help would be appreciated. Thanks
 Avner

+5
source share
1 answer

From what I read in the maven exec plugin , it allows you to configure executable dependencies as plugin dependencies.

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <includeProjectDependencies>false</includeProjectDependencies>
          <includePluginDependencies>true</includePluginDependencies>
          <executableDependency>
            <groupId>com.example.myproject</groupId>
            <artifactId>mylib</artifactId>
          </executableDependency>
          <mainClass>com.example.Main</mainClass>
        </configuration>
        <dependencies>
          <dependency>
                <groupId>sun.jdk</groupId>
                <artifactId>tools</artifactId>
                <version>1.5.0</version>
                <scope>system</scope>
                <systemPath>${java.home}/../lib/tools.jar</systemPath>
          </dependency>
        </dependencies>
      </plugin>
+10
source

All Articles