At line 1 changed 1 line. |
[AppFuse], by default, is configured to be an [Eclipse|http://www.eclipse.org] project. When you run __ant new -Dapp.name=''yourApp'' -Ddb.name=''yourDatabase''__ you will get the .project and .classpath files to start your project with. However, you will need to make a few setting changes in Eclipse to run [Ant|http://jakarta.apache.org/ant]. This tutorial shows you how to use Eclipse with AppFuse, but should be applicable to any application based on AppFuse. |
[AppFuse], by default, is configured to be an [Eclipse|http://www.eclipse.org] project. When you run __ant new -Dapp.name=''yourApp'' -Ddb.name=''yourDatabase''__ you will get the .project and .classpath files to start your project with. However, you will need to make a few easy setting changes in Eclipse (particularly to run [Ant|http://jakarta.apache.org/ant]). This tutorial shows you how to use Eclipse with AppFuse, but should be applicable to any application based on AppFuse. |
At line 6 changed 5 lines. |
* [1] Add junit.jar to Ant's classpath |
* [2] Add build.xml to Ant View |
* [3] Run Ant |
* [4] Run JUnit Tests in Eclipse |
* [5] Tips for Debugging and UI Editing |
* [1] Import the project into an Eclipse workspace |
* [2] Add J2EE_HOME to Classpath Variables |
* [3] Add junit.jar to Ant's classpath |
* [4] Add build.xml to Ant View |
* [5] Run Ant |
* [6] Run JUnit Tests in Eclipse |
* [7] Tips for Debugging and UI Editing |
At line 12 changed 27 lines. |
!!Add JUnit to Ant's classpath [#1] |
Adding junit.jar to Ant's classpath is pretty easy. Open Eclipse and go to Window → Preferences. Navigate to Ant → Runtime and you should a window similar to the one below. |
|
[ant-runtime.png] |
|
You will need to add junit.jar to the __additional classpath entry__ in the bottom pane. If you have Ant installed, and junit.jar in it's ''lib'' directory, I'd use that. Otherwise, you can use the junit.jar file in the lib/junit3.8.1 directory. |
|
Note: Sometime between M4 and M7, the layout of the Runtime properties page has changed. Be sure to add junit.jar to the "Ant Home Entries" rather than the "Global Entries". |
|
!!Add build.xml to Ant View [#2] |
Now we need to add the build.xml to Eclipse's Ant View. To do this, go to Window → Show View → Ant. Then click on the first icon in this view (screenshot below) to add AppFuse's build file. |
|
[ant-view.png] |
|
!!Run Ant [#3] |
After adding the build.xml, you should be able to expand it in the Ant View and execute any of the targets. You should make sure that your $J2EE_HOME is set, since AppFuse relies on this. At this point, you should see something similar to the screenshot below. |
|
[ant-targets.png] |
|
!!Run JUnit Tests in Eclipse [#4] |
It's also possible to run your JUnit tests in Eclipse. I should note that if you're running an ActionTest, you'll need to execute "ant deploy-test-war" and then start Tomcat before running them. To configure Eclipse to run AppFuse's JUnit Tests, all you need to do is define a J2EE_HOME variable. To do this, go to Window → Preferences → Java → Classpath Variables. Add a new variable called J2EE_HOME and point it to the location where you have the [J2EE SDK|http://java.sun.com/j2ee/download.html#sdk] installed. AppFuse already has its classpath configured (in the .classpath file) to include J2EE_HOME/lib/j2ee.jar. |
|
Open a test you'd like to run (i.e. UserDaoTest) and go to Run → Debug As → JUnit Test. If this doesn't work, make sure you have AppFuse 1.0.1+ |
|
!!Tips for Debugging and UI Editing [#5] |
For debugging, I use the Tomcat Plugin in Eclipse and set breakpoints. For little changes, I use "ant deploy-web" which only takes a couple of seconds. For truly minor tweaks, it's sometimes easier to edit the file in Tomcat's webapps folder. For major design changes, I usually run the app, view source on a page and save it to a "sandbox" folder in the same directory as my project. Then I do a find/replace and change all "/appfuse/" references to "../web/". This allows me to change CSS and |
JS files and just refresh the file in the sandbox. |
!!Import the project into an Eclipse workspace [#1] |
Open Eclipse (either with an existing or a new workspace) and to go File → Import... and select |