Building Apache MyFaces with IntelliJ IDEA - Step by Step
Prepare maven and the maven-idea-plugin
Download and install maven
Download the current maven version available at http://maven.apache.org
Follow the Installation Instructions on http://maven.apache.org to install maven
Build latest maven-idea-plugin
The latest stable release works for MyFaces, but there is a patch (filed under http://jira.codehaus.org/browse/MPIDEA-48) which enables you to work more naturally with MyFaces in IntelliJ.
For building the patched version of the plugin,
Do a subversion checkout from http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-idea-plugin/
- run
mvn clean install
mvn clean install -Dmaven.test.skip=true
Apply the patch under the link above.
(If you are using TortoiseSVN, right-click your local folder and select TortoiseSVN -> "Apply Patch...". Select the downloaded patchfile. Two new windows are opened. Right-click one of the provided filenames and select "Patch all". Close the window.)
Uncomment the maven-idea-plugin in myfaces-master/maven/master-pom/pom.xml. It should look like this:
<plugin>
<artifactId>maven-idea-plugin</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<jdkLevel>1.3</jdkLevel>
<useClassifiers>true</useClassifiers>
<linkModules>true</linkModules>
<linkModulesExcept>myfaces-shared-core,myfaces-shared-impl,myfaces-shared-tomahawk,myfaces-shared-project</linkModulesExcept>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
Checkout MyFaces and create the IDEA Project with maven
checkout (svn) the myfaces source directory from https://svn.apache.org/repos/asf/myfaces/current
- change into that directory in the console window
- run
mvn clean install
select one of the JDKs in your IntelliJ settings under "JDK & Global Libraries" and remember (or clipboard) the exact name
Note: JDK 1.5.x is not recommended, use a JDK 1.4.x instead- after that run
mvn idea:idea -DjdkName=NAME
- exit the console window and open the newly created project "myfaces-build.ipr" with IntelliJ IDEA
Customize the project
configure the Web-Modules:
add shared-tomahawk-library
- select the tomahawk module
- select the libraries tab
- press add Jar/Directory and select /shared/core/shared-tomahawk/target/myfaces-shared-tomahawk-X-snapshot.jar
- if you want to debug myfaces you should add the sources /shared/core/shared-tomahawk/target/myfaces-shared-tomahawk-X-snapshot-sources.jar
- select the Order/Export tab
- check myfaces-shared-tomahawk-X-snapshot.jar (shared lib will be visible to tomahawk-sandbox as well)
add shared-impl-library
- select the myfaces-impl module
- select the libraries tab
- press add Jar/Directory and select /shared/core/shared-impl/target/myfaces-shared-impl-X-snapshot.jar
- if you want to debug myfaces you should add the sources /shared/core/shared-impl/target/myfaces-shared-impl-X-snapshot-sources.jar
for each of the web-modules (they are listed in the left section of the dialog having a globe as icon)
- select the web-module in the left section of the dialog
- select the tab J2EE Build Settings
- check the checkbox "Create web module exploded directory"
- click on the tab web module settings
- in the top-left drop-down-menu select an application server (most likely tomcat)
Choose an application server for running/debugging and set the application contexts
click on the dropdown left of the "dead" run and debug buttons, and selct "Edit Configurations"
(alternatively you can select Run -> "Edit Configurations" to get the same dialog)- click on the tab "Tomcat Server"
- click on the + Button in the left section of the dialog and choose "Local"
- In the right section of the dialog, in the dropdown next to "Application Server" select "Tomcat"
- In the right section of the dialog select the sub-tab Deployment
- For each web-module:
- click on the module
- check the checkbox "Deploy Web Module" in the right section of the dialog
enter an application-context for the module
Note: the individual modules must have different application context and there can only be one module with the context /
myfaces-example-simple generally is a good one to start with
Click on the run or debug button start the application and test if you can access the examples with your browser (probably under http://localhost:8080/)