The structure of a plugin project

Updated at 1709015578000
Screenshot 2024-02-26 at 14.04.08.png

Assuming our project is named book-store, it will consist of the following components:

  1. book-store-admin-plugin: Module for the admin part, containing modal classes, controllers, and static files and templates for views.
  2. book-store-sdk: Module containing common classes for other modules.
  3. book-store-socket-app: Module for the socket app.
  4. book-store-socket-plugin: Module for the socket plugin.
  5. book-store-theme: Module for the socket theme, containing modal classes, controllers, and static files and templates for views.
  6. book-store-web-plugin: Module for the web plugin, containing modal classes, controllers, and static files and templates for views.
  7. export-java-docs.bat: Windows batch script to export javadocs.
  8. export-java-docs.sh: Bash script to export javadocs.
  9. export.bat: Windows batch script to export the plugin to the local ezyplatform instance.
  10. export.sh: Bash script to export the plugin to the local ezyplatform instance.
  11. local.properties: Contains configuration properties for the project.
  12. pom.xml: Contains the project configuration; you can refer to it for more information on apache pom.
  13. README.md: Contains basic documentation for the project.

When initializing the project, you will need to choose the necessary modules. For example, if your project does not use sockets, you can skip the book-store-socket-app and book-store-socket-plugin modules.

Mapping

When exported, the corresponding modules of the project will be packaged and transferred to the ezyplatform directories as follows:

  1. book-store-admin-plugin -> ezyplatform/admin/plugins/book-store
  2. book-store-sdk -> ezyplatform/admin/plugins/book-store/lib, ezyplatform/socket/plugins/book-store/lib, ezyplatform/admin/apps/book-store/lib, and ezyplatform/admin/web/book-store/lib
  3. book-store-socket-app -> ezyplatform/socket/apps/book-store
  4. book-store-socket-plugin -> ezyplatform/socket/plugins/book-store
  5. book-store-theme -> ezyplatform/admin/themes/book-store
  6. book-store-web-plugin -> ezyplatform/web/plugins/book-store

Module Structure

The structure of a module in the plugin project is similar to the maven module structure:

  1. src/main/java: Contains Java source code.
  2. src/main/resources: Contains files that will be included in the classpath. You can create configuration files here, but try to avoid putting configuration files here; instead, use the Settings feature to allow admin users to change values.
  3. src/test/java: Contains test code.
  4. src/test/resources: Contains files that will be included in the classpath of the test environment. You can create configuration files for testing here.
  5. src/test/resources/AllTests.tng.xml: This is the testng unit test configuration file, which is mandatory and may look like this:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="AllTests">
  <test name="All">
    <packages>
      <package name="org.youngmonkeys.bookstore.admin.test" ></package>
    </packages>
  </test>
</suite>

For more detailed information, you can refer to the official testng documentation here.

  1. assembly.xml: Configuration file for apache-maven-assembly-plugin, which is also mandatory.

However, ezyplatform also adds some additional files and directories:

  1. menus.properties: A file defining the menus to be displayed on the admin interface. This file is only effective with the book-store-admin-plugin module.
  2. module.properties: A file containing definitions and information for the plugin. Except for book-store-sdk, all other modules must have this file.
  3. src/main/resources/static:
  • A directory containing static files such as html, css, javascript, and media.
  • Upon startup, ezyplatform will automatically scan this directory and register URIs for the files so that users can access them. Therefore, avoid putting sensitive information in this directory.
  • This directory is only effective with the book-store-admin-plugin, book-store-theme, and book-store-web-plugin modules.
  • You should divide it into subdirectories for different types of files, for example, the js directory for javascript files, the css directory for css files, and the images directory for images.
  1. src/main/resources/templates:
  • A directory containing template files for views using thymeleaf.
  • This directory is only effective with the book-store-admin-plugin, book-store-theme, and book-store-web-plugin modules.
  • For the admin, you need to add another subdirectory with the format src/main/resources/templates/{project name}, for example src/main/resources/templates/book-store, to avoid conflicts with other plugin's template paths.

For book-store example plugin you can be found in the Github project.

Next step

You can create admin menus for your plugin.