Modernization Toolkit Analyzer - Vaadin Add-on Directory
Modernization Toolkit Analyzer for MavenModernization Toolkit Analyzer for Maven is a tool to assess how well your applications fit the latest Vaadin versions when migrating with the Vaadin Modernization Toolkit.
The Modernization Toolkit is a Vaadin product that accelerates your migration project. It has two components - a Dragonfly transpiler that does automated refactoring of your code, and a Feature Pack that identifies and isolates useful features from your application’s current application platform and makes them available in Vaadin Flow.
The Analyzer works by parsing your project’s Java code and resolving your application’s references to the libraries you specify, and outputting the high-level results to the Maven console.
The Analyzer report is something you can copy and share with your colleagues, application stakeholders, or with Vaadin experts to discuss. This will give you some concrete data to consider and can be the start of your discovery and planning for your application’s future.
### Limitations
To satisfy organizations with strict security policies on installing tools in their network, the Modernization Toolkit Analyzer for Maven is limited as follows:
* It doesn’t change your code.
* It writes all output to the console, not the disk.
### Requirements
* JDK 17: Your JAVA_HOME for Maven must be JDK 17 or later.
**It is not necessary to change your actual project's target Java runtime, whether it is below JDK 17 or not.**
* Maven 3.9.3, or later.
### Prepare your project to use Modernization Toolkit Analyzer for Maven
Include Vaadin addons repository as Maven plugin repository:
```
vaadin-addons
https://maven.vaadin.com/vaadin-addons
```
Add Modernization as a plugin:
```
com.vaadin.addons.modernization
mtk-maven-plugin
2.0.9
.
.
.
```
If your project has test classes and has dependencies with **test** scope, change those dependencies to **provided** in order to calculate the coverage for Vaadin components in test classes. Otherwise those dependencies will not be added to classpath in type resolution and coverage results will not be accurate.
Check your JAVA_HOME points to a JDK 17 or later and Maven 3.9.3 or later. If your project requires older Java and Maven versions, see the next section.
Check your JAVA_HOME points to a JDK 17 or later and Maven 3.9.3 or later. If your project requires older Java and Maven versions, see the next section.
```
mvn -v
Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Maven home: C:\dev\mvn\apache-maven-3.9.3
Java version: 17.0.8, vendor: Oracle Corporation, runtime: C:\dev\jdks\jdk-17.0.8
```
Before running the Modernization Toolkit Analyzer, make sure your project builds completely without any errors. The Analyzer requires compiled classes in order to resolve type dependencies.
```
mvn clean install
```
Run:
```
mvn mtk:analyze
```
### If your projects require older Java and Maven versions
Compiling projects and running Modernization Toolkit Analyzer are two seperate processes. You can compile projects with older Java and Maven versions, and then run the Analyzer with new Java and Maven versions.
1. Download JDK 17 and extract it to a suitable directory. https://jdk.java.net/archive/
2. Download maven 3.9.3 (or newer) and extract it to a suitable directory. https://maven.apache.org/download.cgi Alternatively, you can use Maven wrapper: `mvn wrapper:wrapper -Dmaven=3.9.5`
3. Switch to new maven directory.
4. In your current terminal, set JAVA_HOME:
Mac/Linux: `export JAVA_HOME=/home/deb/jdk-17.0.2`
Windows: `set JAVA_HOME=C:/users/deb/jdk-17.0.2`
5. Make sure that the project is already compiled with older JDK before running the Analyzer
6. Run: `mvn mtk:analyze`
### Running mtk:analyze: determining your pattern
To run the Analyzer for Maven effectively, you will need to have an awareness of what you are searching for. As a basic rule, a reference in your source code is marked on the analyzer report if it can be resolved to a class that matches the given pattern. Patterns are a semicolon-separated list of starting strings to match with the package names of any class that the reference can be resolved to.
The most common pattern for Vaadin applications is simply: `com.vaadin`.
For Vaadin applications there are many other libraries that you might want to understand at the same time like specific add-ons being used that might be requiring attention in your project. If you knew you used the Viritin addon in your Vaadin application, for example, it would be valid to use the pattern `com.vaadin;org.vaadin.viritin`.
The most common pattern for Swing applications is to search for the pattern `java.awt;javax.swing` …although there are many other libraries that are popular in Swing applications like JGoodies or JDesktop. The following pattern is a more complete one to use if you are analyzing a Swing application: `javax.swing;java.awt;com.jgoodies;org.jdesktop.layout`.
### Running mtk:analyze: passing your pattern to the Analyzer
Use the -Dpattern maven option to pass your search pattern to the Analyzer, like this:
```
mvn mtk:analyze -Dpatterns=javax.swing;java.awt;com.jgoodies
```
Note the ordering of the individual strings in the pattern does not matter. There are no wildcards supported - the match is done with a simple String.startsWith test.
When execution completes, you will see the summarized report in Maven output. To better understand the results and what your options are moving forward, please reach out to Vaadin to discuss.
Modernization Toolkit Analyzer version 2.0.9
- Enhanced type coverage in certain cases