diff --git a/.gitignore b/.gitignore index ad51c41df864275930ecb96fa6433bba3823c5e1..0efe793b666a005b665be120a32db0150a920249 100755 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ jboss/ /.idea/ .vscode/settings.json .settings/org.eclipse.core.resources.prefs +pom_with_models.xml diff --git a/README.md b/README.md index 9a6fa8a66e9630572a507933084d17cb7dd7c138..80c1300b5dba8f25bc5dc5ba955c280b259cc34b 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ or on Windows $ mvnw.cmd clean install ``` +**PLEASE NOTE that this builds the package without any models. See "Adding models" below for more information** + Download and install [WildFly](https://www.wildfly.org/) >= 25.0.1 Deploy the build from this project in Wildfly. @@ -33,36 +35,22 @@ Deploy the build from this project in Wildfly. Wildfly should run on Java >= 11 ### Adding models -To add models, create this folder in WildFly: -`[WILDFLY_ROOT]/modules/no/nibio/vips/modelcontainer/main/` -Add the model jar file, and edit module.xml accordingly. - -``` xml -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - © 2019 NIBIO - Author: Tor-Einar Skog <tor-einar.skog@nibio.no> - --> - -<module xmlns="urn:jboss:module:1.1" name="no.nibio.vips.modelcontainer"> - <resources> - <resource-root path="PsilaRosaeTempModel-1.0-SNAPSHOT.jar"/> - </resources> - <dependencies> - <module name="no.nibio.vips.VIPSCommon" export="false"/> - <module name="com.fasterxml.jackson.core.jackson-core" export="false"/> - <module name="com.fasterxml.jackson.core.jackson-databind" export="false"/> - <module name="com.vividsolutions.jts" export="false"/> - <module name="org.renjin" export="false"/> - <module name="org.slf4j" export="false"/> - </dependencies> - -</module> +Models are listed as dependencies in the POM and built into the WARfile. In order to make it possible +to configure your own set of models to include, we have separated the model dependencies out in a +separate file. The default is `models.xml`, and contains the models that VIPS in Norway are using +currently. + +To build the package with the default set of models, run +```bash +$ build_with_models.py ``` -You also need to make sure you have the dependency modules available. +To build with your preferred set of models, create a new file called e.g. `my_models.xml` and run + +```bash +$ build_with_models.py my_models.xml +``` ## Implement a model See [implement_model.md](./docs/implement_model.md) diff --git a/build_with_models.py b/build_with_models.py index 240d19cddd28500c45acd2c3710cc50515d661df..c6b0a8560680582c6a9d25149ae469a084567ada 100755 --- a/build_with_models.py +++ b/build_with_models.py @@ -1,26 +1,57 @@ #!/usr/bin/python3 +''' +Merges pom.xml and models.xml (default) into pom_with_models.xml and +runs mvn clean install -f pom_with_models.xml + +Copyright (C) 2023 NIBIO + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +@author Tor-Einar Skog <tor-einar.skog@nibio.no> +''' import sys -from xml.dom.minidom import parse, parseString +import subprocess +from xml.dom.minidom import parse +# Default models_xml_path = "models.xml" +merged_pom_filename = "pom_with_models.xml" +# Accept alternative models.xml file if len(sys.argv) > 1: models_xml_path = sys.argv[1] -pom_file = open("pom.xml") -models_file = open(models_xml_path) - -pom_dom = parse(pom_file) -models_dom = parse(models_file) +# Read contents +pom_dom = parse("pom.xml") +try: + models_dom = parse(models_xml_path) +except FileNotFoundError: + print("ERROR: File %s not found." % models_xml_path) + exit(1) -pom_deps_element = pom_dom.getElementsByTagName("dependencies") +# Merge the dependency elements from models.xml into pom.xml +pom_deps_element = pom_dom.getElementsByTagName("dependencies")[0] model_dep_elements = models_dom.getElementsByTagName("dependency") for dep in model_dep_elements: - pom_deps_element.append(dep) + pom_deps_element.appendChild(dep) -print(pom_dom.toprettyxml()) +# Write the modified pom dom to file +pom_with_models_file = open(merged_pom_filename,"w") +pom_dom.writexml(pom_with_models_file) +pom_with_models_file.close() -models_file.close() -pom_file.close() +# Build VIPSCore with Maven, using the merged pom +subprocess.run("./mvnw clean install -f %s" % merged_pom_filename, shell=True) diff --git a/models.xml b/models.xml index 4f4b6b5f646aa551bff493a363ab2c74d2a91a15..c5c0bf5ad90624af838febcea3290bee9523fbd9 100644 --- a/models.xml +++ b/models.xml @@ -1,12 +1,112 @@ <dependencies> - <dependency> - <groupId>no.nibio.vips.model</groupId> - <artifactId>BremiaLactucaeModel</artifactId> - <version>2.0.0</version> - </dependency> - <dependency> - <groupId>no.nibio.vips.model</groupId> - <artifactId>PsilaRosaeTempModel</artifactId> - <version>1.0.0</version> - </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>AlternariaModel</artifactId> + <version>1.0.2</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>AppleScabModel</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>BarleyNetBlotchModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>BremiaLactucaeModel</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips</groupId> + <artifactId>DeliaRadicumModel</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>DeliaRadicumFloralisObservationModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>DOWNCASTModel</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>fi.luke.vips.model</groupId> + <artifactId>FinnCerealModels</artifactId> + <version>1.0.0</version> +</dependency> + <dependency> + <groupId>no.nibio.vips</groupId> + <artifactId>GrassDryingModel</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>LygusRugulipennisModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>MamestraBrassicaeModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.model</groupId> + <artifactId>Model_LEAFBLOTCH</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>no.nibio.model</groupId> + <artifactId>Model_MAIZEPHENO</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>NaerstadModel</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>NegativePrognosisModel</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>OatFloweringModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>PsilaRosaeObservationModel</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>PsilaRosaeTempModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>RoughageNutritionModel</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>no.bioforsk.vips.model</groupId> + <artifactId>SeptoriaApiicolaModel</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>SeptoriaHumidityModel</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>no.nibio.vips.model</groupId> + <artifactId>SeptoriaReferenceHumidityModel</artifactId> + <version>1.0.1</version> + </dependency> </dependencies> \ No newline at end of file diff --git a/models_sample.xml b/models_sample.xml index 22171b4b0859b4f216a56b728bcf9b9d501a2f26..6355573e291df29da5546da51371ef2489578976 100644 --- a/models_sample.xml +++ b/models_sample.xml @@ -1,3 +1,4 @@ +<!-- Example alternative list of model dependencies. Copy and use according to README.md --> <dependencies> <dependency> <groupId>no.nibio.vips.model</groupId> diff --git a/pom.xml b/pom.xml index 76e717425cfff25a091f16452534674c1db93154..84920f92d8abf18c542c513ded97e256b207f0a3 100755 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ <name>copyright</name> <!-- copyright tag for classes and interfaces --> <placement>t</placement> - <head>© Copyright</head> + <head>Copyright</head> </tag> </tags> </configuration> diff --git a/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 0d8a4e7d4cfd034496218dcac00a9110bf1c63cf..acc7ff4f0051b77a911bd6bfadfda38af5e42bfe 100755 --- a/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -22,6 +22,8 @@ along with VIPSCore. If not, see <http://www.nibio.no/licenses/>. <dependencies> </dependencies> - + <exclusions> + <module name="org.jboss.resteasy.resteasy-json-binding-provider"/> + </exclusions> </deployment> </jboss-deployment-structure>