Wstęp

Poniżej opisane zostały 2 sposoby tworzenia projektu wtyczki:

  • ręcznie
  • maven archetype

Tworzenie projektu z archetypu jest szybsze i wygodniejsze. Musimy jedynie uzupełnić wymagane parametry takie jak nazwa, klucz etc.

Tworzenie projektu od podstaw

Każda tworzona wtyczka nie może współdzielić jednego pakietu z inną wtyczką.

  1. Tworzymy nowy projekt Maven (File -> New -> Maven Project).
  2. Zaznaczamy opcję Create a simple project (skip archetype selection) i klikamy Next
  3. Uzupełniamy informacje o projekcie i tworzymy projekt




    Projekt powinien być stworzony zgodnie z konwencją:

    • groupId: dla wtyczek przyjęto com.suncode.plugin
    • artifactId: identyfikator wtyczki (musi być unikalny w zakresie projektu)
    • version: wersja wtyczki może być niezależna od wersji systemu docelowego
    • packaging: musi zostać ustawione na bundle (wartości nie ma na liście)

     

    Dodajemy niezbędny plik deskryptora wtyczki suncode-plugin.xml do katalogu src/main/resources:

    <?xml version="1.0" encoding="UTF-8"?>
    <plugin key="${project.groupId}-${project.artifactId}" name="Tutorial Plugin">
    	<plugin-details>
    		<description>
    			<localized language="en">Description</localized>
    			<localized language="pl">Opis</localized>
    		</description>
    		<author>Suncode</author>
    	</plugin-details>
    	
    	<!-- I18N -->	
    	<i18n key="i18n-bundle" location="locale/messages" />
    	
    	<!-- Web MVC -->
    	<web-mvc key="mvc" />
    </plugin>

    Plik suncode-plugin.xml jest filtrowany przez Maven'a. Oznacza to, że w miejsca właściwości ${...} dynamicznie wstawiana jest zawartość tych właściwości.

    Zamiast ${project.groupId}-${project.artifactId} możemy wpisać stały identyfikator wtyczki. Wpisanie ${project.groupId}-${project.artifactId} skutkuje dynamicznie tworzonym identyfikatorem z właściwości groupId i artifactId.

  4. Dodajemy plik tłumaczeń messages.properties do katalogu src/main/resources/locale


Ostateczna struktura projektu powinna wyglądać następująco:

Tworzenie projektu wykorzystując gotowy archetyp

Przed stworzeniem projektu należy skonfigurować katalogi archetypów. W tym celu otwieramy Window->Preferences oraz dodajemy Remote Catalog z adresem URL repozytorium Suncodehttp://192.168.1.51:8081/nexus/content/groups/public/



  1. Tworzymy nowy projekt Maven (File -> New -> Maven Project).
  2. Zostawiamy opcję Create a simple project (skip archetype selection) odzaznaczoną
  3. Wybieramy interesujący nas archetyp tak jak na rysunku:



  4. Następnie uzupełniamy wszystkie wymagane informacje:



     Opis wszystkich właściwości:

    • plusworkflowVersion: docelowa wersja systemu PlusWorkflow
    • name: nazwa wtyczki
    • author: twórca wtyczki
    • descriptionPL: opis wtyczki w języku polskim
    • descriptionEN: opis wtyczki w języku angielskim
  5. Stworzony projekt bo zbudowaniu może już być zainstalowany w systemie jako wtyczka. Deskryptor tej wtyczki wygląda następująco:

    <?xml version="1.0" encoding="UTF-8"?>
    <plugin key="com.suncode.plugin-tutorial" name="Tutorial Plugin">
    	<plugin-details>
    		<description>
    			<localized language="en">Description</localized>
    			<localized language="pl">Opis</localized>
    		</description>
    		<author>Suncode</author>
    	</plugin-details>
    	
    	<!-- I18N -->	
    	<i18n key="i18n-bundle" location="locale/messages" />
    	
    	<!-- Web MVC -->
    	<web-mvc key="mvc" />
    </plugin>

 

Ostateczna struktura projektu powinna wyglądać następująco:

 


Introduction

Below are described 2 ways to create a plug-in project:

  • manually
  • maven archetype

Creating a project from an archetype is faster and more convenient. We only need to complete the required parameters such as name, key etc.


Creating a project from scratch 

Each created plug-in can not share one package with another plug-in.

 

  1. We create a new Maven project (File -> New -> Maven Project).
  2. Select the Create a simple project option (skip archetype selection)and click Next
  3. We complete the information about the project and create the project




    The project should be created in accordance with the convention:

      • groupId: com.suncode.plugin accepted for plugins
      • artifactId: plug ID (must be universal)
      • version: the plugin version can be independent from the target system version
      • packaging: must be set to bundle (the value is not on the list)

     

    We add the necessary suncode-plugin.xmldescriptor file to the src/main/resources directory: 

    <?xml version="1.0" encoding="UTF-8"?>
    <plugin key="${project.groupId}-${project.artifactId}" name="Tutorial Plugin">
    	<plugin-details>
    		<description>
    			<localized language="en">Description</localized>
    			<localized language="pl">Opis</localized>
    		</description>
    		<author>Suncode</author>
    	</plugin-details>
    	
    	<!-- I18N -->	
    	<i18n key="i18n-bundle" location="locale/messages" />
    	
    	<!-- Web MVC -->
    	<web-mvc key="mvc" />
    </plugin>

    The suncode-plugin.xmlfile is filtered by Maven. This means that the contents of these properties are dynamically inserted into the properties of ${...}.

    Instead of ${project.groupId} - ${project.artifactId} we can enter a permanent ID of the plugin. Typing ${project.groupId} - ${project.artifactId} results in a dynamically created identifier from the groupId and artifactId properties.

  4. We add the messages.properties file to the src/main/resources/locale directory. 

 

The final structure of the project should look like this:

Creating a project using a prepared archetype

 

Before creating the project, you need to configure the archetype catalogs. To do this, open Window-> Preferencesand add the Remote Catalogwith the URL of the Suncode repository http://192.168.1.51:8081/nexus/content/groups/public/


 

 

  1. We create a new Mavenproject (File -> New -> Maven Project).
  2. Leave the Create a simple project (skip archetype selection) option selected
  3. We choose the archetype we are interested in as in the picture:




  1. Then we fill-in all the required information: 



    Description of all properties:

      • plusworkflowVersion: the target version of thePlusWorkflow system
      • name: name of the plugin
      • author: creator of the plugin
      • descriptionPL: description of the plugin in Polish
      • descriptionEN: description of the plugin in English
  2. Created project can already be installed in the system as a plug-in. The descriptor for this plug-in looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <plugin key="com.suncode.plugin-tutorial" name="Tutorial Plugin">
    	<plugin-details>
    		<description>
    			<localized language="en">Description</localized>
    			<localized language="pl">Opis</localized>
    		</description>
    		<author>Suncode</author>
    	</plugin-details>
    	
    	<!-- I18N -->	
    	<i18n key="i18n-bundle" location="locale/messages" />
    	
    	<!-- Web MVC -->
    	<web-mvc key="mvc" />
    </plugin>

 

The final structure of the project should look like this: