0

My situation: I have a java project in eclipse. I have recently added the Maven plugin to my eclipse IDE.

In order for Maven to export my .jar, I have to right click my project > run as > Maven Clean. Then I have to right click my project > Maven > update project. Then I have to right click my project > run as > Maven install. Must be done in this order and skipping the middle step will produce errors with no successful .jar file.
So my first question is can I automate this within eclipse? If not, can I simplify this process?

My second question is, can I specify the destination folder of that exported .jar to anywhere on my computer?
So for instance Maven normally exports the .jar to D:\${eclipse.workspace}\${project.name}\target\ but I would like to export it to D:\Programs\. Once again, this must be done from within eclipse. It would be preferable if the solution could simply make a copy from \target\ to \programs or have a second directory output.

I've briefly (as in spent the better part of my day) looked at pom.xml configurations and Ant build tool but am not sure if I'm chasing a dead end.

Appreciate any and all help given!

fijas
  • 1,272
  • 1
  • 16
  • 26

2 Answers2

0

@SethFul; Right click the project (or POM file) -> Run As -> Run Configurations -> Maven Build -> write in the profiles box the actions you want: "clean install" -> run.

That will perform both actions at once.

Changing the output dir is also feasible; take a look at [this question][1]

[1]: How to change maven build directory? ... hope you find the answer there.

Community
  • 1
  • 1
Diego Villa
  • 131
  • 5
  • Thank you for your swift reply! While I was not able to immediately find a solution to my questions with your responses, they did contribute to the eventual answer to my problems. The first response you gave was what I was looking for, however the middle step (Right click project > Maven > update project) could not be resolved this way. Thanks in kind sir. – SethFul Mar 20 '15 at 09:07
0

(1)The solution to the first question (credit to @Diego Vill), is: Right click project -> Run As -> Run Configurations... -> Maven Build. In the "Goals" textbox put "clean install". Click Apply.

(2)To solve the problem of having to right click project -> Maven -> Update Project. I removed this step, having Maven Clean and Install(See 1). This would throw an error, stating that it was missing a tools.jar. I followed this answer link by Isuru chathuranga to resolve the problem.

The solution to my second question is in this link. This would allow me to copy my .jar after it was exported, and place the copy in another directory. All done within Eclipse.

(Note 2, for an explanation on why I needed to constantly Update Project after modifying any project files see dmiandres answer: link)

Community
  • 1
  • 1