Skip to content

Commit

Permalink
EmpeddedMongoDB plugin (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
  • Loading branch information
rfelcman committed Dec 21, 2023
1 parent c0afde0 commit 48f305b
Show file tree
Hide file tree
Showing 19 changed files with 1,246 additions and 14 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0,
# or the Eclipse Distribution License v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#

name: eclipselink-build-support

on:
pull_request:
push:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Test on JDK ${{ matrix.java_version }}
runs-on: ubuntu-latest

strategy:
matrix:
java_version: [21]

steps:
- name: Checkout for build
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java_version }}
cache: maven
- name: Verify
run: |
cd el-maven-plugin
mvn -B -V -U -C clean verify -Pittest
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## eclipselink-testbuild-plugin

A maven plugin packaging eclipselink test application(s) for the deployment on the application
### goal - package-testapp
A maven plugin goal to package eclipselink test application(s) for the deployment on the application
server. It produces EJB jar and/or EAR application from the project structure with the content
as is outlined bellow and attaches built artifacts to the project.

Expand All @@ -29,3 +30,79 @@ mode (property: `el.packager.mode`):
`el.packager.descriptors` property can be set to `false` to explicitly disable generation of these descriptors
* classifier: ejb

#### Usage
```xml
<plugin>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink-testbuild-plugin</artifactId>
<executions>
<execution>
<id>package-server-tests</id>
<goals>
<goal>package-testapp</goal>
</goals>
<phase>package</phase>
<configuration>
<mode>EAR</mode>
</configuration>
</execution>
</executions>
</plugin>
```

### goals - start-mongo, stop-mongo
Download, start, stop specified version of embedded MongoDB.
Main purpose is use it in testing environment to start MongoDB before tests and stop after tests (integration testing in Maven environment).
This plugin was inspired by https://github.com/joelittlejohn/embedmongo-maven-plugin project which doesn't seem to be active now.
But number of plugin configuration parameters is limited per requirements of the EclipseLink project.
This plugin is wrapper for the [flapdoodle.de embedded MongoDB API](http://github.com/flapdoodle-oss/embedmongo.flapdoodle.de).

Minimal Java version is 11

```xml
<plugin>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink-testbuild-plugin</artifactId>
<executions>
<execution>
<id>start</id>
<phase>process-test-classes</phase>
<goals>
<goal>start-mongo</goal>
</goals>
<configuration>
<port>37017</port>
<!-- database port, optional, default 27017 -->

<version>6.0.8</version>
<!-- database version which will be downloaded or used if downloaded before, optional, default 7.0.0 -->

<features>STORAGE_ENGINE</features>
<!-- flapdoodle.embed.mongo features, for example to build Windows download URLs, optional, default is none -->

<logging>file</logging>
<!-- Logging output. Possible values are (file|console|none), optional, default console -->

<logFile>target/mongoTest.log</logFile>
<!-- If logging output is `file`, path relative or absolute where log file will be created, optional, default `embedmongo.log` -->

<logFileEncoding>utf-8</logFileEncoding>
<!-- If logging output is `file`, log file encoding, optional, default `utf-8` -->

<downloadPath>http://fastdl.mongodb.org/</downloadPath>
<!-- The base URL to be used when downloading MongoDB. This is first part of the URL. Second part is evaluated dynamically (based on current OS and specified version), optional, default is `http://fastdl.mongodb.org/` -->

<skip>false</skip>
<!-- skip plugin execution, optional, default `false` -->
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>prepare-package</phase>
<goals>
<goal>stop-mongo</goal>
</goals>
</execution>
</executions>
</plugin>
```
174 changes: 163 additions & 11 deletions el-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -30,11 +30,22 @@
<version>1.0.1-SNAPSHOT</version>
<name>EclipseLink Maven Build Plugin</name>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease>
<maven.version>3.8.6</maven.version>
<groovy.version>4.0.15</groovy.version>
<mongodb.version>4.11.0</mongodb.version>
<logback.version>1.4.11</logback.version>
<slf4j.version>2.0.9</slf4j.version>
<junit.version>4.13.1</junit.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.8.6</version>
<version>${maven.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand All @@ -46,19 +57,31 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.8.6</version>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.8.6</version>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.8.6</version>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -91,14 +114,46 @@
<artifactId>maven-resolver-api</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.process</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>${mongodb.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease>
</properties>


<build>
<pluginManagement>
<plugins>
Expand All @@ -122,6 +177,24 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand All @@ -142,4 +215,83 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>ittest</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>set-proxy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${project.basedir}/src/test/script/setproxy.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
<streamLogs>true</streamLogs>
<addTestClassPath>true</addTestClassPath>
<settingsFile>${project.build.directory}/it-settings.xml</settingsFile>
<mavenOpts>${ittest-proxy}</mavenOpts>
<properties>
<resgen.plugin.version>${project.version}</resgen.plugin.version>
<tp.compiler.release>${maven.compiler.release}</tp.compiler.release>
</properties>
</configuration>
<executions>
<execution>
<id>integration-test-installdeps</id>
<phase>pre-integration-test</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
<execution>
<id>integration-test</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<projectsDirectory>src/test/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test-verify</id>
<phase>post-integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<it.projects.dir>${project.build.directory}/it</it.projects.dir>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit 48f305b

Please sign in to comment.