Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOUDTRUST-773] Refactor POM hierarchy #19

Merged
merged 1 commit into from Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -29,3 +29,4 @@ hs_err_pid*

# target
target/
bin/
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -9,7 +9,7 @@ The aim of this module is to send those Events and AdminEvents to another server
Java 8 is required (Java 9+ is not supported yet).

### Build and Tests
This module contains both unit and integration tests, and a parent inherited from Keycloak tests for simplifying the
This project 2 modules, one with the event emitter code (could contain unit tests) and one for integration tests using a parent inherited from Keycloak tests for simplifying the
POM content.

The integration tests rely on the arquillian-based Keycloak test framework. As Keycloak does not publish publicly
Expand All @@ -29,12 +29,12 @@ with the module.
## Installation
Event emitter module is expected to be installed as a module in a specific layer.

To install the release, use the TAR.GZ file produced by the build; either run the `install.sh` script
To install the release, go to event-emitter module directory and use the TAR.GZ file produced by the build; either run the `install.sh` script
or manually proceed as follows:

```Bash
# Install the module binaries
tar -zxf event-emitter-<version>.Final-dist.tar.gz --directory <PATH_TO_KEYCLOAK>/modules/system/layers
tar -zxf keycloak-event-emitter-<version>-dist.tar.gz --directory <PATH_TO_KEYCLOAK>/modules/system/layers

# Set the appropriate permissions on the new files
chmod -R 755 <PATH_TO_KEYCLOAK>/modules/system/layers/event-emitter
Expand Down Expand Up @@ -101,6 +101,7 @@ This module will authenticate itself to the server endpoint with Basic authentic

### Flatbuffers

Go to event-emitter module directory.
Flatbuffers schema is located under src/main/flatbuffers/flatbuffers/event.fbs.

Compilation of the schema
Expand Down
123 changes: 123 additions & 0 deletions keycloak-event-emitter-tests/pom.xml
@@ -0,0 +1,123 @@
<?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>io.cloudtrust</groupId>
<artifactId>kc-cloudtrust-testsuite</artifactId>
<version>7.0.0</version>
<relativePath/>
</parent>

<artifactId>keycloak-event-emitter-tests</artifactId>

<properties>
<apache-cxf.version>3.2.9</apache-cxf.version>
</properties>

<dependencies>
<dependency>
<groupId>io.cloudtrust</groupId>
<artifactId>keycloak-event-emitter</artifactId>
<version>${project.version}</version>
</dependency>

<!--keycloak -->
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-tests-base</artifactId>
<version>${keycloak.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-tests-console</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- CXF -->
<dependency>
<groupId>org.apache.cxf.services.sts</groupId>
<artifactId>cxf-services-sts-core</artifactId>
<version>${apache-cxf.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-features-logging</artifactId>
<version>${apache-cxf.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<!--dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency-->
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>${version.jboss.maven.plugin}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${version.frontend.maven.plugin}</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jboss.server.config.dir>src/test/resources</jboss.server.config.dir>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
File renamed without changes.
13 changes: 8 additions & 5 deletions install.sh → keycloak-event-emitter/install.sh 100755 → 100644
Expand Up @@ -5,7 +5,9 @@
# event-emitter

set -eE

MODULE_DIR=$(dirname $0)
TARGET_DIR=$MODULE_DIR/target
LIBRARY_DIR=${MODULE_DIR}/lib-modules

usage ()
{
Expand Down Expand Up @@ -76,9 +78,9 @@ init()
CONF_FILE=$argv__KEYCLOAK/standalone/configuration/standalone.xml
fi
echo $CONF_FILE
MODULE_NAME=$(xmlstarlet sel -N oe="urn:jboss:module:1.3" -t -v '/oe:module/@name' -n module.xml)
MODULE_NAME=$(xmlstarlet sel -N oe="urn:jboss:module:1.3" -t -v '/oe:module/@name' -n $MODULE_DIR/module.xml)
MODULE=${MODULE_NAME##*.}
JAR_PATH=`find ./target/ -type f -name "*.jar" -not -name "*sources.jar"`
JAR_PATH=`find $TARGET_DIR/ -type f -name "*.jar" -not -name "*sources.jar"`
JAR_NAME=`basename $JAR_PATH`
MODULE_PATH=${MODULE_NAME//./\/}/main
}
Expand All @@ -98,6 +100,7 @@ cleanup()
xmlstarlet ed -L -N c="urn:jboss:domain:keycloak-server:1.1" -d "/_:server/_:profile/c:subsystem/c:providers/c:provider[text()='module:$MODULE_NAME']" $CONF_FILE
xmlstarlet ed -L -N c="urn:jboss:domain:keycloak-server:1.1" -d "/_:server/_:profile/c:subsystem/c:spi[@name='eventsListener']/c:provider[@name='event-emitter']" $CONF_FILE
sed -i "$ s/,$MODULE$//" $argv__KEYCLOAK/modules/layers.conf
sed -i "$ s/\([=,]\)$MODULE,/\1/" $argv__KEYCLOAK/modules/layers.conf
rm -rf $argv__KEYCLOAK/modules/system/layers/$MODULE
echo "done"
}
Expand Down Expand Up @@ -139,7 +142,7 @@ Main__main()
# install module
mkdir -p $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/
cp $JAR_PATH $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/
cp module.xml $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/
cp $MODULE_DIR/module.xml $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/
sed -i "s@JAR_NAME@${JAR_NAME}@g" $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/module.xml
if ! grep -q "$MODULE" "$argv__KEYCLOAK/modules/layers.conf"; then
sed -i "$ s/$/,$MODULE/" $argv__KEYCLOAK/modules/layers.conf
Expand Down Expand Up @@ -175,7 +178,7 @@ Main__main()
xmlstarlet ed -L -N c="urn:jboss:domain:keycloak-server:1.1" -i "/_:server/_:profile/c:subsystem/c:spi[@name='eventsListener']/c:provider/c:properties/c:property[@name='datacenterId']" -t attr -n value -v '1' $CONF_FILE

# copy libs to main directory
cp lib-modules/main/* $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/
cp ${LIBRARY_DIR}/main/* $argv__KEYCLOAK/modules/system/layers/$MODULE/$MODULE_PATH/

exit 0
}
Expand Down
File renamed without changes.
86 changes: 86 additions & 0 deletions keycloak-event-emitter/pom.xml
@@ -0,0 +1,86 @@
<?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>io.cloudtrust</groupId>
<artifactId>keycloak-event-emitter-parent</artifactId>
<version>7.0.0</version>
</parent>

<artifactId>keycloak-event-emitter</artifactId>
<description>Keycloak module to transmit events to keycloak-bridge</description>
<packaging>jar</packaging>

<properties>
<jackson.version>2.9.10</jackson.version>
</properties>

<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi-private</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>

<!-- 3rd Party libraries-->
<dependency>
<groupId>com.google.flatbuffers</groupId>
<artifactId>flatbuffers-java</artifactId>
<version>1.10.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
</plugin>
</plugins>
</build>
</project>