-
-
Notifications
You must be signed in to change notification settings - Fork 489
Resolve competing web module war definitions
Date | July 7 2020 | Contacts | Jody Garnett |
Status | proposed | Release | 3.12 |
Resources | Ticket # | pending | |
Source code | pending | ||
Funding | GeoCat, GeoNetwork Enterprise and professional services |
The web app contains competing build configurations (for both war:war
and jetty:run
) on the management of schema-plugins leading to build instability.
This proposal refactors web
module structure to resolve this issue.
Initially proposed as a simple change to take advantage public OSGeo repository; this change has shown several limitations of the core-geonetwork build system for schema-plugins:
-
Use of schema-plugin version
3.7
across different branches ofcore-geonetwork
, combined with transitive dependencies, ensure conflicts across active branches ofcore-geonetwork
. -
web app build copies contents folder to folder, rather than make use of schema plugin artifact
zip
andjar
. -
web app contains competing build configurations (for both
war:war
andjetty:run
) on the management of schema-plugins leading to build instability
The above limitations result in an unstable build environment.
References:
For this discussion keep in mind the maven build life cycle (common steps in italic, default war
stages described):
- validate
- initialize
- generate-sources
- process-sources
- generate-resources
- process-resources - resources:resource goal
- compile - compiler:compile goal
- process-classes
- generate-test-sources
- process-test-sources
- generate-test-resources
- process-test-resources - resources:testResources goal
- test-compile - compiler:testCompile goal
- process-test-classes
- test - surefire:test goal
- prepare-package
- package - war:war goal
- pre-integration-test
- integration-test
- post-integration-test
- verify
- install - install:install goal
- deploy - deploy:deploy goal
Each pom packaging type (pom
, jar,
war, ...) registers maven plugins to specific stages of the maven life cycle, along with appropriate plugin configuration. As an example war
plugin configuration defines a default assembly
definition that includes src/webapp
.
References:
- http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
- https://maven.apache.org/plugins/maven-war-plugin/index.html
- http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
The web
module has quite a complex build chain.
See web/README.md for original research shown above.
The war
packaging for the module defines several src
folders:
-
src/main/java
Define Geonetwork and other classes (compiled into
target/classes
) -
src/main/resources
Define resources (compiled into
target/classes
) -
src/webapp
Static outline of war contents.
-
conversion
-
doc
-
htmlCache
-
images
-
loc
- translations -
resources
-
WEB-INF
web.xml
-
xml
-
xsl
-
xslt
-
geonetwork.css
-
modalbox.css
-
The build generate
-
src/main/filters
Used to process
webResources
intotarget/webapp
-
src/webResources
WEB-INF
Content processed into
target/webapp
The generate-sources
registers two additional src folders:
-
src/main/java
- add-src folder containingGeonetwork
class -
src/webapp/main/webapp/WEB-INF/classes/setup/sql/migrate
- add-src folder for sql migration
The process-resources
stages content into:
-
src/main/webapp/WEB-INF/data/config/schema_plugins
Collected from schema
plugin
content -
src/webapp/doc
- from documentation manuals -
target/webapp
Copy filter
src/main/webResource
based on env configuration
The compile
stage builds:
-
target/classes
- fromjava
andresources
The maven-war-plugin
generates jar
:
-
target/geonetwork/WEB-INF/lib/web-app-3.11.0-SNAPSHOT.jar
Containing:
-
src/main/java
compiled classes -
src/main/resources
contents -
src/webapp/main/webapp/WEB-INF/classes/setup/sql/migrate
compiled classesThis is unusual having java source code in
src/webapp
!
-
The maven-war-plugin
generates war
structure into target/geonetwork
:
catalog
conversion
doc
htmlCache
images
loc
META-INF
resources
WEB-INF
xml
xsl
xslt
modalbox.css
geonetwork.css
Where content is collected from:
-
target/geonetwork
:src/main/webapp
files -
target/geonetwork
:target/webapp
files that have been processed -
target/geonetwork
:../web-ui/src/main/resources
files -
target/geonetwork/WEB-INF/data/config/schema_plugins
:../schemas
files from eachplugin
folder -
target/geonetwork/WEB-INF/lib/
: maven dependencies -
with many excludes ...
xml/schemas/
WEB-INF/data/*.db
WEB-INF/data/index/**
- ...
These appear to be a safety measure to avoid including files produced when
src/main/webapp
is used as a live directory byjetty
below.
The jetty-maven-plugin
defines web application using:
- maven dependencies
target/geonetwork
src/main/webapp
../web-ui/src/main/resources/
target/webapp
-
jett-context.xml
: used to prevent jetty scanning jars during startup
Observations:
-
This configuration has been setup to use the "live"
src/main/webapp
location and pick up any changes each timemvn process-resources
is called above. -
schemas plugin folders are included twice:
- in
target/geonetwork
via war definition - in
src/main/webapp/
via process-resource copy
- in
-
jars are included twice:
-
target/geonetwork
libs folder - as maven dependency
-
migrate
: package database migration in a separate module
src/main/java
src/main/resources
web
:
-
src/assembly
- custom war assembly to include license and avoid accidentally packaging contents -
src/main/filters
- site specific presets used to modifysrc/main/webapp
contents src/main/java
src/main/resources
src/main/webapp
src/main/data
src/webapp
test/java/org/fao/geonet/Start.jar
test/resources/jetty-context.xml
target/classes
target/doc
target/data/
target/data/config/schema_plugins
-
target/schemas
- schema plugins updated bymvn process-resources
-
target/webapp
- generated webapp contents - jars managed as dependencies
What is not included:
target/geonetwork
This approach:
- Completely defines the
war
usingsrc
,target
and maven dependencies for jars. - Does not copy, or include, content across modules or directories.
- Reservers
target/geonetwork
for the default use ofwar
packaging andjetty:run-war
testing.
- Type: Improvement to existing feature
- Module: schema plugins, metadata101, webapp, root
-
Vote Proposed: TBA
- @jodygarentt
If you have some comments, start a discussion, raise an issue or use one of our other communication channels to talk to us.