Skip to content

Commit b5cc716

Browse files
committed
first commit
0 parents  commit b5cc716

32 files changed

+1846
-0
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/target/
2+
.idea/
3+
.vscode/
4+
.settings
5+
.project
6+
.classpath
7+
8+
*.iml
9+
.DS_Store
10+
11+
# The following files are generated/updated by vaadin-maven-plugin
12+
node_modules/
13+
src/main/frontend/generated/
14+
pnpmfile.js
15+
vite.generated.ts
16+
17+
# Browser drivers for local integration tests
18+
drivers/
19+
# Error screenshots generated by TestBench for failed integration tests
20+
error-screenshots/
21+
webpack.generated.js

.gitpod.Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM gitpod/workspace-full
2+
3+
RUN sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
4+
RUN sudo apt-get -q update
5+
RUN sudo apt -y install ./google-chrome-stable_current_amd64.deb
6+
RUN sudo apt-get -y install libnss3\
7+
libnspr4\
8+
libatk1.0-0\
9+
libatk-bridge2.0-0\
10+
libcups2\
11+
libdrm2\
12+
libxkbcommon0\
13+
libxcomposite1\
14+
libxdamage1\
15+
libxfixes3\
16+
libxrandr2\
17+
libgbm1\
18+
libgtk-3-0\
19+
libatspi2.0-0\
20+
libx11-xcb-dev
21+
RUN sudo rm -rf /var/lib/apt/lists/*
22+
23+
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
24+
&& sdk update \
25+
&& sdk install java 11.0.9-amzn \
26+
&& sdk install java 11.0.9-trava \
27+
&& sdk default java 11.0.9-amzn"

.gitpod.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tasks:
2+
- init: mvn package -Pproduction
3+
4+
command: mvn
5+
ports:
6+
- port: 8080
7+
onOpen: open-preview
8+
image:
9+
file: .gitpod.Dockerfile
10+
vscode:
11+
extensions:
12+
- [email protected]:llHUlx8TJ6tFKGa1t6dpLQ==
13+
- [email protected]:gNh98vNbqtZC6ydHasFxAQ==
14+
- [email protected]:1iLvjTfznJrV611qRUeOHg==
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.net.*;
17+
import java.io.*;
18+
import java.nio.channels.*;
19+
import java.util.Properties;
20+
21+
public class MavenWrapperDownloader {
22+
23+
private static final String WRAPPER_VERSION = "0.5.6";
24+
/**
25+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is
26+
* provided.
27+
*/
28+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
29+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
30+
31+
/**
32+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl
33+
* property to use instead of the default one.
34+
*/
35+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
36+
37+
/**
38+
* Path where the maven-wrapper.jar will be saved to.
39+
*/
40+
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
41+
42+
/**
43+
* Name of the property which should be used to override the default download
44+
* url for the wrapper.
45+
*/
46+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47+
48+
public static void main(String args[]) {
49+
System.out.println("- Downloader started");
50+
File baseDirectory = new File(args[0]);
51+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52+
53+
// If the maven-wrapper.properties exists, read it and check if it contains a
54+
// custom
55+
// wrapperUrl parameter.
56+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
57+
String url = DEFAULT_DOWNLOAD_URL;
58+
if (mavenWrapperPropertyFile.exists()) {
59+
FileInputStream mavenWrapperPropertyFileInputStream = null;
60+
try {
61+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
62+
Properties mavenWrapperProperties = new Properties();
63+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
64+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
65+
} catch (IOException e) {
66+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
67+
} finally {
68+
try {
69+
if (mavenWrapperPropertyFileInputStream != null) {
70+
mavenWrapperPropertyFileInputStream.close();
71+
}
72+
} catch (IOException e) {
73+
// Ignore ...
74+
}
75+
}
76+
}
77+
System.out.println("- Downloading from: " + url);
78+
79+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
80+
if (!outputFile.getParentFile().exists()) {
81+
if (!outputFile.getParentFile().mkdirs()) {
82+
System.out.println(
83+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
84+
}
85+
}
86+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
87+
try {
88+
downloadFileFromURL(url, outputFile);
89+
System.out.println("Done");
90+
System.exit(0);
91+
} catch (Throwable e) {
92+
System.out.println("- Error downloading");
93+
e.printStackTrace();
94+
System.exit(1);
95+
}
96+
}
97+
98+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
99+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
100+
String username = System.getenv("MVNW_USERNAME");
101+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
102+
Authenticator.setDefault(new Authenticator() {
103+
@Override
104+
protected PasswordAuthentication getPasswordAuthentication() {
105+
return new PasswordAuthentication(username, password);
106+
}
107+
});
108+
}
109+
URL website = new URL(urlString);
110+
ReadableByteChannel rbc;
111+
rbc = Channels.newChannel(website.openStream());
112+
FileOutputStream fos = new FileOutputStream(destination);
113+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
114+
fos.close();
115+
rbc.close();
116+
}
117+
118+
}

.mvn/wrapper/maven-wrapper.jar

57.4 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 120,
4+
"bracketSameLine": true
5+
}
6+

LICENSE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org>

