diff --git a/add-schema.sh b/add-schema.sh
index 33ea555bd3a..bc253369d49 100755
--- a/add-schema.sh
+++ b/add-schema.sh
@@ -51,18 +51,19 @@ then
echo "Adding schema ${schema} to schemas/pom.xml"
- sed $sedopt "${line} a\\
- ${schema}
- " schemas/pom.xml
+ sed $sedopt -f /dev/stdin schemas/pom.xml << SED_SCRIPT
+ ${line} a\\
+\ ${schema}
+SED_SCRIPT
fi
# Add schema dependency in web/pom.xml
-line=$(grep -n "schema-${schema}" web/pom.xml | cut -d: -f1)
+line=$(grep -m 1 -n "schema-${schema}" web/pom.xml | cut -d: -f1)
if [ ! $line ]
then
- line=$(grep -n 'schema-iso19139' web/pom.xml | cut -d: -f1)
+ line=$(grep -m 1 -n 'schema-iso19139' web/pom.xml | cut -d: -f1)
insertLine=$(($line + 2))
projectGroupId='${project.groupId}'
@@ -70,13 +71,14 @@ then
echo "Adding schema ${schema} dependency to web/pom.xml"
- sed $sedopt "${insertLine} a\\
-\\
-${projectGroupId}\\
-schema-${schema}\\
-${gnSchemasVersion}\\
-
- " web/pom.xml
+ sed $sedopt -f /dev/stdin web/pom.xml << SED_SCRIPT
+ ${insertLine} a\\
+\ \\
+\ ${projectGroupId}\\
+\ schema-${schema}\\
+\ ${gnSchemasVersion}\\
+\
+SED_SCRIPT
fi
@@ -85,18 +87,29 @@ line=$(grep -n "schemas/${schema}/src/main/plugin" web/pom.xml | cut
if [ ! $line ]
then
- line=$(grep -n 'schemas/iso19139/src/main/plugin' web/pom.xml | cut -d: -f1)
- finalLine=$(($line + 3))
+ line=$(grep -n 'schema-iso19139' web/pom.xml | tail -n1 | cut -d: -f1)
+ finalLine=$(($line + 11))
projectBaseDir='${project.basedir}'
baseDir='${basedir}'
echo "Adding schema ${schema} resources to web/pom.xml"
- sed $sedopt "${finalLine} a\\
- \\
- ${projectBaseDir}/../schemas/${schema}/src/main/plugin\\
- ${baseDir}/src/main/webapp/WEB-INF/data/config/schema_plugins\\
-
- " web/pom.xml
+ sed $sedopt -f /dev/stdin web/pom.xml << SED_SCRIPT
+ ${finalLine} a\\
+\ \\
+\ ${projectGroupId}\\
+\ ${schema}\\
+\ ${gnSchemasVersion}\\
+\ jar\\
+\ false\\
+\ ${basedir}/src/main/webapp/WEB-INF/data/config/schema_plugins\\
+\ plugin/**\\
+\ \\
+\ \\
+\ ^plugin/./\\
+\ \\
+\ \\
+\ \\
+SED_SCRIPT
fi
diff --git a/pom.xml b/pom.xml
index c5659193c46..61d0e34e546 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1465,6 +1465,5 @@
1.6.0
4.5.9
3.10-SNAPSHOT
- [3.7,3.11]
diff --git a/schemas/README.md b/schemas/README.md
index 9f9c9311e9d..28440390ec0 100644
--- a/schemas/README.md
+++ b/schemas/README.md
@@ -2,19 +2,20 @@
## Schema Plugin Definition
-#. `src/main/plugin/` plugin contents:
+1. `src/main/plugin/` contents:
- * `schema-ident.xml` configuration file
- * schema definition `xsd` files
- * transformations `xsl` files
- * See [GeoNetwork Manual](https://geonetwork-opensource.org/manuals/trunk/en/customizing-application/implementing-a-schema-plugin.html)
+ * `schema-ident.xml` required configuration file
+ * schema definition `xsd` files
+ * transformations `xsl` files
+
+ See [GeoNetwork Manual](https://geonetwork-opensource.org/manuals/trunk/en/customizing-application/implementing-a-schema-plugin.html)
-#. `src/main/java` providing:
+2. `src/main/java` providing:
* Optional: SchemaPlugin bean
* Optional: ApplicationListener to auto install plugin
-#. Be sure your plugin includes `src/main/plugin`:
+3. Schema plugin `pom.xml` must include `src/main/plugin` in resources section:
```xml
@@ -28,11 +29,40 @@
```
-#. Use `mvn install` to install your schema plugin in your local repository.
+4. If you need to depend on any modules please make use of:
+
+ * `gn.project.version` property for geonetwork modules:
+
+ ```xml
+
+ ${project.groupId}
+ common
+ ${gn.project.version}
+
+ ```
+
+ * `project.version` property for other schemas (or schema-core):
+
+ ```
+
+
+ ${project.groupId}
+ schema-core
+ ${project.version}
+
+
+ ${project.groupId}
+ schema-iso19139
+ ${project.version}
+
+
+ ```
+
+5. Use `mvn install` to install your schema plugin in your local repository.
## Add a plugin to the build
-While schema plugins can be built idependently, they can be conditionally included in the build:
+While schema plugins can be built independently, they can be conditionally included in the build:
1. Add schema plugin:
@@ -40,12 +70,12 @@ While schema plugins can be built idependently, they can be conditionally includ
* As a git submodule if you are making a fork
`
-2. Use a profile (activated by your folder being present) to include your schema plugin to the list of modules in `pom.xml`.
+2. Use a profile (activated by your schema plugin folder being present) to include your schema plugin to the list of modules in `pom.xml`.
```xml
- iso19139.xyz
+ schema-iso19139.xyz
iso19139.xyz
@@ -57,4 +87,6 @@ While schema plugins can be built idependently, they can be conditionally includ
```
+
+3. The `add-schema.sh` script automates these changes.
diff --git a/web/README.md b/web/README.md
index dcf61e46900..6031fd8a261 100644
--- a/web/README.md
+++ b/web/README.md
@@ -76,7 +76,7 @@ If your plugin is not in the `schemas` folder:
mvn process-resources -Pschema-iso19139.xyz
```
-5. Tip: If you commonly work with a set series of plugins you can manage via [settings.xml](https://maven.apache.org/settings.html).
+5. Tip: If work with a set series of plugins you can manage via [settings.xml](https://maven.apache.org/settings.html).
## Including additional schema plugins
@@ -97,7 +97,7 @@ To include your schema plugin in `web/pom.xml`:
${project.groupId}
schema-iso19115-3.2018
- ${gn.schemas.version.range}
+ ${gn.schemas.version}
@@ -116,7 +116,6 @@ To include your schema plugin in `web/pom.xml`:
${project.groupId}
schema-iso19115-3.2018
- ${gn.schemas.version}
jar
false
${basedir}/src/main/webapp/WEB-INF/data/config/schema_plugins
@@ -140,8 +139,8 @@ To include your schema plugin in `web/pom.xml`:
2. This profile example has several interesting features:
* Activates automatically if the `schemas/iso19115-3.2018` folder is present
- * Disabled if `-DcopySchemas=true` property is set
- * Adds a dependency using a version range so that the schema plugin jar is included
+ * Disabled if `-DschemasCopy=true` property is set
+ * Adds a dependency so that the schema plugin jar is included on the classpath
* Unpacks a `plugin` folder into the webapp `schema_plugins` folder
3. Over time we expect active metadata101 schema plugins be listed.
@@ -155,7 +154,7 @@ An alternative approach of copying folders is available using the `-DschemasCopy
To add your schema plugin to the `schemas-copy` profile:
-1. Locate the `schemas-copys` profile in `pom.xml`:
+1. Locate the `schemas-copy` profile in `web/pom.xml`:
2. Add your plugin as a dependency to the profile:
@@ -163,11 +162,13 @@ To add your schema plugin to the `schemas-copy` profile:
${project.groupId}
schema-iso19139.xyz
- ${project.version}
+ ${gn.schemas.version}
```
-3. By default each `src/main/plugin` folder in `schemas` is copied, if your plugin is in a different location:
+3. By default each `src/main/plugin` folder in `schemas` is copied.
+
+ If your plugin is in not in the `schemas` folder:
```xml
@@ -178,3 +179,12 @@ To add your schema plugin to the `schemas-copy` profile:
```
5. This approach modifies `web/pom.xml` so it can only be recommended in a fork or branch.
+
+7. Implementation notes:
+
+ * The `` added here makes use of a specific verion number.
+
+ * If your plugin is inheriting its version number from `schemas/pom.xml` you may use
+ the property `gn.schemas.version`.
+
+6. The `add-schema.sh` script automates these changes.
diff --git a/web/pom.xml b/web/pom.xml
index 6a240e16315..fa29d27e2e4 100644
--- a/web/pom.xml
+++ b/web/pom.xml
@@ -854,7 +854,7 @@
${project.groupId}
schema-iso19115-3.2018
- ${gn.schemas.version.range}
+ ${gn.schemas.version}
@@ -868,12 +868,10 @@
process-resources
unpack
- UTF-8
${project.groupId}
schema-iso19115-3.2018
- ${gn.schemas.version}
jar
false
${basedir}/src/main/webapp/WEB-INF/data/config/schema_plugins