Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the connection between maven and my application?

I need to build java project. The project should include two modules: domain and web.
The domain module contains all the entities, the business logic and hibernate integration.
The web module should be depend on the domain module and contains web application using apache wicket.
I wonder about the maven usage.
Should I create a project and modules using maven? If so, how?
What kind of archetype are relevant for my project and modules?
What is better experience - create the project myself or use maven?

I am using intellij.

like image 555
Naor Avatar asked Dec 23 '11 15:12

Naor


People also ask

How Maven is useful in build an application?

Maven provides project information (log document, dependency list, unit test reports etc.) Maven is very helpful for a project while updating central repository of JARs and other dependencies. With the help of Maven we can build any number of projects into output types like the JAR, WAR etc without doing any scripting.

What is the purpose of using Maven?

Maven's primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal, Maven deals with several areas of concern: Making the build process easy. Providing a uniform build system.

Why do you need Maven in your project?

The Need for Maven Maven is chiefly used for Java-based projects, helping to download dependencies, which refers to the libraries or JAR files. The tool helps get the right JAR files for each project as there may be different versions of separate packages.

Is Maven an application?

Maven is a build management tool that is central to project build tasks such as compilation, packaging, and artifact management. Maven uses a strict XML-based rule set to promote consistency while maintaining flexibility.


3 Answers

I'm assuming you don't need a server for others to access your code, but rather, you want to use maven/ant for internal project organization/dependency resolution/source organization.

Should I create a project and modules using maven?

Yes, either maven or ant will be useful for any non-trivial Java or Java EE project with external dependencies, and build/testing requirements.

If so, how?

Either ant/maven will allow you to easily setup a platform independent "build" file, so that you can easily resolve dependencies, build your jar executables, and run unit tests in order by issuing a single command, rather than multiple clicks to different plugins in whatver the ide-of-the-month is. You can do this in eclipse using the maven plugin to create a new maven project, or , as you suggest, by creating an artifact by running the regular mvn install.

What kind of archetype are relevant for my project and modules?

To learn use maven-archetype-quickstart. For a regular (simple) j2ee app, try maven-archetype-webapp. There is also a j2ee archetype as well.

What is better experience - create the project myself or use maven?

A simple, 3-step, robust method for setting up a maven project :

1) Use maven archetypes to create and setup your "hello world" project.

2) Import the maven project into your ide as a java project.

3) Edit/refine/fix code in your IDE, but use maven to build and test the whole application.

Update: external web frameworks

Creating a wicket (or gwt or any other framework) oriented web app will Be best done following specific tutorials related to the framework itself. In order to add theframework libs, just paste the maven info in your pom.xml like thus, and run a "mvn install" command :

<dependency>
    <groupId>org.apache.wicket</groupId>
    <artifactId>wicket-core</artifactId>
    <version>1.5.3</version>
</dependency>
like image 142
jayunit100 Avatar answered Oct 12 '22 22:10

jayunit100


I'd recommend you to use maven. The reasons why I use maven:

  1. IDE agnostic. You can use idea, eclipse or some other ID.
  2. Dependencies management
  3. Powerful plugin system

You can manually create 3 maven module

  1. app.parent with pom packaging and no parent.
  2. app.domain with jar packaging and app.parent parent
  3. app.web with war packaging and app.parent parent

and import app.parent to idea.

like image 31
Mairbek Khadikov Avatar answered Oct 12 '22 22:10

Mairbek Khadikov


Also checkout Wicket quick-start Maven archetype creation page http://wicket.apache.org/start/quickstart.html

like image 44
Vineet Bhatia Avatar answered Oct 12 '22 23:10

Vineet Bhatia