Changes for page Quick Start

Last modified by Paul Hoadley on 2025/01/30 02:09

From version 56.1
edited by johnc
on 2009/04/08 20:41
Change comment: Removed -DarchetypeRepository from archetype:generate. Should now be downloaded from the wocommunity repository.
To version 79.1
edited by Paul Hoadley
on 2025/01/30 02:09
Change comment: Updates with JVM options required beyond Java 8.

Summary

Details

Page properties
Parent
... ... @@ -1,0 +1,1 @@
1 +WOL.Home.WOProject-Maven.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.johnc
1 +XWiki.paulh
Content
... ... @@ -1,180 +1,154 @@
1 -== Outline ==
1 +(% class="auto-cursor-target" %)
2 +You should be able to get a "Hello, World!" Wonder application running using [[Maven>>https://maven.apache.org]] in about 10 minutes.
2 2  
3 -{{toc style="disc" indent="20px"}}{{/toc}}
4 +(% id="HAssumptions" class="auto-cursor-target" %)
5 += Assumptions =
4 4  
5 -== Step 1: Installing Maven ==
7 +We're going to make a few assumptions to keep this page brief:
6 6  
7 -Downloading and installing the latest version of [[Maven>>http://maven.apache.org/download]] is the first step to start using this tool.
9 +1. You are running macOS X. You can probably get a WebObjects development environment up on a different OS, but we won't cover that here.
10 +1. You have Java installed. Any version will do. People are running WebObjects on Java 21 in production.
11 +1. You have Eclipse and WOLips installed. Install the [[latest version of Eclipse>>https://www.eclipse.org/downloads/packages/]], along with the [[latest WOLips>>https://github.com/wocommunity/wolips]] if you haven't already.
8 8  
9 -{{tip title="Mac Tip"}}
13 +(% id="HSetup" class="auto-cursor-target" %)
14 += Setup =
10 10  
11 - install macports [http://www.macports.org/install.php], then on the terminal
12 - {noformat}sudo port install maven2{noformat}
16 +(% class="auto-cursor-target" %)
17 +You need to install Maven:
13 13  
14 - In future, to keep this up to date:
15 - {noformat}sudo port upgrade maven2{noformat}
19 +(% class="auto-cursor-target" %)
20 +{{{$ cd ~/Applications
21 +$ curl -O https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip
22 +$ unzip apache-maven-3.9.9-bin.zip
23 +$ ln -s apache-maven-3.9.9 apache-maven
24 +}}}
16 16  
17 -{{/tip}}
26 +Add ##bin## to your path in your shell's startup file, say ##~~/.zshrc##:
18 18  
19 -**NOTE**: It is very helpful if you understand some Maven concepts before continuing with this tutorial. See [[General Maven Documentation]] for more information.
28 +{{{PATH=$PATH:/Users/paulh/Applications/apache-maven-3.9.9/bin
29 +}}}
20 20  
21 -== Step 2: Configuring your Maven Settings ==
31 +(% class="auto-cursor-target" %)
32 +Confirm you have it installed:
22 22  
23 -Before start using Maven, you have to configure it in order to use the plug-ins provided by WOProject. General Maven configuration is made in a settings.xml file. This file can be found in a folder called ##.m2## in each user's home directory (,,/.m2 on Unix systems and C:ocuments and SettingsserNamem2 on Windows). If this file does not yet exist, you can just create it.,,
34 +(% class="auto-cursor-target" %)
35 +{{{$ mvn --version
36 +Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
37 +}}}
24 24  
25 -You have to define the WOProject plug-in group and the repositories to download the plug-ins. The following xml is sufficient to configure maven for using WOProject-maven plugin:
39 +(% class="auto-cursor-target" %)
40 +Finally, add ##~~/.m2/settings.xml##:
26 26  
27 -{{noformat}}
28 -
29 -<settings xmlns="http://maven.apache.org/POM/4.0.0"
30 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
31 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
32 - http://maven.apache.org/xsd/settings-1.0.0.xsd">
33 - <pluginGroups>
34 - <pluginGroup>org.objectstyle.woproject.maven2</pluginGroup>
35 - </pluginGroups>
36 -
37 - <profiles>
38 - <profile>
39 - <id>default</id>
40 - <activation>
41 - <activeByDefault>true</activeByDefault>
42 - </activation>
43 - <repositories>
44 - <repository>
45 - <id>wocommunity.releases</id>
46 - <name>WOCommunity Releases Repository</name>
47 - <url>
48 - http://maven.wocommunity.org/content/groups/public
49 - </url>
50 - <releases>
51 - <enabled>true</enabled>
52 - </releases>
53 - <snapshots>
54 - <enabled>false</enabled>
55 - </snapshots>
56 - </repository>
57 - <repository>
58 - <id>wocommunity.snapshots</id>
59 - <name>WOCommunity Snapshots Repository</name>
60 - <url>
61 - http://maven.wocommunity.org/content/groups/public-snapshots
62 - </url>
63 - <releases>
64 - <enabled>false</enabled>
65 - </releases>
66 - <snapshots>
67 - <enabled>true</enabled>
68 - </snapshots>
69 - </repository>
70 - </repositories>
71 - <pluginRepositories>
72 - <pluginRepository>
73 - <id>wocommunity.releases</id>
74 - <name>WOCommunity Releases Repository</name>
75 - <url>
76 - http://maven.wocommunity.org/content/groups/public
77 - </url>
78 - <releases>
79 - <enabled>true</enabled>
80 - </releases>
81 - <snapshots>
82 - <enabled>false</enabled>
83 - </snapshots>
84 - </pluginRepository>
85 - <pluginRepository>
86 - <id>wocommunity.snapshots</id>
87 - <name>WOCommunity Snapshots Repository</name>
88 - <url>
89 - http://maven.wocommunity.org/content/groups/public-snapshots
90 - </url>
91 - <releases>
92 - <enabled>false</enabled>
93 - </releases>
94 - <snapshots>
95 - <enabled>true</enabled>
96 - </snapshots>
97 - </pluginRepository>
98 - </pluginRepositories>
99 - </profile>
100 - </profiles>
42 +(% class="auto-cursor-target" %)
43 +{{{<settings xmlns="http://maven.apache.org/POM/4.0.0"
44 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
45 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
46 + http://maven.apache.org/xsd/settings-1.0.0.xsd">
47 + <profiles>
48 + <profile>
49 + <id>wocommunity</id>
50 + <activation>
51 + <activeByDefault>true</activeByDefault>
52 + </activation>
53 + <repositories>
54 + <repository>
55 + <id>wocommunity</id>
56 + <url>https://maven.wocommunity.org/content/groups/public/</url>
57 + <releases>
58 + <enabled>true</enabled>
59 + </releases>
60 + <snapshots>
61 + <enabled>true</enabled>
62 + </snapshots>
63 + </repository>
64 + </repositories>
65 + <pluginRepositories>
66 + <pluginRepository>
67 + <id>wocommunity</id>
68 + <url>https://maven.wocommunity.org/content/groups/public/</url>
69 + <releases>
70 + <enabled>true</enabled>
71 + </releases>
72 + <snapshots>
73 + <enabled>false</enabled>
74 + </snapshots>
75 + </pluginRepository>
76 + </pluginRepositories>
77 + </profile>
78 + </profiles>
101 101  </settings>
80 +}}}
102 102  
103 -{{/noformat}}
82 +(% id="HCreateanewapplicationproject" class="auto-cursor-target" %)
83 += Create a new application project =
104 104  
105 -**NOTE**: You can download the complete and most recent settings.xml [[here>>^settings.xml]]. See [[Maven Settings Reference>>http://maven.apache.org/settings.html]] if you want more information about additional options for the settings.xml file.
85 +(% class="auto-cursor-target" %)
86 +Make a new directory somewhere, and run:
106 106  
107 -== Step 3: Installing WebObjects Libraries ==
88 +{{{$ mvn archetype:generate -DarchetypeArtifactId=erxapplication-archetype \
89 + -DarchetypeGroupId=org.wocommunity \
90 + -DarchetypeVersion=3.0 -DaskForDefaultPropertyValues=true}}}
108 108  
109 -Maven takes control of all your project's dependencies. To develop WebObjects applications, Maven has to reference the WebObjects jars. You have to install the WebObjects libraries into your local repository to accomplish this:
92 +(% class="auto-cursor-target" %)
93 +After some downloading, Maven will prompt you:
110 110  
111 -{{noformat}}
95 +(% class="auto-cursor-target" %)
96 +{{{Define value for property 'JavaVersion' 1.8: : 1.8
97 +Define value for property 'WonderVersion' 7.2: : 7.4
98 +Define value for property 'groupId': example.app
99 +Define value for property 'artifactId': Foo
100 +Define value for property 'version' 1.0-SNAPSHOT: : 0.1-SNAPSHOT
101 +Define value for property 'package' example.app: : example.app.foo}}}
112 112  
113 -mvn wobootstrap:install
114 114  
115 -{{/noformat}}
104 +You can enter any version of Java. You should definitely change ##WonderVersion## from 7.2 → 7.4. Hit 'Y' to confirm when requested.
116 116  
117 -**NOTE**: WebObjects must be installed. See the [[maven-wobootstrap-plugin]] documentation for more information. See [[Maven Introduction to Repositories>>http://maven.apache.org/guides/introduction/introduction-to-repositories.html]] if you want more information about Maven repositories.
106 +(% class="box infomessage" %)
107 +(((
108 +If you enter a ##JavaVersion## greater than 1.8 (there are people using Java 21 in production, for example: enter ##21##), you need to add the following line to build.properties:
109 +\\##jvmOptions=~-~-add-exports java.base/sun.security.action=ALL-UNNAMED ~-~-add-exports java.base/sun.util.calendar=ALL-UNNAMED##
110 +)))
118 118  
119 -{{warning title="Installing the right jars!"}}
120 120  
121 -Do *not* link to or install the WebObjects jars located inside {{/System/Library/Frameworks}} or {{/Library/Frameworks}}. If you're installing an older version of WebObjects you must obtain the jars that the WebObjects installer had previously installed into {{/Library/WebObjects/lib}}. For example, the jar {{/Library/WebObjects/lib/JavaWebObjects.jar}} has the complete set of resources and files included for the dependency JavaWebObjects whereas {{/System/Library/Frameworks/JavaWebObjects.framework/Resources/Java/javawebobjects.jar}} does not.
113 +(% id="HBuildandlaunchtheapplication" class="auto-cursor-target" %)
114 += Build and launch the application =
122 122  
123 -{{/warning}}
116 +(% class="auto-cursor-target" %)
117 +From the same directory, run:
124 124  
125 -== Step 4: Creating a WebObjects Project ==
119 +(% class="auto-cursor-target" %)
120 +{{{$ cd Foo
121 +$ mvn package}}}
126 126  
127 -Archetypes are the fast way to create a new project using Maven. WOProject provides one archetype to create WebObjects Application. Execute the following command to generate a basic WebObjects project:
123 +(% class="auto-cursor-target" %)
124 +Once Maven has finished building, you can launch:
128 128  
129 -{{noformat}}
126 +(% class="auto-cursor-target" %)
127 +{{{$ ./target/Foo.woa/Foo}}}
130 130  
131 -mvn archetype:generate -DarchetypeArtifactId=woapplication-archetype \
132 - -DarchetypeGroupId=org.objectstyle.woproject.maven2 \
133 - -DarchetypeVersion=2.0.16
129 +(% class="auto-cursor-target" %)
130 +A browser should open and show:
134 134  
135 -{{/noformat}}
132 +>Hello WOnder world!
136 136  
137 -The maven-archetype-plugin will ask the required information to create the new project.
134 +(% id="HImportyourprojectintoEclipse" class="auto-cursor-target" %)
135 += Import your project into Eclipse =
138 138  
139 -**NOTE**: You can use archetype catalogs to reduce the number of properties to set while creating a project. See the documentation of [[woapplication-archetype]].
137 +(% class="auto-cursor-target" %)
138 +A final, optional step is to bring the project into Eclipse.
140 140  
141 -**NOTE**: You can use archetypes within Eclipse as described [[here>>Maven Create WO Application Project||anchor="m2eclipse"]].
140 +1. File > Import... > Maven > Existing Maven Projects
141 +1. Using the file browser, find the top-level "Foo" folder containing the project you created above, click Open.
142 +1. Ensure ##pom.xml## is checked and click Finish.
142 142  
143 -== Step 5: Importing the Project into Eclipse ==
144 +(% class="box infomessage" %)
145 +(((
146 +As above, if you're using Java beyond Java 8, you need to add the following to the launch configuration under Arguments > VM arguments:
147 +\\##~-~-add-exports java.base/sun.security.action=ALL-UNNAMED ~-~-add-exports java.base/sun.util.calendar=ALL-UNNAMED##
148 +)))
144 144  
145 -The new project is ready to be imported into Eclipse workspace. Use the Eclipse's import wizard (File > Import...) and choose the option "Existing Projects into Workspace". Select the root directory of your new project and finish the import wizard.
146 146  
147 -{{note title="Warning"}}
148 148  
149 -As Maven takes care of the dependency management, you must use a mechanism to add the jars to your Eclipse build path. There are 3 options:
150 -# Use the [mvn eclipse:eclipse|http://maven.apache.org/plugins/maven-eclipse-plugin/] goal to update your .classpath file.
151 -# Use the [m2eclipse|http://m2eclipse.codehaus.org/] plug-in for Eclipse.
152 -# Use the [q4e|http://code.google.com/p/q4e/] plug-in for Eclipse.
153 153  
154 -{{/note}}
155 -
156 -After adding the project dependencies to your Eclipse build path, WOLips can build the project and you will be able to start developing and running the application.
157 -
158 -**NOTE**: This tutorial assumes you have chosen the option 2. You can find more information about IDE integration [[here>>General Maven Documentation||anchor="IDE Integration"]].
159 -
160 -== Step 6: Building WebObjects Applications with Maven ==
161 -
162 -Now, building your project with Maven is easy. Go to the project folder on Terminal and execute:
163 -
164 -{{noformat}}
165 -
166 -mvn clean package
167 -
168 -{{/noformat}}
169 -
170 -This goal will generate a WOA package inside the target folder of your project. It also generates two compressed packages: one for woapplication and other for the webserver resources.
171 -
172 -To install your project into your local repository:
173 -
174 -{{noformat}}
175 -
176 -mvn clean install
177 -
178 -{{/noformat}}
179 -
180 -This will install your project into ##,,/.m2/repository/your/project/groupId/artifactId/version/...,,##
153 +(% class="auto-cursor-target" %)
154 +You're done.