Wiki source code of Embedding WOFrameworks

Version 55.1 by Philippe Rabier on 2011/07/29 18:09

Hide last authors
Philippe Rabier 55.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 Another way to fix this bug is to set the following launch parameter:
24
25 DWOFrameworksBaseURL=/WebObjects/MyApp-2009-07-14.woa/Frameworks
26
27 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):
28
29 * ##frameworksBaseURL=/WebObjects/$build.app.name.woa/Frameworks##
30
31 There was an old bug in the build.xml file but fixed if you have WOLips more recent than october 2010:
32 [[http://issues.objectstyle.org/jira/browse/WOL-979]]
33
34 == Introduction ==
35
36 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:
37
38 [[Alternative Ant Build Script for Fully Embedded and Split Install Bundles]]
39
40 == Simple Approach ==
41
42 This simple approach can be used to embed frameworks already **installed** on your development machine right into the app.woa bundle.
43
44 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
45
46 {{code title="Default build.xml snippet"}}
47
48 <frameworks root="${wo.wolocalroot}" embed="false">
49 <patternset>
50 <includesfile name="woproject/ant.frameworks.wo.wolocalroot" />
51 </patternset>
52 </frameworks>
53 <frameworks root="${user.home}" embed="false">
54 <patternset>
55 <includesfile name="woproject/ant.frameworks.user.home" />
56 </patternset>
57 </frameworks>
58 <frameworks root="${wo.wosystemroot}" embed="false">
59 <patternset>
60 <includesfile name="woproject/ant.frameworks.wo.wosystemroot" />
61 </patternset>
62 </frameworks>
63
64 {{/code}}
65
66 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:
67
68 {{code title="Changes to build.xml to embed frameworks installed in /Library/Frameworks dir"}}
69
70 <frameworks root="${wo.wolocalroot}" embed="true">
71 <patternset>
72 <includesfile name="woproject/ant.frameworks.wo.wolocalroot" />
73 </patternset>
74 </frameworks>
75 <frameworks root="${user.home}" embed="false">
76 <patternset>
77 <includesfile name="woproject/ant.frameworks.user.home" />
78 </patternset>
79 </frameworks>
80 <frameworks root="${wo.wosystemroot}" embed="false">
81 <patternset>
82 <includesfile name="woproject/ant.frameworks.wo.wosystemroot" />
83 </patternset>
84 </frameworks>
85
86 {{/code}}
87
88 The various dirs referenced in the build.xml from which you can select the embed option are:
89
90 |= dir name |= Description
91 | wo.wolocalroot | /Library/Frameworks/
92 \\Embedding these is most useful especially if you the codebase for these, like WOnder frameworks or your own, is frequently updated
93 | user.home | /Library/Frameworks/
94 | wo.systemroot | /System/Library/Frameworks/
95 \\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.
96
97 {{note title="Remember to..." bgColor="#FFFFCE"}}
98
99 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.
100
101 {{/note}}
102
103 === Pre-installing Workspace Frameworks Before Embedded Build ===
104
105 You could write a task to install the frameworks directly from the workspace, for example:
106
107 {{code}}
108
109 <!-- Install my own dependent frameworks in final local install location before embedding -->
110 <target name="installMyFrameworks">
111 <ant dir="../WKDemography" target="install" inheritall="false" />
112 <ant dir="../WKEmailData" target="install" inheritall="false" />
113 <ant dir="../WKEOFExtensions" target="install" inheritall="false" />
114 <ant dir="../WKFoundation" target="install" inheritall="false" />
115 <ant dir="../WKPrototypes" target="install" inheritall="false" />
116 <ant dir="../WKRemoteClient" target="install" inheritall="false" />
117 <ant dir="../WKReports" target="install" inheritall="false" />
118 <ant dir="../WKWebObjects" target="install" inheritall="false" />
119 </target>
120
121 {{/code}}
122
123 ... 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:
124
125 {{code}}
126
127 <target name="build.woapp" depends="installMyFrameworks">
128
129 {{/code}}
130
131 == Advanced Approach ==
132
133 **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)
134
135 ----
136
137 See also [[FrameworkSet>>WOProject-FrameworkSet]] documentation.
138
Ulrich Köster 49.1 139 Example for embedding WOFrameworks.
David Holt 19.1 140
Philippe Rabier 55.1 141 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.
David Holt 19.1 142
143 Assume two projects: One named Foo( a framework) and the other named Uli (an application). The parent folder has another folder named packandgo.
144
Ulrich Köster 53.1 145 [[image:Folders.png]]
146
Ulrich Köster 49.1 147 The [[^packageandgobuild.xml]] from the application. Two minor changes to the default build.xml:
148 1 application target
David Holt 19.1 149
Ulrich Köster 49.1 150 {{code}}
151
Philippe Rabier 55.1 152 <!-- package and go example-->
Ulrich Köster 49.1 153 <frameworks root="../packageandgo/frameworks" embed="true">
154 <include name="*.framework"/>
155 </frameworks>
156
157 {{/code}}
158
Philippe Rabier 55.1 159 2 compile target
Ulrich Köster 49.1 160
161 {{code}}
Philippe Rabier 55.1 162
163 <!-- package and go example-->
Ulrich Köster 49.1 164 <fileset dir="../packageandgo/frameworks">
165 <include name = "**/*.jar"/>
166 </fileset>
167
168 {{/code}}
169
170 The [[^build.xml]] from the packageandgo folder:
171
Philippe Rabier 55.1 172 Just invoke ant in the packageandgo folder and grap the App from the applications folder within the packageandgo folder.
173
174 [[image:FoldersAfterBuild.png]]