简体   繁体   中英

Why maven use the old version of the Vaadin plug-in when I run the project in IntelliJ?

I use Wildfly 20 and IntelliJ latest version with vaadin-maven-plugin 14.2.2 in my pom.xml and pnpm enabled.

A very ugly problem happens what I can't understand why. When I run my project via IntelliJ run configuration something strange happens. IntelliJ uses an older version of vaadin-plugin namely vaadin-maven-plugin 14.2.0 which I don't have it in my pom.xml.

I have already tried mvn help:effective-pom to see if multiple versions of this dependency exists in pom and also checked all transitive dependencies using mvn dependency:tree

Anyone knows why this happens and what should I do to prevent it?

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <vaadin.version>14.2.2</vaadin.version>
</properties>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>show-profiles</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>active-profiles</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
            </plugin>

            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <pnpmEnable>true</pnpmEnable>
                </configuration>
            </plugin>
        </plugins>


    </build>
    <profiles>
        <profile>
            <id>production</id>
            <properties>
                <vaadin.productionMode>true</vaadin.productionMode>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>flow-server-production-mode</artifactId>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-maven-plugin</artifactId>
                        <version>${vaadin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <pnpmEnable>true</pnpmEnable>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

If I use wildfly plugin and execut wildfly:run I get following error

    ERROR in ../target/frontend/generated-flow-imports-fallback.js
    Module not found: Error: Can't resolve '@vaadin/flow-frontend/?babel-target=es5' in 'C:\workspace\user-web\target\frontend'
     @ ../target/frontend/generated-flow-imports-fallback.js 45:0-32
     @ ../target/frontend/generated-flow-imports.js?babel-target=es5
    ERROR in ../target/frontend/generated-flow-imports-fallback.js
    Module not found: Error: Can't resolve '@vaadin/flow-frontend/?babel-target=es6' in 'C:\workspace\user-web\target\frontend'
     @ ../target/frontend/generated-flow-imports-fallback.js 45:0-32
     @ ../target/frontend/generated-flow-imports.js?babel-target=es6
Failed to execute goal com.vaadin:vaadin-maven-plugin:14.2.2:build-frontend 

    (default) on project user-web: Webpack process exited with non-zero exit code.
    Stderr: ''

            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>2.1.0.Beta1</version>
                <configuration>
                    <server-args>
                        <server-arg>-Duser.properties.file=C:\appserver.properties</server-arg>
                    </server-args>
                </configuration>
            </plugin>

Try following steps:

  • Do mvn clean install -U
  • Open the project view in IntelliJ
  • Right click the pom.xml file and
  • select Maven - Reimport If this works for you IntelliJ will add the dependencies to the project
  • Check the if the dependencies you need are added in File - Project Structure - Project Settings - Libraries and File - Project Structure - Modules - Dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM