I have a project with finalised version in pom files , lets say 12.3.45 .
I have built the code for this version some time ago already, all the built jars are in the local maven repo.
Then at some point I have run mvn clean, so all the target folders are being removed.
And now I want to execute some code, as quickly as possible, using mvn exec:java. Preferably without building anything, because why not? all the jars at some point were already built, and I know there were no code changes after that. How can I force maven to execute the code as fast as possible , not recompile anything, and just reuse the jars from the local repo?
Thanks.
Asked
Active
Viewed 1,512 times
1

javagirl
- 1,635
- 6
- 27
- 43
-
I do not think, this is possible without building maven project to execute a java class.Other may comment on this. – Sambit Sep 16 '19 at 15:40
-
gradle.properties is located in GRADLE_USER_HOME directory or if you want you can create inside .gradle directory. – Sambit Sep 16 '19 at 15:47
1 Answers
0
- If your artifacts are in a local or remote repository you can use them as dependencies.
- You can use exec-maven-plugin's options includeProjectDependencies or includePluginDependencies to use them in java execution https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#includePluginDependencies. includeProjectDependencies option is enabled (true) by default.
- You can execute exec-maven-plugin without building anything with
mvn exec:java
command
Instructions:
To run exec-maven-plugin you would need a main class to run. I assume you have one in your project. If you don't - you need to make a separate project with a main class.
- Create a blank maven project.
- In the project add exec-maven-plugin configuration. Set the mainClass
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>pack.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
- Include you artifacts as dependencies to the project
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>myartifact</artifactId>
<version>12.3.45</version>
</dependency>
</dependencies>
- Run
mvn exec:java
to executecom.my.package.MyMainClass
main class frommy.group.myartifact
artifact
Edits:
- includeProjectDependencies option is enabled (true) by default

Vitaly Roslov
- 313
- 1
- 8
-
1This is not very helpful, because this property includeProjectDependencies is already TRUE by default. See documentation https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#includePluginDependencies – javagirl Sep 17 '19 at 11:03