Configuring vaadin-maven-plugin to create target folder in a different plac

Hello guys!
I’m working on a multi-module project, within this structure.

my-project

– api

– webapp

I have added the vaadin dependency on my webapp pom.xml, but when I’m running the project the vaadin creates a target folder within the root folder (my-project), I’m wondering if there is any way to configure the vaadin-maven-plugin to create the node-module and package.json file into the webapp folder, or even better for me, to avoid the node.js dependency. It this possible?

Thanks!

  • Mario.

Hi, can you share the pom.xml files?

Alejandro Duarte:
Hi, can you share the pom.xml files?

Sure!

This is the pom.xml of the parent project

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.2.0.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>mx.isccarrasco</groupId>
	<artifactId>spring-multi-module</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>spring-multi-module</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>org.junit.vintage</groupId>
					<artifactId>junit-vintage-engine</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
	</dependencies>

	<modules>
        <module>api</module>
        <module>webapp</module>
    </modules>

</project>

and this is the pom.xml of the webapp module:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>mx.isccarrasco</groupId>
		<artifactId>spring-multi-module</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>

	<groupId>mx.isccarrasco</groupId>
	<artifactId>webapp</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>webapp</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<java.version>1.8</java.version>
		<vaadin.version>14.0.10</vaadin.version>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.vaadin</groupId>
				<artifactId>vaadin-bom</artifactId>
				<!-- declare the latest Vaadin version
                     as a property or directly here -->
				<version>${vaadin.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>
				vaadin-spring-boot-starter
			</artifactId>
			<version>${vaadin.version}</version>
		</dependency>
	</dependencies>

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

		</plugins>
	</build>

</project>

As I mentioned, what I want is to create the target/frontend folder within the webapp module folder.

Thanks a lot!

Regards!

Thanks for sharing the files. I’m not sure if that’s a bug or not. I made it work as expected by removing all node_modules, target, package.json, package-lock.json, webpack.config.js, and webpack.generated.js directories and files. Then I cd webapp and mvn vaadin:prepare-frontend. Might be worth it opening an issue.

Alejandro Duarte:
Thanks for sharing the files. I’m not sure if that’s a bug or not. I made it work as expected by removing all node_modules, target, package.json, package-lock.json, webpack.config.js, and webpack.generated.js directories and files. Then I cd webapp and mvn vaadin:prepare-frontend. Might be worth it opening an issue.

Thanks Alejandro,
Now I have the problem that when I run the app, all the time it is showing a message that the client lost the connection with the server.

Can you share more details? Logs in the server and in the client, for instance.

Hi, I am also very interested how I can keep these files away from my root folder.

In my case I don’t even have the vaadin maven plugin declared. I run my project using IntelliJ Spring Boot run configuration.

I can see build, node_modules, package.json etc in the root directory. Can we please open an bug for it?

I am facing similar issue… Can someone help?

I think in a newer version it was fixed somehow. Not entirely sure why that is but look at my project here, the vaadin files are inside the “ui” module.
https://github.com/Sam-Kruglov/bank