[Maven] How to create a new plugin from an existing UI component ?


I don’t find how to create a plugin with Maven from an existing UI component. In my case I would like to copy the DateField component in a plugin in order to modify only one private method.

First, I created a new Maven plugin with the command :

mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-widget -DarchetypeVersion=7.0-SNAPSHOT -Dpackaging=war

Now I have a project structured like this :

 |-- my-datefield-root
   |-- my-datefield
       |-- client
           |-- MyDateFieldClientRpc.java
           |-- MyDateFieldConnector.java
           |-- MyDateFieldServerRPC.java
           |-- MyDateFieldState.java
           |-- MyDateFieldWidget.java
       |-- MyDateField.java
   |-- my-datefield-demo
      |-- DemoUI.java

The structure includes src/main/java and src/main/resources.

I’m stuck here : Where can I put the code of DateField ? As a reminder, my goal is simply to replace the code of a private method, this is the getCalendar() method.

Here is my previous thread explaining why I want to achieve this :

Thanks for your help.

Hi Romain,

If you simply want to modify an existing component, why don’t you simply extend such component?

public class MyDateField extends com.vaadin.ui.DateField {

    private Calendar getCalendar() {

        Calendar newCal = null;
        //TODO insert code here ...

        return newCal;

The structure you provided corresponds to that of a Vaadin custom Widget, as far as I know.


Hi Bernat,

I can’t do that, because I have to access some private field in the class. So I need to copy the entire class…