Skip to content

Commit 373385f

Browse files
tltvmshabarov
andauthored
docs: update articles for production build change (#4650)
* docs: update articles for production build change Removed production profile from articles that use example apps that build or will build production package without any production profile. Part of vaadin/flow#22464 * Update quarkus.adoc * Update getting-started.adoc --------- Co-authored-by: Mikhail Shabarov <[email protected]>
1 parent 00d1469 commit 373385f

File tree

19 files changed

+177
-129
lines changed

19 files changed

+177
-129
lines changed

articles/flow/configuration/licenses/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The banner links to the https://vaadin.com/commercial-license-info[Commercial Li
5858
[source,terminal]
5959
----
6060
<source-info group="Maven"></source-info>
61-
mvn package -Pproduction -Dvaadin.commercialWithBanner
61+
mvn package -Dvaadin.commercialWithBanner
6262
----
6363
[source,groovy]
6464
----

articles/flow/integrations/quarkus.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ After doing the <<quarkus.setup>>, the Quarkus application can be started in dev
198198

199199
[source,terminal]
200200
----
201-
mvn package quarkus:dev
201+
mvn quarkus:dev
202202
----
203203

204204
The application is then available at http://localhost:8080/[+localhost:8080+] in the browser.
@@ -212,7 +212,7 @@ When you're ready, run the following commands to start the application:
212212

213213
[source,terminal]
214214
----
215-
mvn package -Pproduction
215+
mvn package
216216
java -jar target/quarkus-app/quarkus-run.jar
217217
----
218218

articles/flow/production/cloud-providers/aws/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Open the project directory from a terminal window, and enter the following comma
5555

5656
[source,terminal]
5757
----
58-
mvn package -Pproduction
58+
mvn package
5959
----
6060

6161
== Step 5: Initialize a Beanstalk Project

articles/flow/production/cloud-providers/azure/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Open the project directory from a terminal window, and enter the following comma
6363

6464
[source,terminal]
6565
----
66-
mvn package -Pproduction
66+
mvn package
6767
----
6868

6969
== Step 5: Configure Your Application

articles/flow/production/cloud-providers/google/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Finally, you can build and deploy using a single command as follows:
131131

132132
[source,terminal]
133133
----
134-
mvn package appengine:deploy -Pproduction
134+
mvn package appengine:deploy
135135
----
136136

137137
When the deployment has finished, the application URL is displayed in the logs.

articles/flow/production/cloud-providers/heroku/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Open the project directory from a terminal window, and enter the following comma
6767

6868
[source,terminal]
6969
----
70-
mvn package -Pproduction
70+
mvn package
7171
----
7272

7373
== Step 5: Initialize a Heroku Application

articles/flow/production/docker.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This approach makes building and running your container as simple as running the
2121
+
2222
[source,terminal]
2323
----
24-
mvn clean package -Pproduction
24+
mvn clean package
2525
----
2626

2727
. Run the following command to build your container:

articles/flow/production/production-build.adoc

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ order: 10
99

1010
= Production Build
1111

12-
To create a production build, run the following from the command-line:
12+
To create a production build, run the following from the command-line for application using Spring Boot:
13+
14+
[source,terminal]
15+
----
16+
mvn clean package
17+
----
18+
19+
For other applications, e.g., Jakarta EE or plain Java, and for better backwards compatibility, run same with a production profile:
1320

1421
[source,terminal]
1522
----
@@ -37,7 +44,7 @@ If needed, you can force the creation of an optimized production bundle by execu
3744

3845
[source,terminal]
3946
----
40-
mvn clean package -Pproduction -Dvaadin.force.production.build=true
47+
mvn clean package -Dvaadin.force.production.build=true
4148
----
4249

4350
[NOTE]
@@ -57,10 +64,62 @@ By default, Vaadin uses `npm install` to install frontend packages. This can be
5764

5865
When set, Vaadin interrupts package installation if it spots any mismatch between package versions in the [filename]`package.json` and the lock file. It'll then recommend re-running `npm install`. This makes production builds in the CI pipelines reproducible, enabling you to identify problems in advance.
5966

60-
6167
== Enabling Production Builds
6268

63-
The production build command works out-of-the-box for Vaadin starter projects. It'll work with projects that are generated with `https://start.vaadin.com`. The starter projects come with the necessary Maven configuration. If you've manually created your project's [filename]`pom.xml` file, add the following Maven profile to enable production builds:
69+
The production build command works out-of-the-box for Vaadin starter projects. It'll work with projects that are generated with `https://start.vaadin.com`. The starter projects come with the necessary Maven configuration.
70+
71+
If you've manually created your project's [filename]`pom.xml` file, add the following `vaadin-maven-plugin` to enable production builds when using Spring Boot:
72+
73+
.`pom.xml`
74+
[source,xml]
75+
----
76+
<!--
77+
.. configuration depending on environment ..
78+
-->
79+
80+
<build>
81+
<plugins>
82+
<plugin>
83+
<groupId>com.vaadin</groupId>
84+
<artifactId>vaadin-maven-plugin</artifactId>
85+
<version>${project.version}</version>
86+
<executions>
87+
<execution>
88+
<goals>
89+
<goal>prepare-frontend</goal>
90+
</goals>
91+
</execution>
92+
<execution>
93+
<id>package-for-production</id>
94+
<goals>
95+
<goal>build-frontend</goal>
96+
</goals>
97+
<phase>prepare-package</phase>
98+
</execution>
99+
</executions>
100+
<configuration>
101+
<!-- To always force an optimized production bundle build set this configuration to 'true' -->
102+
<!-- To possibly use the pre-compiled production bundle remove or set to 'false' -->
103+
<forceProductionBuild>true</forceProductionBuild>
104+
<!-- To have reproducible build by running 'npm ci' -->
105+
<ciBuild>true</ciBuild>
106+
</configuration>
107+
</plugin>
108+
<!--
109+
.. more plugins ..
110+
-->
111+
</plugins>
112+
</build>
113+
<!--
114+
.. more configuration ..
115+
-->
116+
----
117+
118+
The content depends on the environment in which your application is running, but all variations call the Maven goal `vaadin:build-frontend`. The Maven goal `vaadin:prepare-frontend` is also required. Once the `vaadin:build-frontend` goal targeting `prepare-package` phase is added, you can call the production build command.
119+
120+
If you don't have the `build-frontend` goal in your [filename]`pom.xml` file, get a project base for Spring Boot projects from `https://start.vaadin.com`. Then copy the `vaadin-maven-plugin` plugin from the downloaded [filename]`pom.xml` file.
121+
122+
For other applications, e.g., Jakarta EE or plain Java, and for better backwards compatibility, add the following Maven profile to enable production builds and get a project base from `https://vaadin.com/hello-world-starters`:
64123

65124
.`pom.xml`
66125
[source,xml]
@@ -106,12 +165,6 @@ The production build command works out-of-the-box for Vaadin starter projects. I
106165
</profiles>
107166
----
108167

109-
The content of the profile depends on the environment in which your application is running, but all variations call the Maven goal `vaadin:build-frontend`. The Maven goal `vaadin:prepare-frontend` is also required, but that's often declared already in the development build. Once the Maven profile is added, you can call the production build command.
110-
111-
If you don't have the production Maven profile in your [filename]`pom.xml` file, get a project base: for Spring Boot projects, get it from `https://start.vaadin.com`; for other stacks (e.g., Jakarta EE or plain Java) from `https://vaadin.com/hello-world-starters`. Then copy the production profile from the downloaded [filename]`pom.xml` file.
112-
113-
Having the production build as a separate Maven profile is recommended to avoid unexpected problems due to production settings during development.
114-
115168
.Building for 64-bit
116169
[NOTE]
117170
If you're using a 64-bit operating system, be sure to use a 64-bit JDK installation, as well.
@@ -146,6 +199,23 @@ The Vite server integration and live reload features -- which are available only
146199
</profiles>
147200
----
148201

202+
Or when building Spring Boot 4 application, add `vaadin-dev` dependency as a `optional` scope in project `<dependencies>`. Spring Boot 4 `spring-boot-maven-plugin` automatically excludes optional dependencies from the final build:
203+
204+
.`pom.xml`
205+
[source,xml]
206+
----
207+
<dependencies>
208+
...
209+
<dependency>
210+
<groupId>com.vaadin</groupId>
211+
<artifactId>vaadin-dev</artifactId>
212+
<optional>true</optional>
213+
</dependency>
214+
...
215+
</dependencies>
216+
----
217+
218+
149219
This results in less code and fewer dependency libraries being bundled in the production application.
150220

151221

articles/flow/testing/selenium.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ If you added your Selenium tests to a project that was generated from https://st
156156

157157
[source,terminal]
158158
----
159-
mvn verify -Pit,production
159+
mvn verify -Pit
160160
----
161161

162162
This runs the tests in the `it` profile, which starts the Spring Boot server before the tests are run -- and stops it afterwards. If you're running the test this way, your test classes must end with `IT`.

articles/getting-started/build.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ Up to this point, the walking skeleton has been <<run#,running in development mo
1414

1515
== Make a Production Build
1616

17-
In the walking skeleton, you use the Vaadin Maven plugin to make a production build. You do this by activating the `production` profile, like this:
17+
In the walking skeleton, you use the Vaadin Maven plugin to make a production build. You do this by activating the `package` goal, like this:
1818

1919
[.example]
2020
--
2121
[source,bash,subs="+attributes"]
2222
----
2323
<source-info group="macOS / Linux"></source-info>
24-
./mvnw clean package -Pproduction
24+
./mvnw clean package
2525
----
2626

2727
[source,powershell,subs="+attributes"]
2828
----
2929
<source-info group="Windows"></source-info>
30-
mvnw clean package -Pproduction
30+
mvnw clean package
3131
----
3232
--
3333

3434
Once the build has finished, check the `target` directory. If your skeleton was named `my-application`, you should find a file called `my-application-1.0-SNAPSHOT.jar`.
3535

36-
The `production` profile not only builds the frontend, but also excludes the development server bundle since it contains features that aren't used in production.
36+
The `package` goal not only builds the frontend, but also excludes the development server bundle since it contains features that aren't used in production.
3737

3838

3939
== Build a Docker Image
@@ -107,7 +107,7 @@ RUN --mount=type=cache,target=/root/.m2 \
107107
--mount=type=secret,id=offlineKey \
108108
sh -c 'PRO_KEY=$(jq -r ".proKey // empty" /run/secrets/proKey 2>/dev/null || echo "") && \
109109
OFFLINE_KEY=$(cat /run/secrets/offlineKey 2>/dev/null || echo "") && \
110-
./mvnw clean package -Pproduction -DskipTests -Dvaadin.proKey=${PRO_KEY} -Dvaadin.offlineKey=${OFFLINE_KEY}'
110+
./mvnw clean package -DskipTests -Dvaadin.proKey=${PRO_KEY} -Dvaadin.offlineKey=${OFFLINE_KEY}'
111111
----
112112
113113
For more information about build secrets in Docker, see the https://docs.docker.com/build/building/secrets/[Docker documentation].

0 commit comments

Comments
 (0)