Skip to content

Commit

Permalink
chore: mostly code cleanup / upgrades / support / improvements and un…
Browse files Browse the repository at this point in the history
…it tests

- Upgraded java versions in generator projects to 17
- Added docker support
- Made some markdown improvements to the README file and added a Docker section
- Cleaned up the code some
- The downloaded zip file will now be called according to the provided artifactId.zip or jakarta-project.zip if not provided
- The artifact will be moved from target to artifact for development purposes (docker)
- added some convenience scripts
- Added an example HttpRequest.http to the test resources
- added the artifact folder to git ignore
- Added unit test for StarterServlet
- removed the zip in src/main/resources as it is not needed
- updated github actions
- using eclipse temurin 17 for the builds in java 17
  • Loading branch information
IvoNet committed Nov 27, 2022
1 parent 8966272 commit 3be34d5
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 125 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -137,4 +137,29 @@ jobs:
- name: Run TomEE REST Application Maven Build
run: mvn clean package --file app/rest/tomee/jakartaee-cafe/pom.xml

build-java-17:
runs-on: ubuntu-20.04
strategy:
matrix:
java: [ 17 ]
name: Java ${{ matrix.Java }}
steps:
- uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}

- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build maven-project-generator
run: mvn clean install --file maven-project-generator/pom.xml

- name: Build starter-ui
run: mvn clean package --file starter-ui/pom.xml
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -92,3 +92,5 @@ buildNumber.properties
jakartaee-cafe-data
jakartaee-cafe-test-data
.vscode/settings.json

artifact/
23 changes: 19 additions & 4 deletions README.md
Expand Up @@ -22,16 +22,31 @@ There are currently multiple separate Archetypes available.

There is also a demo archetype with demonstrates more features of Jakarta EE.

* The [REST/CRUD archetype](rest-starter) generates a simple RESTful CRUD service using a representative set of Jakarta EE technologies such as REST, Enterprise Beans, CDI, Persistence, JSON Binding and Bean Validation. It also includes JUnit tests.
* The [REST/CRUD archetype](rest-starter) generates a simple RESTful CRUD service using a representative set of Jakarta
EE technologies such as REST, Enterprise Beans, CDI, Persistence, JSON Binding and Bean Validation. It also includes
JUnit tests.

