Änderungen von Dokument Plugin-Entwicklung


Von Version 13.1
bearbeitet von awa
am 04.12.2022, 00:47
Änderungskommentar: Löschung des Anhangs README.md
Auf Version 15.1
bearbeitet von awa
am 04.12.2022, 00:49
Änderungskommentar: Neuen Anhang README-FC-SERVER.md hochladen

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -314,5 +314,5 @@
314 314  
315 315  Dies funktioniert auch in einem Ordner ohne Maven-Projekt. Falls keine {{formcycle/}}-Version angegeben ist, wird eine Standard-Version genommen, abhängig von der Maven-Plugin-Version.
316 316  
317 -Für fortgeschrittenen Gebrauch siehe die [[README.md>>attach:README.md||rel="__blank"]].
317 +Für fortgeschrittenen Gebrauch siehe die [[README.md>>attach:README-FC-SERVER.md||rel="__blank"]].
318 318  
README-FC-SERVER.md
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.awa
Größe
... ... @@ -1,0 +1,1 @@
1 +15.1 KB
Inhalt
... ... @@ -1,0 +1,495 @@
1 +Maven plugin for starting a FORMCYCLE server, similar to the Jetty maven plugin, but initializes the FORMCYCLE application.
2 +
3 +## TL;DR
4 +
5 +Version 8:
6 +
7 +```bash
8 +# Standalone
9 +mvn de.xima.fc.maven.plugin:fc-server-maven-plugin:8.0.0:ms -DxfcVersion=8.0.4
10 +
11 +# FORMCYCLE plugin project
12 +mvn fc-server:run-ms-war
13 +```
14 +
15 +Version 7:
16 +
17 +> mvn de.xima.fc.maven.plugin:fc-server-maven-plugin:7.0.4:ms -DxfcVersion=7.0.16
18 +
19 +## Versioning
20 +
21 +* The major and minor version are always equal to the FORMCYCLE major version against which the project was built.
22 +* The patch version is for the plugin.
23 +
24 +## Terms
25 +
26 +A "FORMCYCLE plugin project" is Maven project packaged as a fat jar, with a (possibly transitive)
27 +compile dependency on `de.xima.fc:fc-plugin-common` in the `provided` scope.
28 +
29 +A Maven project "packaged as a fat jar" is Maven project with its `packaging` set to `jar` and
30 +that includes a plugin execution for either the `maven-assembly-plugin` or the `maven-shade-plugin`.
31 +
32 +## Goals
33 +
34 +See the site above for more in-depth info.
35 +
36 +* `ms` Intended for use as a command line tool to start a server without a Maven project:
37 + `mvn fc-server:ms`.
38 +* `run-ms-war` Intended for use as a command line tool to start a server on an existing
39 + [FORMCYCLE plugin project](#terms): `mvn fc-server:ms`.
40 +* `start-ms-war` Goal for integration into an existing lifecycle defined in a pom.xml, should be
41 + bound to a particular phase. Does not block by default.
42 +
43 +## Usage
44 +
45 +This is a Maven plugin with several goals. You can run it via the command line:
46 +
47 +```bash
48 +# When you have no Maven project
49 +mvn fc-server:ms
50 +
51 +# When you have an existing FORMYCLE plugin project
52 +mvn fc-server:run-ms-war
53 +```
54 +
55 +If the command is run from within an existing Maven project, it first packages the project, then starts the server and finally (if `-DdeployMavenProject=true` is set), installs the main artifact file of the Mavne project automatically into the started FORMCYCLE instance.
56 +
57 +The first command can be used in a directory without a Maven project.
58 +
59 +If the second command is run on an existing [FORMCYCLE plugin project](#terms), it first packages that project, then
60 +starts the server and finally installs the main artifact file of the Maven project automatically into the started
61 +FORMCYCLE instance.
62 +
63 +If Maven cannot find the plugin or you need to run a specific version of the plugin, you have to use the full coordinates:
64 +
65 +> mvn de.xima.fc.maven.plugin:fc-server-maven-plugin:8.0.0-SNAPSHOT:run-ms-war
66 +
67 +To get Maven to find the plugin without the full name, either add the plugin to `<plugin>` section of your `pom.xml` or add the following to the `~/.m2/settings.xml`:
68 +
69 +```xml
70 +<settings>
71 + <pluginGroups>
72 + <pluginGroup>de.xima.fc.maven.plugin</pluginGroup>
73 + </pluginGroups>
74 +</settings>
75 +```
76 +
77 +If you want to configure the plugin, you can do so via a `<plugin>` section in the `pom.xml`. See the
78 +site above for documentation. Below are some example configurations.
79 +
80 +### Use a different FORMCYCLE version
81 +
82 +The FORMCYCLE version defaults to the version against which the version of the plugin was built. The plugin major and minor version always follow the FORMCYCLE version, e.g. plugin version 7.0.9 will default to some `7.0.x` release of FORMCYCLE.
83 +
84 +To set the version of the FORMCYCLE app:
85 +
86 +```xml
87 +<plugin>
88 + <groupId>de.xima.fc.maven.plugin</groupId>
89 + <artifactId>fc-server-maven-plugin</artifactId>
90 + <version>${fc-server-maven-plugin.version}</version>
91 + <configuration>
92 + <xfcVersion>7.0.7</xfcVersion>
93 + </configuration>
94 +</plugin>
95 +```
96 +
97 +Note that you can also use:
98 +
99 +> mvn fc-server:ms -DxfcVersion=7.0.7
100 +
101 +You may have to use a different version of the plugin for older FC versions (major and minor plugin version always follow the FC version)
102 +
103 +> mvn de.xima.fc.maven.plugin:fc-server-maven-plugin:7.0.4:ms -DxfcVersion=7.0.16
104 +
105 +### Use a custom FORMCYCLE war file
106 +
107 +If you need to, you can also use a custom FORMCYCLE WAR file, e.g. a local build etc.
108 +
109 +
110 +```xml
111 +<plugin>
112 + <groupId>de.xima.fc.maven.plugin</groupId>
113 + <artifactId>fc-server-maven-plugin</artifactId>
114 + <version>${fc-server-maven-plugin.version}</version>
115 + <configuration>
116 + <warFile>/path/to/formcycle.war</warFile>
117 + </configuration>
118 +</plugin>
119 +```
120 +
121 +You can also use specify this setting on the command line:
122 +
123 +> mvn fc-server:ms -DwarFile=/path/to/formcycle.war
124 +
125 +### Change servlet container settings
126 +
127 +You can change the server context path and port:
128 +
129 +```xml
130 +<plugin>
131 + <groupId>de.xima.fc.maven.plugin</groupId>
132 + <artifactId>fc-server-maven-plugin</artifactId>
133 + <version>${fc-server-maven-plugin.version}</version>
134 + <configuration>
135 + <contextPath>form-server</contextPath>
136 + <port>8099</port>
137 + </configuration>
138 +</plugin>
139 +```
140 +
141 +You can also use specify these settings on the command line:
142 +
143 +> mvn fc-server:ms -DcontextPath=form-server -Dport=8090
144 +
145 +### Change app persistence directory
146 +
147 +All FORMCYCLE specific data such as the log files, configuration files or temporary files are stored in the application directory in the `target` folder. You can use a different app directory if you want.
148 +
149 +```xml
150 +<plugin>
151 + <groupId>de.xima.fc.maven.plugin</groupId>
152 + <artifactId>fc-server-maven-plugin</artifactId>
153 + <version>${fc-server-maven-plugin.version}</version>
154 + <configuration>
155 + <appDir>${project.basedir}/xfc-server</appDir>
156 + </configuration>
157 +</plugin>
158 +```
159 +
160 +You can also use specify this setting on the command line:
161 +
162 +> mvn fc-server:ms -DappDir=target/apps/xfc-server
163 +
164 +### Use a different servlet container
165 +
166 +By default, Jetty is used, but this can be changed:
167 +
168 +```xml
169 +<plugin>
170 + <groupId>de.xima.fc.maven.plugin</groupId>
171 + <artifactId>fc-server-maven-plugin</artifactId>
172 + <version>${fc-server-maven-plugin.version}</version>
173 + <configuration>
174 + <container>tomcat:9</container>
175 + </configuration>
176 +</plugin>
177 +```
178 +
179 +You can also use specify this setting on the command line:
180 +
181 +> mvn fc-server:ms -Dcontainer=tomcat:9
182 +
183 +By default, supported values are currently
184 +
185 +* `jetty:10` - Jetty Servlet Container Version 10.x
186 +* `tomcat:9` - Apache Tomcat Version 9.x
187 +
188 +To use a custom container, include a `de.xima.servletcontainer.api.IServletContainerProvider` in
189 +the classpath and specify the corresponding name.
190 +
191 +### Use in-memory H2 database
192 +
193 +By default, the H2 database is stored in a file, so the data is persisted when you restart the server. But you can also use an in-memory database:
194 +
195 +```xml
196 +<plugin>
197 + <groupId>de.xima.fc.maven.plugin</groupId>
198 + <artifactId>fc-server-maven-plugin</artifactId>
199 + <version>${fc-server-maven-plugin.version}</version>
200 + <configuration>
201 + <h2Storage>ram</h2Storage>
202 + </configuration>
203 +</plugin>
204 +```
205 +
206 +You can also use specify this setting on the command line:
207 +
208 +> mvn fc-server:ms -Dh2Storage=ram
209 +
210 +### Use a different database
211 +
212 +Include the driver via `dbDrivers` and configure the `database.properties`:
213 +
214 +```xml
215 +<plugin>
216 + <groupId>de.xima.fc.maven.plugin</groupId>
217 + <artifactId>fc-server-maven-plugin</artifactId>
218 + <version>${fc-server-maven-plugin.version}</version>
219 + <configuration>
220 + <dbDrivers>
221 + <dbDriver>postgresql</dbDriver>
222 + </dbDrivers>
223 + <databaseProperties>
224 + <properties>
225 + <property>
226 + <name>db.connection.dbms.shortname</name>
227 + <value>postgresql</value>
228 + </property>
229 + <property>
230 + <name>db.connection.jdbcurl</name>
231 + <value>jdbc:postgresql://localhost:5432/my_database</value>
232 + </property>
233 + <property>
234 + <name>db.connection.login.username</name>
235 + <value>USERNAME</value>
236 + </property>
237 + <property>
238 + <name>db.connection.login.password</name>
239 + <value>PASSWORD</value>
240 + </property>
241 + </properties>
242 + </databaseProperties>
243 + </configuration>
244 +</plugin>
245 +```
246 +
247 +You can also use specify this setting on the command line (separate multiple drivers with a comma):
248 +
249 +> mvn fc-server:ms -DaddDbDrivers=postgresql,h2 -DdbShortname=postgresql -DdbJdbcUrl=jdbc:postgresql://localhost:5432/my_database -DdbUsername=USERNAME -DdbPassword=PASSWORD
250 +
251 +Supported database drivers are
252 +
253 +* `h2`
254 +* `mariadb`
255 +* `mysql`
256 +* `oracle`
257 +* `postgresql`
258 +* `sqlserver`
259 +* `custom` (does not add any driver, add your own driver via `dependencies`)
260 +
261 +### Create default clients
262 +
263 +You can add additional clients to be created when the FORMCYCLE app starts. When the client exists already, it is updated with the configured settings. Clients are identified by their `name`.
264 +
265 +```xml
266 +<plugin>
267 + <groupId>de.xima.fc.maven.plugin</groupId>
268 + <artifactId>fc-server-maven-plugin</artifactId>
269 + <version>${fc-server-maven-plugin.version}</version>
270 + <configuration>
271 + <bootstrap>
272 + <clientManagement>
273 + <!-- Do not create the default client -->
274 + <excludeDefaults>true</excludeDefaults>
275 + <clients>
276 + <!-- Create a default client -->
277 + <client>
278 + <baseSettings>
279 + <name>myforms</name>
280 + <alias>Formular</alias>
281 + <languageTag>de</languageTag>
282 + <baseUrl>http://10.42.42.50/form-server</baseUrl>
283 + <description>Client for testing forms</description>
284 + </baseSettings>
285 + <adminUser>
286 + <userName>awa</userName>
287 + <email>awa@xima.de</email>
288 + <givenName>Andre</givenName>
289 + <lastName>Wachsmuth</lastName>
290 + <password>12345678</password>
291 + </adminUser>
292 + </client>
293 + </clients>
294 + </clientManagement>
295 + </bootstrap>
296 + </configuration>
297 +</plugin>
298 +```
299 +
300 +### Including additional plugins
301 +
302 +You can include additional plugins that should be installed after the FORMYCLE app was started:
303 +
304 +```xml
305 +<plugin>
306 + <groupId>de.xima.fc.maven.plugin</groupId>
307 + <artifactId>fc-server-maven-plugin</artifactId>
308 + <version>${fc-server-maven-plugin.version}</version>
309 + <configuration>
310 + <bootstrap>
311 + <pluginManagement>
312 + <plugins>
313 + <!-- You can specify a Maven coordinate when the plugin is available via Maven -->
314 + <plugin>
315 + <location>de.xima.fc.plugin:fc-plugin-bundle-leitfaden:2.0.22</location>
316 + </plugin>
317 + <!-- You can also specify a local path -->
318 + <plugin>
319 + <location>/path/to/some-plugin.jar</location>
320 + </plugin>
321 + </plugins>
322 + </pluginManagement>
323 + </bootstrap>
324 + </configuration>
325 +</plugin>
326 +```
327 +
328 +You can also use specify this setting on the command line:
329 +
330 +> mvn fc-server:ms -DaddSystemPlugins=de.xima.fc.plugin:fc-plugin-bundle-leitfaden:2.0.22
331 +
332 +Supported plugin sources:
333 +
334 +* Store coordinate:
335 + * `store:/1ce83c47-7b8d-4da8-844e-723cf5e3c426/2.0.7`(no double slash!)
336 + * in general: `store://[itemKey]/[version]/[fileName]?store=[storeKey]&server=[baseUrl]`
337 + * only the `itemKey` and `version` are required
338 +* Maven coordinate
339 + * `-DaddSystemPlugins=de.xima.fc.plugin:fc-plugin-bundle-leitfaden:2.0.22`
340 +* File:
341 + * `-DaddSystemPlugins=/home/user/Downloads/myPlugin.jar`
342 +* URL:
343 + * `-DaddSystemPlugins=https://example.com/plugin.jar`
344 +
345 +### Use a different or no license
346 +
347 +By default, a demo license is used. To use a different license:
348 +
349 +```xml
350 +<plugin>
351 + <groupId>de.xima.fc.maven.plugin</groupId>
352 + <artifactId>fc-server-maven-plugin</artifactId>
353 + <version>${fc-server-maven-plugin.version}</version>
354 + <configuration>
355 + <licenseFile>/path/to/license.lic</licenseFile>
356 + </configuration>
357 +</plugin>
358 +```
359 +
360 +You can also use specify this setting on the command line:
361 +
362 +> mvn fc-server:ms -DlicenseFile=/path/to/license.lic
363 +
364 +Sometimes you may want to start the server without a preinstalled license:
365 +
366 +```xml
367 +<plugin>
368 + <groupId>de.xima.fc.maven.plugin</groupId>
369 + <artifactId>fc-server-maven-plugin</artifactId>
370 + <version>${fc-server-maven-plugin.version}</version>
371 + <configuration>
372 + <licenseFile>builtin:none</licenseFile>
373 + </configuration>
374 +</plugin>
375 +```
376 +
377 +The value for `licenseFile` can be either
378 +* a file path
379 + * `file:/path/to/license.lic`
380 +* a file URI
381 + * `file:/path/to/license.lic`
382 +* a builtin URI:
383 + * `builtin:<name>`
384 + * `builtin:demo` Uses a simple demo license.
385 + * `builtin:none` Uses no license.
386 +
387 +### Deploy current plugin project on startup
388 +
389 +By default, the `run-ms-war` goal checks whether the current Maven project is a
390 +[FORMCYCLE plugin project](#terms). If so, it automatically picks up the main artifact file
391 +of the project and installs the plugin after the FORMCYCLE app was started.
392 +
393 +To configure this behavior, add the following configuration in your pom:
394 +
395 +```xml
396 +<plugin>
397 + <groupId>de.xima.fc.maven.plugin</groupId>
398 + <artifactId>fc-server-maven-plugin</artifactId>
399 + <version>${fc-server-maven-plugin.version}</version>
400 + <configuration>
401 + <deployMavenProject>true</deployMavenProject>
402 + </configuration>
403 +</plugin>
404 +```
405 +
406 +You can also use specify this setting on the command line:
407 +
408 +> mvn fc-server:run-ms-war -DdeployMavenProject=false
409 +
410 +### Include additional dependencies
411 +
412 +Sometimes you may want to include additional dependencies in the classpath, e.g. for custom servlet container
413 +providers or database drivers.
414 +
415 +You can add additional dependencies on a per-execution basis like this:
416 +
417 +```xml
418 +<plugin>
419 + <groupId>de.xima.fc.maven.plugin</groupId>
420 + <artifactId>fc-server-maven-plugin</artifactId>
421 + <version>${fc-server-maven-plugin.version}</version>
422 + <executions>
423 + <execution>
424 + <goals>
425 + <goal>run-ms-war</goal>
426 + </goals>
427 + <phase>package</phase>
428 + <configuration>
429 + <dependencies>
430 + <dependency>
431 + <groupId>com.ibm.db2</groupId>
432 + <artifactId>jcc</artifactId>
433 + <version>11.5.8.0</version>
434 + </dependency>
435 + </dependencies>
436 + </configuration>
437 + </execution>
438 + </executions>
439 +</plugin>
440 +```
441 +
442 +You can also use specify this setting on the command line (separate multiple dependenies with a comma):
443 +
444 +> mvn fc-server:run-ms-war -DaddDependencies=com.ibm.db2:jcc:com.ibm.db2
445 +
446 +### Skip execution for multi-module projects
447 +
448 +By default, the `run-ms-war` goal skips execution when run on a Maven project that is not a
449 +[FORMCYCLE plugin project](#terms). This can be useful e.g. when you have a multi-module project
450 +where only one project is a FORMYCLE plugin. You can then simply invoke `mvn fc-server:run-ms-war`
451 +on the parent project. This builds the entire project until it reaches the FORMCYCE plugin, at which
452 +point it starts the server and installs the built plugin.
453 +
454 +To disable this default behavior, use `-DskipNonPluginProject=false` or use the following configuration in your pom:
455 +
456 +```xml
457 +<plugin>
458 + <groupId>de.xima.fc.maven.plugin</groupId>
459 + <artifactId>fc-server-maven-plugin</artifactId>
460 + <version>${fc-server-maven-plugin.version}</version>
461 + <configuration>
462 + <skipNonPluginProject>true</skipNonPluginProject>
463 + </configuration>
464 +</plugin>
465 +```
466 +
467 +You can also force the execution to be always skipped via the `skip` parameter in your pom:
468 +
469 +
470 +```xml
471 +<plugin>
472 + <groupId>de.xima.fc.maven.plugin</groupId>
473 + <artifactId>fc-server-maven-plugin</artifactId>
474 + <version>${fc-server-maven-plugin.version}</version>
475 + <configuration>
476 + <skip>true</skip>
477 + </configuration>
478 +</plugin>
479 +```
480 +
481 +You can also use specify this setting on the command line:
482 +
483 +> mvn fc-server:run-ms-war -Dskip.fc.server
484 +
485 +### Remote debugging
486 +
487 +To remote debug the the application server, start it with
488 +
489 +> MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 mvn fc-server:ms
490 +
491 +Then attach the debugger to port 1044.
492 +
493 +Note: When you start this goal from within your IDE, you usually do no need to specify this manually
494 +as your IDE will usually attach to the JVM process automatically already.
495 +