• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

What does maven "packaging = jar" mean ?

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys : I've been using maven2 to manage dependencies for a while, it works well. I wanted to expand my use of maven to do more than just dependency management.... That is, I want it cover my deployment and testing needs.

However, I was confused about 3 things (I'm using the M2 plugin in eclipse, which very nicely merges maven into the natural eclipse build process, making it somewhat easy to be an ignorant maven user).

1) I never quite know what Maven means by "<packaging>jar</packaging>" .... Is it actually creating a Jar ? If so where is that jar being stored ? I'm also wondering the same thing for the war packaging command ... where is the "war" going ?

2) Is there a way to directly invoke JUnit tests from Maven by simply editing the Pom file ? I know that you can add some JUnit details using the
using the <build> tag, but I'm not sure how this relates, sequentially, to the overall maven compilation process.

Any suggestions on a good, project based maven / eclipse / junit tutorial would be nice also.

 
Saloon Keeper
Posts: 28323
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maven produces artefacts, and the "maven package" goal is the one that will compile the code, gather the resources, run the unit tests and build a deployable artefact (JAR, WAR, EAR, etc.).

The products of Maven are always written to the "target" directory. "mvn clean will erase these products, so I generally build a package using the command "mvn clean package".

"packaging jar" means quite simply that the goal is to produce a jar file in the target directory. "packaging war" would build a WAR file.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That answers the war/jar question. Thanks!!
I was still wondering if there is a way to (by simply editting the pom) add all unit tests in a package to the build workflow ?

i.e. Is there a tag for this that I can add to
The <packaging> directive?
 
Tim Holloway
Saloon Keeper
Posts: 28323
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The maven "package" goal automatically runs unit tests, if you have any defined in your project. You need to add a junit dependency in "test" scope in order to select the Junit jar needed to run the tests, but it's mostly Just Magic.

You should put source for JUnit tests in the src/test/java subdirectory tree.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maven has a build lifecycle and phases. Depending on the packaging type you choose different phases are executed. Have a look at this link for more details
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic