Skip to content

Commit

Permalink
Fixes #228 - Separate UI into its own module (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Jul 23, 2024
1 parent e2c5f78 commit 05a2091
Show file tree
Hide file tree
Showing 22 changed files with 1,769 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
<name>Manorrock.com</name>
<url>http://www.manorrock.com</url>
</organization>
<properties>
<!-- other -->
<piranha.version>24.7.0</piranha.version>
</properties>
<modules>
<module>repo</module>
<module>ui</module>
</modules>
</project>
1 change: 0 additions & 1 deletion repo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<jaxb-runtime.version>4.0.3</jaxb-runtime.version>
<junit.version>5.10.0</junit.version>
<oyena.version>23.5.0</oyena.version>
<piranha.version>24.4.0</piranha.version>
<!-- other -->
<java.version>21</java.version>
<piranha.distribution>webprofile</piranha.distribution>
Expand Down
28 changes: 28 additions & 0 deletions ui/nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
<goal>piranha:run</goal>
</goals>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
<goal>piranha:run</goal>
</goals>
</action>
</actions>
169 changes: 169 additions & 0 deletions ui/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.manorrock.persian</groupId>
<artifactId>project</artifactId>
<version>23.8.0-SNAPSHOT</version>
</parent>
<artifactId>persian-ui</artifactId>
<packaging>war</packaging>
<name>Manorrock Persian - UI</name>
<organization>
<name>Manorrock.com</name>
<url>http://www.manorrock.com</url>
</organization>
<properties>
<!-- dependencies -->
<jakarta.jakartaee-web-api.version>10.0.0</jakarta.jakartaee-web-api.version>
<jaxb-runtime.version>4.0.3</jaxb-runtime.version>
<junit.version>5.10.0</junit.version>
<oyena.version>23.5.0</oyena.version>
<!-- other -->
<java.version>21</java.version>
<piranha.distribution>webprofile</piranha.distribution>
<piranha.httpPort>8080</piranha.httpPort>
<!--<piranha.jvmArguments>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000</piranha.jvmArguments>-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- plugins -->
<docker-maven-plugin.version>0.42.1</docker-maven-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
</properties>
<build>
<finalName>persian-ui</finalName>
<plugins>
<plugin>
<groupId>cloud.piranha.maven.plugins</groupId>
<artifactId>piranha-maven-plugin</artifactId>
<version>${piranha.version}</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<distribution>${piranha.distribution}</distribution>
<httpPort>${piranha.httpPort}</httpPort>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- compile -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
<scope>compile</scope>
<exclusions>
<!--
Excluding be cause this causes a ClassNotFoundException as
per https://github.com/eclipse-ee4j/jaxb-ri/issues/1703
-->
<exclusion>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-activation</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- runtime -->
<dependency>
<groupId>com.manorrock.oyena.lifecycle</groupId>
<artifactId>oyena-lifecycle-action</artifactId>
<version>${oyena.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.manorrock.oyena.lifecycle</groupId>
<artifactId>oyena-lifecycle-cdi</artifactId>
<version>${oyena.version}</version>
<scope>runtime</scope>
</dependency>
<!-- provided -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>${jakarta.jakartaee-web-api.version}</version>
<scope>provided</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<images>
<image>
<alias>persian</alias>
<name>ghcr.io/manorrock/persian:%l</name>
<build>
<buildx>
<platforms>
<platform>linux/amd64</platform>
<platform>linux/arm64</platform>
</platforms>
</buildx>
<contextDir>${basedir}</contextDir>
<dockerFile>src/main/docker/Dockerfile</dockerFile>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
33 changes: 33 additions & 0 deletions ui/settings.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>localhost</id>
<name>localhost</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
<url>http://localhost:8080/repositories</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
</settings>
6 changes: 6 additions & 0 deletions ui/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/piranhacloud/webprofile:23.8.0
COPY target/persian.war ROOT.war
USER root
RUN chown -R piranha:piranha /home/piranha
USER piranha
CMD ["java", "-jar", "piranha-dist-webprofile.jar", "--war-file", "ROOT.war", "--webapp-directory", "ROOT", "--verbose"]
48 changes: 48 additions & 0 deletions ui/src/main/java/com/manorrock/persian/rest/RestApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.manorrock.persian.rest;

import java.util.HashSet;
import java.util.Set;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

/**
* The Persian application.
*
* @author Manfred Riem (mriem@manorrock.com)
*/
@ApplicationPath("repositories")
public class RestApplication extends Application {

@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
classes.add(RestResource.class);
return classes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.manorrock.persian.rest;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import java.io.File;
import static java.util.logging.Level.INFO;
import java.util.logging.Logger;

/**
* The one and only application bean.
*
* @author Manfred Riem (mriem@manorrock.com)
*/
@ApplicationScoped
public class RestApplicationBean {

/**
* Stores the logger.
*/
private static final Logger LOGGER = Logger.getLogger(RestApplicationBean.class.getPackageName());

/**
* Stores the root directory.
*/
private File rootDirectory;

/**
* Get the root directory.
*
* @return the root directory.
*/
public File getRootDirectory() {
return rootDirectory;
}

/**
* Initialize the bean.
*/
@PostConstruct
public void initialize() {
String rootDirectoryFilename = System.getenv("PERSIAN_REPOSITORIES_DIRECTORY");
if (rootDirectoryFilename == null) {
rootDirectoryFilename = System.getProperty("PERSIAN_REPOSITORIES_DIRECTORY",
System.getProperty("user.home") + "/.manorrock/persian/repositories");
}

if (LOGGER.isLoggable(INFO)) {
LOGGER.log(INFO, "Repositories directory: {0}", rootDirectoryFilename);
}

rootDirectory = new File(rootDirectoryFilename);
if (!rootDirectory.exists()) {
rootDirectory.mkdirs();
}
}
}
Loading

0 comments on commit 05a2091

Please sign in to comment.