Skip to content

Latest commit

 

History

History
218 lines (156 loc) · 6.36 KB

README.md

File metadata and controls

218 lines (156 loc) · 6.36 KB

GeoNetwork Web application

The web module gathers the static resources and configuration files for building the final web application WAR.

Jetty

  1. Run embedded Jetty server:

    mvn jetty:run -Penv-dev
    

    The env-dev profile above ensures geonetwork runs without a javascript cache allowing testing of changes to web-ui.

  2. After startup, GeoNetwork is accessible at:

  3. Jetty is configured to use src/main/webapp and maven classpath and will reload changes:

    • For changes related to the user interface in the web-ui module:

      mvn process-resources
      
    • For changes to schema plugins compile:

      cd ../schemas
      mvn install
      

      And then load:

      cd ../web
      mvn process-resources
      
    • You may also try the following (which just copies between folders):

      mvn process-resources -DschemasCopy=true
      

Clean

The build generates, processes and compile files into:

  • src/main/webapp/WEB-INF/data/config/schema_plugins
  • target/

Use mvn clean to remove these files.

In addition running jetty makes use of a database, data directory and cache, notably:

  • *.db
  • images/ ...
  • jcs_caching/ ...
  • logs/ ...
  • src/main/webapp/WEB-INF/data/config/schema_plugins/ ...
  • src/main/webapp/WEB-INF/data/data/ ...
  • src/main/webapp/WEB-INF/data/wro4j*.db
  • src/main/webapp/WEB-INF/doc/en/ ...
  • src/main/webapp/WEB-INF/doc/fn/ ...

Use mvn clean:clean@reset to remove these files.

Managing Schema Plugins

The web application src/main/webapp contains WEB-INF/data/config/schema_plugins used by the application.

If your plugin is in the schemas folder:

  1. The web/pom.xml is setup to run jetty and automatically include any additional schema plugins in the schemas folder.

If your plugin is not in the schemas folder:

  1. If you are building a metadata101 plugin separately, or working with your own plugin:

    cd iso19139.xyz
    mvn install
    
  2. Use jetty:run with an additional profile to test your plugin:

    mvn install -Pschema-iso19139.xyz
    mvn jetty:run -Pschema-iso19139.xyz
    
  3. In the example above the profile -Pschema-iso19139.xyz:

    • Includes schema-iso19139.xyz artifact as a dependency, making the schema plugin bean is available on the CLASSPATH.
    • Unpacks the schema-iso19139.xyz artifact plugin folder into WEB-INF/data/config/schema_plugins
  4. The profile can also be used with process-resources while jetty is running:

    cd web
    mvn process-resources -Pschema-iso19139.xyz
    
  5. Tip: If work with a set series of plugins you can manage via settings.xml.

Including additional schema plugins

To include your schema plugin in web/pom.xml:

  1. Add a profile to web/pom.xml unpacking your schema plugin.

    Using iso19115-xyz as an example:

 <profile>
   <id>schema-iso19115-xyz</id>
   <activation>
     <property><name>schemasCopy</name><value>!true</value></property>
     <file><exists>../schemas/iso19115-xyz</exists></file>
   </activation>
   <dependencies>
     <dependency>
       <groupId>org.geonetwork-opensource.schemas</groupId>
       <artifactId>schema-iso19139.xyz</artifactId>
       <version>${project.version}</version>
     </dependency>
   </dependencies>
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
           <execution>
             <id>iso19115-xyz-resources</id>
             <phase>process-resources</phase>
             <goals><goal>unpack</goal></goals>
             <configuration>
               <encoding>UTF-8</encoding>
               <artifactItems>
                 <artifactItem>
                   <groupId>org.geonetwork-opensource.schemas</groupId>
                   <artifactId>schema-iso19115-xyz</artifactId>
                   <type>zip</type>
                   <overWrite>false</overWrite>
                   <outputDirectory>${schema-plugins.dir}</outputDirectory>
                 </artifactItem>
               </artifactItems>
               </artifactItems>
             </configuration>
           </execution>
         </executions>
       </plugin>
     </plugins>
   </build>
 </profile>
  1. This profile example has several interesting features:

    • Activates automatically if the schemas/iso19115-xyz folder is present
    • 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
  2. Over time we expect active metadata101 schema plugins be listed.

Alternative: Add schema plugin to copy-schemas profile

An alternative approach of copying folders is available using the -DschemasCopy flag:

  • -DschemasCopy=true: copies folders from ../schemas location
  • -DschemasCopy=false: default approach, using artifact and maven repository

To add your schema plugin to the schemas-copy profile:

  1. Locate the schemas-copy profile in web/pom.xml:

  2. Add your plugin as a dependency to the profile:

    <dependency>
      <groupId>org.geonetwork-opensource.schemas</groupId>
      <artifactId>schema-iso19139.xyz</artifactId>
      <version>${project.version}</version>
    </dependency>
  3. By default each src/main/plugin folder in schemas is copied.

    If your plugin is in not in the schemas folder:

    <resource>
      <directory>${metadata101}/iso19139.xyz/src/main/plugin</directory>
      <targetPath>${schema-plugins.dir}</targetPath>
    </resource>
  4. This approach modifies web/pom.xml so it can only be recommended in a fork or branch.

  5. Implementation notes:

    • The <dependency> 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:

    ./add-schema.sh iso19139.ca.HNAP https://github.com/metadata101/iso19139.ca.HNAP 3.11.x"