How to set up NWDS or Eclipse without MDK
Every person has its own way of setting up its developement environment. There is no ideal set up, but some are easier to maintain than others.
Mobile Development Kit has some useful features such as precompiling JSPs and building a WAR file for you, but it is slow when it comes to development cycles. Over my years at SAP, I understood that a couple of Ant scripts and a well set up Eclipse can be really more powerful than the MDK. Here is how!
- Before starting to create your project, you have to install your development Mobile Infrastructure folder. I install it directly in the C:/. You can even create a backup copy to avoid reinstallation. After, you have to register that MI installation with the middleware and install the relevant applications (you have to do this because your application must be registered with the middleware to sync and appear on the MI homepage). Once this is done you can create your project.
- When you receive code from SAP (in this case a mobile application ie. MAM), you should never directly change code from it. You should use the enhancement concepts to make your changes. So you should completly separate the sources in different folders. I suggest you keep the folder structure align between SAP and your own code on your disk before making that structure available to Eclipse. It will be easier for you afterward and it will be easier to set up your source control system. Let's make the structure like this one:
- Foo Project
- config
- SAP Code
- source
- webapps
- FOO
- Code
- source
- webapps
- FOO
- Foo Project
- Now you can create a project in Eclipse. To create a project, use the File > New > Project... and chose a "Java Project". Give a meaningful name to the project: "Foo Guimont". You also have to include the related libraries and all other stuff your project requires. Don't forget to have a different output folder for your classes (otherwise both .java and .class will be mixed in one place, I guess I like to have organized stuff).

Project Creation

Folder creation
- Link your project to your folder structure. To do so, chose File > New > Folder... In the wizard, give a name to the folder (I strongly suggest the same names as before) and click Advanced to link the newly create folder the real folder on the disk. Repeat this for "config", "SAP Code" and "Code" folder (all the subfolder will be automaticaly linked). You can also link your MI webapp folder for easy debugging.
You are halfway done! We still have to create the build phase and the run target for your project. - To create the build phase, you first have to create a new "build.xml" Ant file. Create a new file in the config folder and name it "buildphase.xml". Copy the following Ant source:
<project name="package" default="copywebapp" basedir="."> <property name="sap_dir"/> <property name="code_dir"/> <property name="mi_dir"/> <property name="project"/> <property name="project_mi" value="${project}"/> <target name="copywebapp" description="Copy the webapp files to the right place in MI"> <mkdir dir="${mi_dir}/webapps/${project_mi}"/> <copy todir="${mi_dir}/webapps/${project_mi}"> <fileset dir="${sap_dir}/webapps/${project}"/> <fileset dir="${code_dir}/webapps/${project}"/> </copy> </target> </project>
You will be able to configure the script with the properties in Eclipse build phase editor. Let's take a look... - Go in Project > Properties... menu item and click on the item "Builders" then create a new Ant builder.

Give a name to the builder : "Move webapps". Select "buildphase.xml" Ant file as the buildfile. Go to the Properties tab and enter your project properties like this:

This builder will be called everytime you trigger a build for that project. The files will only be copied if you changed them so it is fairly fast. Eclipse takes care of moving your file to your MI folder so you are sure that what you have in there is the latest code. As you saw, only the webapps folder is copied. This is because the classes and libraries do not need to be in MI folder as long as they are loaded in the classpath in the Run Target. - Create your run target. Go Run > Run... menu and in the wizard create a "Java Application" run configuration for your project. Use the main class "com.sap.ip.me.core.FrameworkInitializer" (you have to include the libraries to be able to chose this class). In the "Arguments" tab write the following "-home:C:/MIFolder" (put your "MIFolder" name!).
Now you are ready to go! Hit the Run button and the build will be triggered, the webapp files will be copied and your application will be launched within MI. Point your browser to http://localhost:4444/ and you should see it running.
I hope this post can be useful for some of you who asked questions about this. I a next entry I will talk about setting up a Ant build to create the complete deployable War file with precompiled JSP.