You should start from this project, if your add-on will be based on custom Lit HTML element (that you are not planning to publish through npm) and provide Java API for the rest of the application. As an example this project implements a simple clock-element to display current time based on browser.
If you wish to build and publish an add-on or extension in Vaadin Directory, Vaadin provides the following three template projects:
- vaadin/addon-template: Create a composite component. This Java-only template is the easiest when extending Vaadin Java components.
- (this repo) vaadin/client-server-addon-template: Build a standalone, client-server TypeScript-Java component. This template provides you with a Lit-based example to start with.
- vaadin/npm-addon-template: Wrap a web component from npmjs.com as a Vaadin Java component.
Component implementation and API:
- Clock.java: Add-on component Java class. Provides server-side Java API to use component in your applications.
- clock-element.ts: TypeScript file that defines the client-side part of the component.
- clock-element.css: Default styles for the component.
For testing and development:
- TestView.java: A View class that let's you test the component you are building. This and other classes in the test folder will not be packaged during the build. You can add more test view classes in this package.
- TestViewIT.java: Integration tests for the component. Uses TestView.java.
- assembly/: this folder includes configuration for packaging the project into a JAR so that it works well with other Vaadin projects and the Vaadin Directory. There is usually no need to modify these files, unless you need to add JAR manifest entries.
- Starting the test/demo server in dev-mode:
mvn jetty:run
- Starting the test/demo server in prod-mode:
mvn jetty:run -Pproduction
These deploy test view at http://localhost:8080
To run Integration Tests, execute mvn verify -Pit,production
.
You should change the organisation.name
property in pom.xml
to your own name/organization.
<organization>
<name>###author###</name>
</organization>
You can create the zip package needed for Vaadin Directory using
mvn versions:set -DnewVersion=1.0.0 # You cannot publish snapshot versions
mvn package -Pdirectory,production
The package is created as target/{project-name}-1.0.0.zip
For more information or to upload the package, visit https://vaadin.com/directory/my-components?uploadNewComponent