How to use the Maven class path to run the main Java class?

I am currently using Maven to create my Rhino JavaScript project, load dependent libraries, and manage classpath at runtime. I can run the JavaScript entry point using the Maven exec plugin as follows:

<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> <mainClass>org.mozilla.javascript.tools.shell.Main</mainClass> <classpathScope>runtime</classpathScope> <arguments> <argument>path/to/entryPoint.js</argument> </arguments> </configuration> </plugin> 

This works well, but the problem is that maven takes about 10 seconds to start, which is about 10 times longer than starting my program. Is there any way:

  • improves the performance of the maven exec plugin, so it takes less time to run or
  • export class path that maven will use at runtime so that I can only run my program from a script?
+6
source share
1 answer
  • You can use the -o / --offline switch to tell Maven not to worry about checking for snapshot updates or plugins.

  • Use appassembler or assembly to create startup scripts that automatically (in the case of appassembler) refer to the desired class path.

+4
source

Source: https://habr.com/ru/post/889919/


All Articles