Skip to content

Commit b2de9dc

Browse files
committed
Initial commit.
0 parents  commit b2de9dc

33 files changed

+1777
-0
lines changed

.gitignore

+21
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+
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

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 17.0.8-amzn \
26+
&& sdk default java 17.0.8-amzn"

.gitpod.yml

+14
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==
+118
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.

.mvn/wrapper/maven-wrapper.properties

+18
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

LICENSE.md

+24
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

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Github Copilot Coding Challenge
2+
This is a playground project for testing out Github Copilot with Vaadin Flow.
3+
4+
For more information you can refer to this Google Docs document: https://docs.google.com/document/d/1fgkVuvlDYJ6lN3bvQHjuhZK0hBu5rJHGao_bXMc5ISU/edit
5+
6+
## Scoring (optional)
7+
8+
In case you are up for it you can fill in the scorecard in the next section. This is purely for fun and to enhance the sense of accomplishment as part of the coding challenge. The main point of the challenge is to learn something new. If you accomplish this you are a winner 🙂
9+
10+
For solving a single challenge you get 1 point. You can also increase the points you get from a single solution using the following difficulty modifiers
11+
12+
13+
| Modifier | Points |
14+
|:-----------------------------------------------------------|:-------|
15+
| Use an IDE that you usually don’t normally use | x 1.5 |
16+
| Write the solution in a language you are not familiar with | x 2 |
17+
| Do the challenge another time in a different way | x 2 |
18+
| < Add your own modifiers here > | |
19+
20+
## Scorecard (optional)
21+
22+
| Challenge | Points |
23+
|:-----------------------------------------------------------|:-------|
24+
| Solve FizzBuzz 30 | |
25+
| Solve Bubble sort | |
26+
| Solve Fibonacci average | |
27+
| Generate enums from a text file | |
28+
| Generate translations for a new language | |
29+
| Migrate a class from Java to another language | |
30+
| Generate 100 person’s names | |
31+
| Write unit test cases for a previous algorithm | |
32+
| Write TestBench tests | |
33+
| Write TestBench unit tests | |
34+
| Refactor selection into a new method | |
35+
| Modernize Java code | |
36+
| Optimize BogoSort into something better | |
37+
| Optimize an algorithm | |
38+
| Ask Copilot to explain you a piece of code | |
39+
| Add JavaDocs | |
40+
| Find bugs in org.vaadin.challenges.bugs | |
41+
| Evaluate InsecureCodeExample for potential security issues | |
42+
| Implement Game of Life | |
43+
| Implement Tetris | |
44+
| < Add your own challenges here to keep going > | |
45+
| Total | |
46+
47+
48+
49+
# Project Base for Vaadin and Spring Boot
50+
51+
This project can be used as a starting point to create your own Vaadin application with Spring Boot.
52+
It contains all the necessary configuration and some placeholder files to get you started.
53+
54+
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.
55+
56+
## Running the Application
57+
There are two ways to run the application : using `mvn spring-boot:run` or by running the `Application` class directly from your IDE.
58+
59+
You can use any IDE of your preference,but we suggest Eclipse or Intellij IDEA.
60+
Below are the configuration details to start the project using a `spring-boot:run` command. Both Eclipse and Intellij IDEA are covered.
61+
62+
#### Eclipse
63+
- Right click on a project folder and select `Run As` --> `Maven build..` . After that a configuration window is opened.
64+
- In the window set the value of the **Goals** field to `spring-boot:run`
65+
- You can optionally select `Skip tests` checkbox
66+
- All the other settings can be left to default
67+
68+
Once configurations are set clicking `Run` will start the application
69+
70+
#### Intellij IDEA
71+
- On the right side of the window, select Maven --> Plugins--> `spring-boot` --> `spring-boot:run` goal
72+
- Optionally, you can disable tests by clicking on a `Skip Tests mode` blue button.
73+
74+
Clicking on the green run button will start the application.
75+
76+
After the application has started, you can view your it at http://localhost:8080/ in your browser.
77+
78+
79+
If you want to run the application locally in the production mode, use `spring-boot:run -Pproduction` command instead.
80+
### Running Integration Tests
81+
82+
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
83+
84+
`mvn verify -Pit,production`
85+
86+
and make sure you have a valid TestBench license installed.
87+
88+
Profile `it` adds the following parameters to run integration tests:
89+
```sh
90+
-Dwebdriver.chrome.driver=path_to_driver
91+
-Dcom.vaadin.testbench.Parameters.runLocally=chrome
92+
```
93+
94+
If you would like to run a separate test make sure you have added these parameters to VM Options of JUnit run configuration
95+
96+
### Live Reload (optional)
97+
98+
With live reload, you can see the results of your code changes immediately.
99+
When you edit your Java code and recompile it, the application changes will be automatically reloaded and the browser is refreshed.
100+
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).
101+
To be able to see the changes in the browser tab, the page still needs to be reloaded.
102+
That can also be automated via a LiveReload browser extension.
103+
One such extension for Google Chrome is [LiveReload](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei).
104+
In Firefox, [LiveReload - Web extension](https://addons.mozilla.org/en-US/firefox/addon/livereload-web-extension/) can be used.
105+
You can find such similar extensions for other major browsers too.
106+
These extensions add an icon to your browser next to the address bar.
107+
To enable the extension, you should click that icon after you opened your application.
108+
109+
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.
110+
111+
## Structure
112+
113+
Vaadin web applications are full-stack and include both client-side and server-side code in the same project.
114+
115+
| Directory | Description |
116+
| :--- | :--- |
117+
| `frontend/` | Client-side source directory |
118+
| &nbsp;&nbsp;&nbsp;&nbsp;`index.html` | HTML template |
119+
| &nbsp;&nbsp;&nbsp;&nbsp;`index.ts` | Frontend entrypoint |
120+
| &nbsp;&nbsp;&nbsp;&nbsp;`main-layout.ts` | Main layout Web Component (optional) |
121+
| &nbsp;&nbsp;&nbsp;&nbsp;`views/` | UI views Web Components (TypeScript / HTML) |
122+
| &nbsp;&nbsp;&nbsp;&nbsp;`styles/` | Styles directory (CSS) |
123+
| `src/main/java/<groupId>/` | Server-side source directory |
124+
| &nbsp;&nbsp;&nbsp;&nbsp;`Application.java` | Server entrypoint |
125+
| &nbsp;&nbsp;&nbsp;&nbsp;`AppShell.java` | application-shell configuration |
126+
127+
## Useful links
128+
129+
- Read the documentation at [vaadin.com/docs](https://vaadin.com/docs).
130+
- Follow the tutorials at [vaadin.com/tutorials](https://vaadin.com/tutorials).
131+
- Watch training videos and get certified at [vaadin.com/learn/training](https://vaadin.com/learn/training).
132+
- Create new projects at [start.vaadin.com](https://start.vaadin.com/).
133+
- Search UI components and their usage examples at [vaadin.com/components](https://vaadin.com/components).
134+
- View use case applications that demonstrate Vaadin capabilities at [vaadin.com/examples-and-demos](https://vaadin.com/examples-and-demos).
135+
- 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).
136+
- Find a collection of solutions to common use cases in [Vaadin Cookbook](https://cookbook.vaadin.com/).
137+
- Find Add-ons at [vaadin.com/directory](https://vaadin.com/directory).
138+
- Ask questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/vaadin) or join our [Discord channel](https://discord.gg/MYFq5RTbBn).
139+
- Report issues, create pull requests in [GitHub](https://github.com/vaadin/platform).

frontend/index.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8"/>
5+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
6+
<title>###Project Name###</title>
7+
<style>
8+
body {
9+
height: 100vh;
10+
margin: 0;
11+
}
12+
13+
#outlet {
14+
height: 100%;
15+
}
16+
</style>
17+
<!-- index.ts is included here automatically (either by the dev server or during the build) -->
18+
</head>
19+
<body>
20+
<div id="outlet"></div>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)