1

I have a simple Vaadin 14.4.4 LTS example app that I moved to 14.6.8. Styling issues occur when I start it (in development mode, haven't checked production). The font is not configured correctly for labels, checkboxes and the header.

Have checked and diffed it against the new examples from start.vaadin.com but cannot see a difference. Have copied the theme folder from the new examples to frontend/themes/myapp and used the layout the same way:

@PWA(name = "My App", shortName = "My App", enableInstallPrompt = false)
@Theme(themeFolder = "myapp")
// @Theme(value = Lumo.class, variant = Lumo.DARK)
@PageTitle("Main")
public class MainLayout extends AppLayout {

When the theme with Lumo.class and without the themeFoder is used the dark variant is not shown, so I suppose it doesn't pick up the @Theme for some reason.

vaadin 14.6.8 styles broken

I could add a css style so it looks ok again, but I don't want to tweak it manually since the new examples work as expected.

I have added the lumo style package as described here Can't resolve 'lumo-css-framework/all-classes.css' and just as in the examples:

@NpmPackage(value = "lumo-css-framework", version = "^4.0.10")
@NpmPackage(value = "line-awesome", version = "1.3.0") 

I have deleted webpack.config.js and package.json to fetch all the modules again. Also to be sure there is no dependency to an older Vaadin version I went through mvn dependency:tree and double-checked all is 14.6.8.

The strange thing about it is that it is based on an example from 14.4.4 LTS so I didn't expect it to break. Maybe someone has an idea what I am missing and was running into the same issue?

Will appreciate any help, thanks in advance!

Edit/Update:

I narrowed down the problem for future reference, here are the files required to reproduce the scenario (which used to work for me without problems in 14.4):

parent-pom, pom.xml of the sub-module, Main-Class and View

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>Parent POM</name>
    <groupId>test</groupId>
    <artifactId>test-parent-pom</artifactId>
    <version>1.2.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <source>10</source>
        <target>10</target>
        <java.release>11</java.release>
        <java.target>1.8</java.target>
        <java.version>1.8</java.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <spring.boot.version>2.5.3</spring.boot.version>
        <velocity.version>2.1</velocity.version>

        <vaadin.version>14.6.8</vaadin.version>
        <groovy.version>3.0.8</groovy.version>
        <spock.version>2.0-groovy-3.0</spock.version>

        <jupiter.version>5.7.2</jupiter.version>
        <junit-platform-runner.version>1.7.2</junit-platform-runner.version>
        <groovy-eclipse-compiler.version>3.7.0</groovy-eclipse-compiler.version>
        <groovy-eclipse-batch.version>3.0.8-01</groovy-eclipse-batch.version>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
        <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
        <maven-failsafe-plugin.version>${maven-surefire-plugin.version}</maven-failsafe-plugin.version>
    </properties>

    <modules>
        <module>sample-sub</module>
    </modules>
</project>

sub-module pom (which is the pom of starters with a parent added):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <name>Example</name>
    
    <artifactId>example</artifactId>
    <groupId>examples</groupId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>test</groupId>
        <artifactId>test-parent-pom</artifactId>
        <version>1.2.1-SNAPSHOT</version>
    </parent>




    <repositories>
        <!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->

        <!-- Main Maven repository -->
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <!-- Repository used by many Vaadin add-ons -->
        <repository>
            <id>Vaadin Directory</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>seife</id>
            <url>https://repo.uc-mobileapps.com/release</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <!-- Main Maven repository -->
        <pluginRepository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>com.vaadin</groupId>
            <!-- Replace artifactId with vaadin-core to use only free components -->
            <artifactId>vaadin-core</artifactId>
            <exclusions>
                <!-- Webjars are only needed when running in Vaadin 13 compatibility mode -->
                <exclusion>
                    <groupId>com.vaadin.webjar</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.webjars.bowergithub.insites</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.webjars.bowergithub.polymer</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.webjars.bowergithub.polymerelements</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.webjars.bowergithub.vaadin</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.webjars.bowergithub.webcomponents</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
            <exclusions>
                <!-- Excluding so that webjars are not included. -->
                <exclusion>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.5.0</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Include JUnit 4 support for TestBench and others -->
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>


    </dependencies>

    <build>
        <defaultGoal>spring-boot:run</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!-- Clean build and startup time for Vaadin apps sometimes may exceed
                     the default Spring Boot's 30sec timeout.  -->
                <version>${spring.boot.version}</version>
                <configuration>
                    <wait>500</wait>
                    <maxAttempts>240</maxAttempts>
                </configuration>
            </plugin>

            <!--
                Take care of synchronizing java dependencies and imports in
                package.json and main.js files.
                It also creates webpack.config.js if not exists yet.
            -->
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- Production mode is activated using -Pproduction -->
            <id>production</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-maven-plugin</artifactId>
                        <version>${vaadin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <productionMode>true</productionMode>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>
</project>

Main.java

package com.examples;

import com.vaadin.flow.component.dependency.NpmPackage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@EnableJpaRepositories
@ServletComponentScan
@NpmPackage(value = "lumo-css-framework", version = "^4.0.10")
@NpmPackage(value = "line-awesome", version = "1.3.0")
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }
}

The view-class:

package com.examples.vaadin.views;

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.checkbox.Checkbox;
import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.BeforeEnterEvent;
import com.vaadin.flow.router.BeforeEnterObserver;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.PWA;
import com.vaadin.flow.theme.Theme;
import com.vaadin.flow.theme.lumo.Lumo;
import com.vaadin.flow.theme.material.Material;

@Route("")
@Theme(value = Lumo.class, variant = Lumo.DARK)
public class MainView extends VerticalLayout {

    public MainView() {
        Label label = new Label("serif?");
        Checkbox checkbox = new Checkbox("serif??");
        Button button = new Button("Click me",
                event -> Notification.show("Clicked!"));
        add(label, checkbox, button);
    }
}
RookieGuy
  • 517
  • 7
  • 18
  • Could you give a step by step on what was the changes made for the 14.4.4 starter? Or would it perhaps be possible to share the broken project for inspection? – Mikael Grankvist Aug 16 '21 at 05:14
  • While trying to create the sample project to reproduce the issue, I found the following; The build/run *depends on the working directory* due to webpack. Here is a maven multi-project and for some reason webpack complained when starting in the project.parent.dir, so I set the working directory to the sub-module, the project now starts but doesn't pick up the theme. – RookieGuy Aug 16 '21 at 10:33
  • 1
    Sounds like there is some configuration issue with the modules as it should work fine with multiple modules also. See: https://github.com/vaadin/flow/tree/2.6/flow-tests and the `test-themes` module. (It is run from the parent parent module) also you could see the setup in `test-application-theme` to see if there is something you might have miss configured. – Mikael Grankvist Aug 16 '21 at 12:00
  • I've uploaded a sample project that reproduces the problem: https://wetransfer.com/downloads/33bc3acb3a9bf1e478d1df48e4d1a2b320210816115804/0cfba6 node_modules is created in the sub modules' directory and when run with RMB -> Run on the Main class the theme isn't picked up. – RookieGuy Aug 16 '21 at 12:01
  • Tested the sample project and at least running with maven it works as expected. Which IDE are you using to run the main class? For running with IDE it seems it takes the wrong base directory which could be given with `-Dproject.basedir={path}/sub-module` to the runner or run `mvn vaadin:prepare-fronted` (in the sub module). – Mikael Grankvist Aug 19 '21 at 06:18
  • Thanks for taking the time, this is happening in IntelliJ. To me it seems the issue is really that it is hard to understand what the build-process is doing and what information it uses from the build environment to set up all the paths for webpack and what-not. I think this might also be a hidden bug for a specific local configuration. I've seen that it sometimes created node_modules in the parent directory and during some other runs in the sub-module dir. I'll set up a new project structure based on the starter and will copy the files as a fresh project to circumvent the issue. – RookieGuy Aug 21 '21 at 15:58

0 Answers0