

{note}
In order to follow the instructions of this paragraph you must have Maven installed on your system. The installation of Maven is out of the scope of this guide but you can easily find an extensive documentation about it on Internet.
Another requirement is a good Internet connection (a flat ADSL is enough) because Maven needs to connect to its central repository to download the required dependencies. 
{note}


h3. From Maven to our IDE

Wicket project and its dependencies are managed using Maven. This tool is very useful also when we want to create a new project based on Wicket from scratch. With a couple of shell commands we can generate a new project properly configured and ready to be imported into our favourite IDE.
The main step to create such a project is to run the command which generates project's structure and its artifacts. If we are not familiar with Maven or we simply don't want to type this command by hand, we can use the utility form on Wicket site at "http://wicket.apache.org/start/quickstart.html":http://wicket.apache.org/start/quickstart.html :

!quickstart-webpage.png!

Here we have to specify the root package of our project (GroupId), the project name (ArtifactId) and which version of Wicket we want to use (Version).
Once we have run the resulting command in the OS shell, we will have a new folder with the same name of the project (i.e the ArtifactId). Inside this folder we can find a file called pom.xml. This is the main file used by Maven to manage our project. For example, using “org.wicketTutorial” as GroupId and “MyProject” as ArtifactId, we would obtain the following artifacts:

{code}
 .\MyProject
        |   pom.xml
        |
        \---src
            +---main
            |   +---java
            |   |   \---org
            |   |       \---wicketTutorial
            |   |               HomePage.html
            |   |               HomePage.java
            |   |               WicketApplication.java
            |   |
            |   +---resources
            |   |       log4j.properties
            |   |
            |   \---webapp
            |       \---WEB-INF
            |               web.xml
            |
            \---test
                \---java
                    \---org
                        \---wicketTutorial
                                TestHomePage.java

{code}

Amongst other things, file pom.xml contains a section delimited by tag <dependencies> which declares the dependencies of our project. By default the Maven archetype will add the following Wicket modules as dependencies:

{code:xml}
...
<dependencies>
	<!--  WICKET DEPENDENCIES -->
	<dependency>
		<groupId>org.apache.wicket</groupId>
		<artifactId>wicket-core</artifactId>
		<version>${wicket.version}</version>
	</dependency>
	<dependency>
		<groupId>org.apache.wicket</groupId>
		<artifactId>wicket-ioc</artifactId>
		<version>${wicket.version}</version>
	</dependency>
	<!-- OPTIONAL DEPENDENCY
	<dependency>
		<groupId>org.apache.wicket</groupId>
		<artifactId>wicket-extensions</artifactId>
		<version>${wicket.version}</version>
	</dependency>
	--> 
	...
</dependencies>
...
{code}

If we need to use more Wicket modules or additional libraries, we can add the appropriate XML fragments here.

h3. Importing a Maven project into our IDE

Maven projects can be easily imported into the most popular Java IDEs. However, the procedure needed to do this differs from IDE to IDE. In this paragraph we can find the instructions to import Maven projects into three of the most popular IDEs among Java developers : NetBeans, JetBrains IDEA and Eclipse.

*NetBeans*
Starting from version 6.7, NetBeans includes Maven support, hence we can start it and directly open the folder containing our project:

!netbeans-maven-import.png!

*Intellj IDEA*
Intellj IDEA comes with a Maven importing functionality that can be started under “File/New Project/Import from external model/Maven”. Then, we just have to select the pom.xml file of our project:

!intellj-maven-import.png!

*Eclipse*
If our IDE is Eclipse the import procedure is a little more complex. Before opening the new project we must generate the Eclipse project artifacts running the following command from project root:

{code}
mvn eclipse:eclipse
{code}

  Now to import our project into Eclipse we must create a classpath variable called M2_REPO that must point to your local Maven repository. This can be done selecting “Window/Preferences” and searching for “Classpath Variables”. The folder containing our local Maven repository is usually under our user folder and is called .m2 (for example under Unix system is /home/<myUserName>/.m2/repository):

!eclipse-classpath-variables.png!

Once we have created the classpath variable we can go to “File/Import.../Existing Project into Workspace”, select the directory of the project and press “Finish”:

!eclipse-maven-import.png!

Once the project has been imported into Eclipse, we are free to use our favourite plug-ins to run it or debug it (like for example "run-jetty-run": http://code.google.com/p/run-jetty-run/ ).  

{note}
Please note the option “Copy projects into workspace” in the previous illustration. If we select it, the original project generated with Maven won't be affected by the changes made inside Eclipse because we will work on a copy of it under the current workspace.
{note}

{note}
If we modify the pom.xml file (for example adding further dependencies) we must regenerate project's artifacts and refresh the project (F5 key) to reflect changes into Eclipse.
{note}

h3. Speeding up development with plugins.

Now that we have our project loaded into our IDE we could start coding our components directly by hand. However it would be a shame to not leverage the free and good Wicket plugins available for our IDE. The following is a brief overview of the most widely used plugins for each of the three main IDEs considered so far.

*NetBeans*
NetBeans offers Wicket support through 'NetBeans Plugin for Wicket' hosted at "http://plugins.netbeans.org/plugin/3586/wicket-1-4-support":http://plugins.netbeans.org/plugin/3586/wicket-1-4-support . This plugin is released under CDDL-1.0 license. 
You can  find a nice introduction guide to this plugin at "http://netbeans.org/kb/docs/web/quickstart-webapps-wicket.html":http://netbeans.org/kb/docs/web/quickstart-webapps-wicket.html .

*Intellj IDEA*
For JetBrain IDEA we can use WicketForge plugin, hosted at Google Code "http://code.google.com/p/wicketforge/":http://code.google.com/p/wicketforge/ . The plugin is released under ASF 2.0 license.

*Eclipse*
With Eclipse we can install one of the plugins that supports Wicket. As of the writing of this document, the most popular is probably Qwickie, available in the Eclipse Marketplace and hosted on Google Code at "http://code.google.com/p/qwickie/":http://code.google.com/p/qwickie/ .
QWickie is released under ASF 2.0 license.
