Maven plugin for Vaadin Flow applications that handles frontend resource management, webpack bundling, and development workflow automation
The convert-polymer goal automates migration from legacy Polymer-based components to modern Lit framework, improving performance and maintainability.
<goal>convert-polymer</goal>
<!-- No default phase - must be explicitly executed -->This goal performs automated code migration:
<configuration>
<!-- Target conversion path -->
<path>path/to/specific/file/or/directory</path>
<!-- Lit version compatibility -->
<useLit1>false</useLit1>
<!-- JavaScript compatibility -->
<disableOptionalChaining>false</disableOptionalChaining>
</configuration><path>string</path> <!-- Specific file or directory to convert -->
<useLit1>true|false</useLit1> <!-- Enforce Lit 1.x compatible imports -->
<disableOptionalChaining>true|false</disableOptionalChaining> <!-- Disable ?. operator usage --><plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>24.9.0</version>
<executions>
<execution>
<goals>
<goal>convert-polymer</goal>
</goals>
</execution>
</executions>
</plugin><plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>24.9.0</version>
<configuration>
<path>src/main/frontend/components</path>
</configuration>
<executions>
<execution>
<goals>
<goal>convert-polymer</goal>
</goals>
</execution>
</executions>
</plugin><configuration>
<useLit1>true</useLit1>
<disableOptionalChaining>true</disableOptionalChaining>
</configuration><configuration>
<path>src/main/frontend/views/my-polymer-view.js</path>
</configuration>When no path is specified, the goal scans and converts:
*.js files in the project*.java files with Polymer template stringsnode_modules directory automatically// JavaScript/TypeScript files
my-component.js
my-component.ts
// Java files with embedded templates
@Tag("my-component")
@JsModule("./my-component.js")
public class MyComponent extends LitTemplate {
// Polymer template strings in Java
}Before (Polymer):
import { PolymerElement, html } from '@polymer/polymer';
import '@polymer/paper-button/paper-button.js';After (Lit):
import { LitElement, html, css } from 'lit';
import '@material/mwc-button/mwc-button.js';Before (Polymer):
class MyElement extends PolymerElement {
static get template() {
return html`<div>[[title]]</div>`;
}
static get properties() {
return {
title: String
};
}
}After (Lit):
class MyElement extends LitElement {
static properties = {
title: { type: String }
};
render() {
return html`<div>${this.title}</div>`;
}
}Before (Polymer):
html`
<div>[[property]]</div>
<input value="{{userInput::input}}">
<button on-click="handleClick">Click</button>
`After (Lit):
html`
<div>${this.property}</div>
<input .value="${this.userInput}" @input="${this.handleInput}">
<button @click="${this.handleClick}">Click</button>
`# Convert entire project
mvn flow:convert-polymer
# Convert specific directory
mvn flow:convert-polymer -Dvaadin.path=src/main/frontend/views
# Convert with Lit 1 compatibility
mvn flow:convert-polymer -Dvaadin.useLit1=true
# Convert without optional chaining
mvn flow:convert-polymer -Dvaadin.disableOptionalChaining=true
# Convert specific file
mvn flow:convert-polymer -Dvaadin.path=src/main/frontend/my-view.jsThe conversion tool is not intended for Hilla projects since Polymer templates are not supported in Hilla. When executed in a Hilla project, the goal will display a warning:
The 'convert-polymer' goal is not meant to be used in Hilla projects as polymer templates are not supported.When useLit1 is enabled:
When disableOptionalChaining is enabled:
?. operatorBefore running the conversion:
After conversion completion:
The automated conversion handles most cases but may require manual review for:
// May need manual adjustment
handleComplexEvent(e) {
// Custom Polymer patterns might not convert perfectly
}// Polymer observers need manual conversion to Lit reactive properties
static get observers() {
return ['_titleChanged(title)']; // Needs manual Lit lifecycle conversion
}// Complex data binding expressions may need review
html`<div>[[_computeValue(prop1, prop2)]]</div>` // Check Lit equivalentError: Cannot convert file
Solution: Check file syntax, ensure valid JavaScript/TypeScript, try converting smaller sectionsWarning: Pattern not converted automatically
Solution: Review generated code, apply manual conversion for complex patternsError: Cannot write converted file
Solution: Check file permissions, ensure files are not read-only# Convert one component at a time
mvn flow:convert-polymer -Dvaadin.path=src/main/frontend/components/user-card.js
mvn compile # Test compilation
mvn test # Run tests
# Continue with next component
mvn flow:convert-polymer -Dvaadin.path=src/main/frontend/components/nav-bar.js<!-- Maven profile for batch conversion -->
<profile>
<id>convert-to-lit</id>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<executions>
<execution>
<id>convert-components</id>
<goals>
<goal>convert-polymer</goal>
</goals>
<configuration>
<path>src/main/frontend/components</path>
</configuration>
</execution>
<execution>
<id>convert-views</id>
<goals>
<goal>convert-polymer</goal>
</goals>
<configuration>
<path>src/main/frontend/views</path>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>Activate with:
mvn compile -Pconvert-to-litInstall with Tessl CLI
npx tessl i tessl/maven-com-vaadin--vaadin-maven-plugin