Wiki source code of Embedding WOFrameworks

Version 34.1 by David Holt on 2009/09/02 11:20

Hide last authors
David Holt 33.1 1 == WOLips 3.4.x, and later, Side-note ==
2
3 {{warning}}
4 If you are updating an older project, make sure you get the latest build.xml file. Create a new project, then copy/paste the contents of the fresh build.xml file into your project's build.xml file.
5 {{/warning}}
6
7 For WOLips 3.4.x and later, while embedding is built-in, it's not enabled by default. To enable embedding:
8
9 * make sure you are in the WO Explorer view
10 * right-click your project folder, select Properties, select WOLips Deployment
11 * check the related, if not all, options under Embed Frameworks
12
13 To create a versioned/dated bundle of your app and resources:
14
15 * make sure you are in the Navigator view
16 * edit build.properties, and add:
17 * ##build.app.name=MyApp-2009-07-14##
18
19 There is a known bug with WO 5.4.x (for those not using the latest Wonder release) regarding proper linking to your web server resources within the embedded frameworks. The WOFrameworksBaseURL isn't set correctly. To do this you'll need to programmatically set this within your Application constructor:
20
21 * ##setFrameworksBaseURL("/WebObjects/MyApp-2009-07-14.woa/Frameworks");##
22
23 Within build.properties (I may need to be corrected on this), the best approach to linking your embedded framework's web server resources automatically is to include (however the bug noted above breaks this):
24
25 * ##frameworksBaseURL=/WebObjects/$build.app.name.woa/Frameworks##
26
27 And finally, there is a bug in the build.xml file that you may need to clean-up:
28 [[http://issues.objectstyle.org/jira/browse/WOL-979]]
29
Kieran Kelleher 31.1 30 == Introduction ==
31
David Holt 33.1 32 Below is outlined "simple embedding" concepts, however __full embedding__ **and** __split-installing__ are really recommended. This provides fully versioned self-contained bundles of both the application deployment bundle and the webserver deployment bundle. Read the docs on that technique for more **advantages**. This technique fully explained along with a ready-to-use ant build script is available at:
Kieran Kelleher 31.1 33
34 [[Alternative Ant Build Script for Fully Embedded and Split Install Bundles]]
35
Kieran Kelleher 27.1 36 == Simple Approach ==
37
38 This simple approach can be used to embed frameworks already **installed** on your development machine right into the app.woa bundle.
39
40 Open your build.xml project file and change embed="false" to embed="true" for the appropriate directory paths in this section of the build.xml file inside the woapplication task
41
42 {{code title="Default build.xml snippet"}}
43
Kieran Kelleher 29.1 44 <frameworks root="${wo.wolocalroot}" embed="false">
45 <patternset>
46 <includesfile name="woproject/ant.frameworks.wo.wolocalroot" />
47 </patternset>
48 </frameworks>
49 <frameworks root="${user.home}" embed="false">
50 <patternset>
51 <includesfile name="woproject/ant.frameworks.user.home" />
52 </patternset>
53 </frameworks>
54 <frameworks root="${wo.wosystemroot}" embed="false">
55 <patternset>
56 <includesfile name="woproject/ant.frameworks.wo.wosystemroot" />
57 </patternset>
58 </frameworks>
Kieran Kelleher 27.1 59
60 {{/code}}
61
62 The most common choice is to embed locally installed WOnder and 3rd party frameworks that your app references by setting embed="true" on the wolocalroot frameworks dir as shown below:
63
64 {{code title="Changes to build.xml to embed frameworks installed in /Library/Frameworks dir"}}
65
Kieran Kelleher 29.1 66 <frameworks root="${wo.wolocalroot}" embed="true">
67 <patternset>
68 <includesfile name="woproject/ant.frameworks.wo.wolocalroot" />
69 </patternset>
70 </frameworks>
71 <frameworks root="${user.home}" embed="false">
72 <patternset>
73 <includesfile name="woproject/ant.frameworks.user.home" />
74 </patternset>
75 </frameworks>
76 <frameworks root="${wo.wosystemroot}" embed="false">
77 <patternset>
78 <includesfile name="woproject/ant.frameworks.wo.wosystemroot" />
79 </patternset>
80 </frameworks>
Kieran Kelleher 27.1 81
82 {{/code}}
83
84 The various dirs referenced in the build.xml from which you can select the embed option are:
85
Kieran Kelleher 29.1 86 |= dir name |= Description
87 | wo.wolocalroot | /Library/Frameworks/
88 \\Embedding these is most useful especially if you the codebase for these, like WOnder frameworks or your own, is frequently updated
89 | user.home | /Library/Frameworks/
90 | wo.systemroot | /System/Library/Frameworks/
91 \\This is where Apple's WebObjects frameworks are installed and if your WebObjects version is consistent between your deployment and development platforms, then embedding these is not of much benefit.
Kieran Kelleher 27.1 92
Kieran Kelleher 29.1 93 {{note title="Remember to..." bgColor="#FFFFCE"}}
Kieran Kelleher 27.1 94
Kieran Kelleher 29.1 95 If you are working with framework source in your Eclipse workspace (which you should be\!), then it is critical that you build and install all frameworks before building the deployment bundles to ensure that the embedded frameworks are the same as the source you have been developing and testing with. See next subsection for one approcah to automating this.
Kieran Kelleher 27.1 96
Kieran Kelleher 29.1 97 {{/note}}
Kieran Kelleher 27.1 98
Kieran Kelleher 29.1 99 === Pre-installing Workspace Frameworks Before Embedded Build ===
100
101 You could write a task to install the frameworks directly from the workspace, for example:
102
103 {{code}}
104
105 <!-- Install my own dependent frameworks in final local install location before embedding -->
106 <target name="installMyFrameworks">
107 <ant dir="../WKDemography" target="install" inheritall="false" />
108 <ant dir="../WKEmailData" target="install" inheritall="false" />
109 <ant dir="../WKEOFExtensions" target="install" inheritall="false" />
110 <ant dir="../WKFoundation" target="install" inheritall="false" />
111 <ant dir="../WKPrototypes" target="install" inheritall="false" />
112 <ant dir="../WKRemoteClient" target="install" inheritall="false" />
113 <ant dir="../WKReports" target="install" inheritall="false" />
114 <ant dir="../WKWebObjects" target="install" inheritall="false" />
115 </target>
116
117 {{/code}}
118
119 ... and then you could put a depends attribute on the build target to ensure the frameworks are installed before the embedded build task is executed:
120
121 {{code}}
122
123 <target name="build.woapp" depends="installMyFrameworks">
124
125 {{/code}}
126
Kieran Kelleher 27.1 127 == Advanced Approach ==
128
David Holt 19.1 129 **Caveat:** This example assumes that each framework you want to embed has an ant "build.xml" file with a "compileAndBuild" target. For frameworks you create yourself using WOLips, you will have this, but for a case where you are checking out individual Wonder framework projects from CVS, then you probably will not have such a build.xml file, so this approach is not quick to implement in that case unless you want to spend a lot of time working on ant build files to resolve the missing build.xml having a compileAndBuild target for those external projects. (KK 3/30/2007)
130
131 ----
132
133 See also [[FrameworkSet>>WOProject-FrameworkSet]] documentation.
134
135 Example for embedding WOFrameworks.
136
137 It's often a good idea to create your own targets in the build.xml or even create your own build.xml (with a different name). This leaves the door open for an update of the default build.xml.
138
139 Assume two projects: One named Foo( a framework) and the other named Uli (an application). The parent folder has another folder named packandgo.
140
141 [[image:Folders.png]]
142
143 The [[^packageandgobuild.xml]] from the application. Two minor changes to the default build.xml:
144 1 application target
145
146 {{code}}
147
148 <!-- package and go example-->
149 <frameworks root="../packageandgo/frameworks" embed="true">
150 <include name="*.framework"/>
151 </frameworks>
152
153 {{/code}}
154
155 2 compile target
156
157 {{code}}
158
159 <!-- package and go example-->
160 <fileset dir="../packageandgo/frameworks">
161 <include name = "**/*.jar"/>
162 </fileset>
163
164 {{/code}}
165
166 The [[^build.xml]] from the packageandgo folder:
167
168 Just invoke ant in the packageandgo folder and grap the App from the applications folder within the packageandgo folder.
169
170 [[image:FoldersAfterBuild.png]]