Please look at the documentation for the respective archetypes on how to use them. If desired, you can easily use the Maven Archetypes from a Maven capable IDE such as [Eclipse](https://www.eclipse.org/ide). The generated starter code is simply Maven projects. You can easily load, explore and run the code in a Maven capable IDE such as [Eclipse](https://www.eclipse.org/ide).
Please look at the documentation for the respective archetypes on how to use them. If desired, you can easily use the
Maven Archetypes from a Maven capable IDE such as [Eclipse](https://www.eclipse.org/ide). The generated starter code is
simply Maven projects. You can easily load, explore and run the code in a Maven capable IDE such
as [Eclipse](https://www.eclipse.org/ide).

## Roadmap

The following is a high level roadmap for the project. All contributions are welcome advancing any of this work.
* Add support for other [Jakarta EE compatible runtimes](https://jakarta.ee/compatibility) such as [WildFly](https://github.com/eclipse-ee4j/starter/issues/113) and [Open Liberty](https://github.com/eclipse-ee4j/starter/issues/112).

* Add support for other [Jakarta EE compatible runtimes](https://jakarta.ee/compatibility) such
as [WildFly](https://github.com/eclipse-ee4j/starter/issues/113)
and [Open Liberty](https://github.com/eclipse-ee4j/starter/issues/112).
* [Transition to Jakarta EE 9.1](https://github.com/eclipse-ee4j/starter/issues/111).
* The complete Issue list can be found [here](https://github.com/eclipse-ee4j/starter/issues)

## Known Issues
* Note that Payara does not yet work on the Apple M1 chip. If you are on an M1 chip, we suggest you use GlassFish or TomEE for the time being with the archetypes.

* Note that Payara does not yet work on the Apple M1 chip. If you are on an M1 chip, we suggest you use GlassFish or
TomEE for the time being with the archetypes.

## Contributing

We welcome contributions to the project in many forms. Please see the [Contributing](CONTRIBUTING.md) page for more
information.
16 changes: 8 additions & 8 deletions maven-project-generator/pom.xml
Expand Up @@ -9,14 +9,14 @@
<artifactId>maven-project-generator</artifactId>
<packaging>jar</packaging>
<name>Maven Project Generator</name>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.8.6</version>
</dependency>

<!-- for Cli -->
<dependency>
<groupId>org.apache.maven.resolver</groupId>
Expand All @@ -41,7 +41,7 @@
</dependency>

<!-- end for Cli -->

<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -55,11 +55,11 @@
<scope>test</scope>
<version>3.23.1</version>
</dependency>

<!-- end for Testing -->

</dependencies>

<build>
<pluginManagement>
<plugins>
Expand All @@ -77,7 +77,7 @@
</pluginManagement>
</build>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>
</project>
8 changes: 4 additions & 4 deletions pom.xml
Expand Up @@ -132,13 +132,13 @@
</extensions>

</build>

<profiles>
<profile>
<!-- modules that require building with Java 11 -->
<id>jdk11plus</id>
<!-- modules that require building with Java 17 -->
<id>jdk17plus</id>
<activation>
<jdk>[11,)</jdk>
<jdk>[17,)</jdk>
</activation>
<modules>
<module>starter-ui</module>
Expand Down
6 changes: 6 additions & 0 deletions starter-ui/Dockerfile
@@ -0,0 +1,6 @@
FROM tomcat:10.0.27-jdk17-corretto

RUN rm -rf /usr/local/tomcat/webapps/* 2>/dev/null

ADD target/jakarta-starter-ui.war /usr/local/tomcat/webapps/ROOT.war

74 changes: 61 additions & 13 deletions starter-ui/README.md
@@ -1,33 +1,47 @@
This project serves the UI. It has s Servlet endpoint, which is supposed to take parameters, e.g. groupId, artifactId, version, runtime etc., and generate a downloadable zip folder.
# Starter-UI

This project serves the UI. It has s Servlet endpoint, which is supposed to take parameters, e.g. groupId, artifactId,
version, runtime etc., and generate a downloadable zip folder.
The following instruction works on `*nix` environment.

### Generate the war
## Pre-requisites

- Docker installed or Tomcat 10 installed

## Generate the war

Following maven command will generate the war.
```

```shell
mvn clean package
```
The command will generate `jakarta-starter-ui-1.1.0-SNAPSHOT.war` in the `/target` folder.

### Deployment & Running the UI
The command will generate `jakarta-starter-ui.war` in the `./artifact` folder.

## Deployment & Running the UI

This war would expect a Server 5+ or Jakarta EE 9+ runtime (such as tomcat 10 or Eclipse GlassFish 6).

### Deployment on Tomcat 10
Download Tomcat 10 from the following URL-
## Deployment on Tomcat 10

`https://tomcat.apache.org/download-10.cgi`
Download Tomcat 10 from the following URL:

[https://tomcat.apache.org/download-10.cgi](https://tomcat.apache.org/download-10.cgi)

Unzip it, and put it in a folder. It can be at any location. Then, remove all the contents of `webapps` folder.

```
```shell
cd ~/apache-tomcat-10.0.21/webapps
rm -rf .
```
Rename the applicatoin WAR to `ROOT.war`

```a
mv target/jakarta-starter-ui-1.1.0-SNAPSHOT.war ROOT.war
Rename the application WAR to `ROOT.war`

```shell
mv artifact/jakarta-starter-ui.war ROOT.war
```
Copy the `ROOT.war` and paste it into this `webapps` folder.

Copy the `ROOT.war` and paste it into this `webapps` folder.

The following command will run Tomcat.

Expand All @@ -38,3 +52,37 @@ sh catalina.sh start

That's it. Now open the browser and hit `http://localhost:8080`

## Docker with Tomcat 10

With Docker you can deploy without having to install Tomcat 10 on your local machine.

### Build the image

from the `starter-ui` folder, run the following command to build the image.

```shell
docker build -t eclise/starter-ui .
```

### Run the container

```shell
docker run -it --rm -p 8080:8080 eclipse/starter-ui
```

### run in dev mode

In this you will mount a volume to the webapp folder so that you can make changes to the code and every new
`maven package` will be reflected in the running container.

```shell
docker run -it --rm -p 8080:8080 -v "$(pwd)/articat:/usr/local/tomcat/webapps" eclipse/starter-ui
```

See also the `build-docker.sh` and `run-docker.sh` scripts.

The endpoint is now available at `http://localhost:8080/jakarta-starter-ui`

e.g. [sample artifact](http://localhost:8080/jakarta-starter-ui/download.zip?archetypeGroupId=org.eclipse.starter&archetypeArtifactId=jakartaee10-minimal&archetypeVersion=1.1.0&groupId=com.sample&artifactId=hello_world&version=1.0.0-SNAPSHOT)

```
12 changes: 12 additions & 0 deletions starter-ui/build-docker.sh
@@ -0,0 +1,12 @@
#!/usr/bin/env bash


if ! mvn clean package; then
echo "Build failed"
exit 1
fi

if ! docker build -t eclipse/starter-ui .; then
echo "Docker build failed"
exit 1
fi
5 changes: 5 additions & 0 deletions starter-ui/docker-run-dev-mode.sh
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

rm -rf ./artifact 2>/dev/null
mvn clean package -U
docker run -it --rm -p 8080:8080 -v "$(pwd)/artifact:/usr/local/tomcat/webapps/" eclipse/starter-ui;
128 changes: 82 additions & 46 deletions starter-ui/pom.xml
@@ -1,49 +1,85 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jakarta-starter-modules</artifactId>
<groupId>org.eclipse.starter</groupId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>jakarta-starter-ui</artifactId>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.report.sourceEncoding>UTF-8</project.report.sourceEncoding>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>maven-project-generator</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jakarta-starter-modules</artifactId>
<groupId>org.eclipse.starter</groupId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>jakarta-starter-ui</artifactId>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.report.sourceEncoding>UTF-8</project.report.sourceEncoding>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>

<arquillian.version>1.7.0.Alpha13</arquillian.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>maven-project-generator</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.9.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.22.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>jakarta-starter-ui</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>./artifact</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 3be34d5

Please sign in to comment.