Version 35.1 by Kieran Kelleher on 2007/01/16 14:24

Hide last authors
Kieran Kelleher 23.1 1 === Introduction ===
Pascal Robert 15.1 2
Kieran Kelleher 35.1 3 So, you have built the mother of all WebObjects apps in XCode or Eclipse with everything in the default package (or not ;-). The time has come where you want a make a new WebObjects application that re-uses some of the functionality you have already created in bigApp.woa.
Kieran Kelleher 23.1 4 This article explains how to create a framework in Eclipse that can be used with your WebObjects projects. The resulting framework can be used in WOLips or XCode projects. In this example a framework is created that consists of class(es) that were in the default package of a WebObjects application and the 3rd party jar dependencies were originally in /Library/WebObjects/Extensions. The resulting framework bundle will encompass the 3rd party jar and the custom java classes that are moved from the original WO project.
5 Disclaimer: I am still relatively new to Eclipse, so if you see a smarter way to do this, then feel free to edit this wiki page.
Pascal Robert 15.1 6 Also, at the time of writing this article I was using Eclipse 3.2.1 with WOLips build #3769.
7
Kieran Kelleher 23.1 8 === How To ===
Pascal Robert 15.1 9
Kieran Kelleher 35.1 10 ===== Adjust Your Filters =====
Kieran Kelleher 33.1 11
Kieran Kelleher 35.1 12 Before you start, edit your Package Explorer filters so that we can really "see" the files in our project, especially so we can check if our project was created correctly by the wizard later on. To do this simply select Filters from the Package Explorer contextual menu as shown below:
Kieran Kelleher 33.1 13
Kieran Kelleher 35.1 14 ... and then deselect everything except the ones show here. This of course is a user preference, but at least your screen will match my initial project picture shown here if you do as I tell you
Kieran Kelleher 33.1 15
Kieran Kelleher 35.1 16 ===== Create the Framework project in your Eclipse workspace. =====
Pascal Robert 15.1 17
Kieran Kelleher 25.1 18 Right-click in Package Explorer view of the WOLips perspective and select New->Other.
19 [[image:new-project-other.jpg]]
Pascal Robert 15.1 20
21 Next type WO in the filter field and select WOnderFramework from the list and click Next.
Kieran Kelleher 27.1 22 [[image:new-WOnderFramework.jpg]]
Pascal Robert 15.1 23
24 Next enter a project name and click Finish
Kieran Kelleher 27.1 25 [[image:WOnderFramework-projectname.jpg]]
Pascal Robert 15.1 26
Kieran Kelleher 33.1 27 WOLips Bug: If your new framework project DOES NOT look like the one in the picture then you have come across a known elusive WOLips bug that the team is trying to solve. In the case that your project does not look like this, the fix is to select the project and then select the Project->Close in the main menu bar. Afterward select Project->Open and then expand your project and it should be OK.
28
Kieran Kelleher 35.1 29 Another Minor Bug: In the latest build I was using, the default framework project does not contain a folder named 'Components' which it needs to have a successful build later. So just create a new folder in the project named Components. Right-click the project > New > Folder
30 [[image:newComponentsFolder.jpg]]
Kieran Kelleher 33.1 31
Kieran Kelleher 35.1 32 ===== Bundling 2rd Party Jars in your Framework =====
Kieran Kelleher 33.1 33
Kieran Kelleher 35.1 34 Next add any 3rd party jar files to your project that you want bundled with this framework. This is probably the "best practice" way to make 3rd party jars available to your WebObjects apps rather than stuffing them into /Library/WebObjects/Extensions.
35
Kieran Kelleher 33.1 36 To do this simply locate the jar in the Finder and drag and drop it on the Libraries folder in your project as shown here:
37 [[image:dragJarToLibraries.jpg]]
38
Kieran Kelleher 35.1 39 Next, edit the build path so that it sees the classes in this jar. Right-click on the project > Build Path > Configure Build Path.
Kieran Kelleher 33.1 40
Kieran Kelleher 35.1 41 [[image:configureBuildPath.jpg]]
42
Kieran Kelleher 33.1 43 Click on the Libraries tab.
44 Click the Add Jars button and navigate to the jar inside your project.
45 Select the jar and click OK.
46 [[image:buildPath-jarSelection.jpg]]
47
Kieran Kelleher 35.1 48 Adding dependencies on other frameworks can be done at this stage if your wish. The procedure is the same as for adding framework dependencies to a WOApplication which also has a tutorial. Keep in mind that the WOnder Framework wizard adds default framework links which you can adjust and turn off easily (right-click WOFrameworks icon
Kieran Kelleher 33.1 49
50 ===== Now I want to create a package for my reusable classes. =====
51
Kieran Kelleher 35.1 52 Right-click on the Sources folder and select New > Package as shown here:
Kieran Kelleher 33.1 53 [[image:Sources-new-package.jpg]]
54
55 Enter a name for the package and Eclipse automatically creates the appropriate folder structure in the file system:
56 [[image:NewJavaPackage.jpg]]
57
58 ===== Add classes to your package. You can drag java files from the file system or XCode to the package: =====
59
60 [[image:dragClassToPackage.jpg]]
Kieran Kelleher 35.1 61
62 ===== Cleanup Time =====
63
64 Eclipse will check and compile your classes and sprinkle red x's and yellow exclamations on the areas needing your attention. (Isn't Eclipse just great ... intelligent assistance, refactoring, etc.) Anyway go ahead and fix/refactor to fix code problems and resolve dependencies. There is nothing like trying to package a large "default package" app to show you where you have opportunities to clean up dependencies or to show you dependencies you did not realize you had
65 [[image:codeCleanUp.jpg]]
66
67 ===== Install The Framework =====
68
69 Building and/or installing is the same as for WOApplications in Eclipse
70 [[image:installFramework.jpg]]