README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Project Base for Vaadin and Spring Boot
2+
3+
This project can be used as a starting point to create your own Vaadin application with Spring Boot.
4+
It contains all the necessary configuration and some placeholder files to get you started.
5+
6+
The best way to create your own project based on this starter is [start.vaadin.com](https://start.vaadin.com/) - you can get only the necessary parts and choose the package naming you want to use.
7+
8+
## Running the Application
9+
There are two ways to run the application : using `mvn spring-boot:run` or by running the `Application` class directly from your IDE.
10+
11+
You can use any IDE of your preference,but we suggest Eclipse or Intellij IDEA.
12+
Below are the configuration details to start the project using a `spring-boot:run` command. Both Eclipse and Intellij IDEA are covered.
13+
14+
#### Eclipse
15+
- Right click on a project folder and select `Run As` --> `Maven build..` . After that a configuration window is opened.
16+
- In the window set the value of the **Goals** field to `spring-boot:run`
17+
- You can optionally select `Skip tests` checkbox
18+
- All the other settings can be left to default
19+
20+
Once configurations are set clicking `Run` will start the application
21+
22+
#### Intellij IDEA
23+
- On the right side of the window, select Maven --> Plugins--> `spring-boot` --> `spring-boot:run` goal
24+
- Optionally, you can disable tests by clicking on a `Skip Tests mode` blue button.
25+
26+
Clicking on the green run button will start the application.
27+
28+
After the application has started, you can view your it at http://localhost:8080/ in your browser.
29+
30+
31+
If you want to run the application locally in the production mode, use `spring-boot:run -Pproduction` command instead.
32+
### Running Integration Tests
33+
34+
Integration tests are implemented using [Vaadin TestBench](https://vaadin.com/testbench). The tests take a few minutes to run and are therefore included in a separate Maven profile. We recommend running tests with a production build to minimize the chance of development time toolchains affecting test stability. To run the tests using Google Chrome, execute
35+
36+
`mvn verify -Pit,production`
37+
38+
and make sure you have a valid TestBench license installed.
39+
40+
Profile `it` adds the following parameters to run integration tests:
41+
```sh
42+
-Dwebdriver.chrome.driver=path_to_driver
43+
-Dcom.vaadin.testbench.Parameters.runLocally=chrome
44+
```
45+
46+
If you would like to run a separate test make sure you have added these parameters to VM Options of JUnit run configuration
47+
48+
### Live Reload (optional)
49+
50+
With live reload, you can see the results of your code changes immediately.
51+
When you edit your Java code and recompile it, the application changes will be automatically reloaded and the browser is refreshed.
52+
This is done by leveraging [Spring Boot Developer Tools](https://docs.spring.io/spring-boot/docs/2.1.5.RELEASE/reference/html/using-boot-devtools.html).
53+
To be able to see the changes in the browser tab, the page still needs to be reloaded.
54+
That can also be automated via a LiveReload browser extension.
55+
One such extension for Google Chrome is [LiveReload](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei).
56+
In Firefox, [LiveReload - Web extension](https://addons.mozilla.org/en-US/firefox/addon/livereload-web-extension/) can be used.
57+
You can find such similar extensions for other major browsers too.
58+
These extensions add an icon to your browser next to the address bar.
59+
To enable the extension, you should click that icon after you opened your application.
60+
61+
You can find more information at [Live Reload in Spring Boot Applications](https://vaadin.com/docs/flow/workflow/tutorial-spring-boot-live-reload.html) document.
62+
63+
## Structure
64+
65+
Vaadin web applications are full-stack and include both client-side and server-side code in the same project.
66+
67+
| Directory | Description |
68+
|:-------------------------------------------| :--- |
69+
| `src/main/frontend/` | Client-side source directory |
70+
| &nbsp;&nbsp;&nbsp;&nbsp;`index.html` | HTML template |
71+
| &nbsp;&nbsp;&nbsp;&nbsp;`index.ts` | Frontend entrypoint |
72+
| &nbsp;&nbsp;&nbsp;&nbsp;`main-layout.ts` | Main layout Web Component (optional) |
73+
| &nbsp;&nbsp;&nbsp;&nbsp;`views/` | UI views Web Components (TypeScript / HTML) |
74+
| &nbsp;&nbsp;&nbsp;&nbsp;`styles/` | Styles directory (CSS) |
75+
| `src/main/java/<groupId>/` | Server-side source directory |
76+
| &nbsp;&nbsp;&nbsp;&nbsp;`Application.java` | Server entrypoint |
77+
| &nbsp;&nbsp;&nbsp;&nbsp;`AppShell.java` | application-shell configuration |
78+
79+
## Code Formatting
80+
81+
The project includes the Spotless code formatter.
82+
83+
To use it in IntelliJ, install the [https://plugins.jetbrains.com/plugin/22455-spotless-applier](IntelliJ plugin)
84+
To use it in VS Code, install the [https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-spotless-gradle ](VS Code extension)
85+
To use it from the command line, run `mvn spotless:apply`
86+
87+
## Useful links
88+
89+
- Read the documentation at [vaadin.com/docs](https://vaadin.com/docs).
90+
- Follow the tutorials at [vaadin.com/tutorials](https://vaadin.com/tutorials).
91+
- Watch training videos and get certified at [vaadin.com/learn/training](https://vaadin.com/learn/training).
92+
- Create new projects at [start.vaadin.com](https://start.vaadin.com/).
93+
- Search UI components and their usage examples at [vaadin.com/components](https://vaadin.com/components).
94+
- View use case applications that demonstrate Vaadin capabilities at [vaadin.com/examples-and-demos](https://vaadin.com/examples-and-demos).
95+
- Discover Vaadin's set of CSS utility classes that enable building any UI without custom CSS in the [docs](https://vaadin.com/docs/latest/ds/foundation/utility-classes).
96+
- Find a collection of solutions to common use cases in [Vaadin Cookbook](https://cookbook.vaadin.com/).
97+
- Find Add-ons at [vaadin.com/directory](https://vaadin.com/directory).
98+
- Ask questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/vaadin) or join our [Discord channel](https://discord.gg/MYFq5RTbBn).
99+
- Report issues, create pull requests in [GitHub](https://github.com/vaadin/platform).

0 commit comments

Comments
 (0)