Skip to content

Commit

Permalink
Merge pull request #241 from europeana/EA3647-update_to_mongo6
Browse files Browse the repository at this point in the history
Update to Morphia 1.6.1 and mongo driver 4.7.2
  • Loading branch information
gsergiu authored Mar 19, 2024
2 parents 978e58a + fb778cd commit fd6cff5
Show file tree
Hide file tree
Showing 42 changed files with 707 additions and 383 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/build_test_analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 171
uses: actions/setup-java@v3
with:
java-version: 11
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
distribution: 'temurin' #should use the same as in the docker file
java-version: 17
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Builds a docker image from a locally built Maven war. Requires 'mvn package' to have been run beforehand
# when needed the image can be switched from jre to jdk, but the jdk has about 200MB
#FROM eclipse-temurin:11-jdk-alpine
FROM eclipse-temurin:11-jre-alpine
#FROM eclipse-temurin:11-jre-alpine
FROM eclipse-temurin:17-jre-alpine
LABEL Author="Europeana Foundation <[email protected]>"

# Configure APM and add APM agent
Expand Down
2 changes: 1 addition & 1 deletion k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
image: europeana/set-api
env:
- name: SPRING_CONFIG_NAME
value: "set.common,set.user"
value: "application,set.common,set.user"
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: "/opt/app/config/set.user.properties"
ports:
Expand Down
141 changes: 120 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,30 @@

<properties>
<revision>0.12-SNAPSHOT</revision>
<version.java>11</version.java>
<version.javac.release>11</version.javac.release>
<version.log4j2>2.17.2</version.log4j2>
<version.commonsApi>0.3.22-SNAPSHOT</version.commonsApi>
<version.springBoot>2.5.7</version.springBoot>
<version.springBootMongoStarter>2.0.3.RELEASE</version.springBootMongoStarter>
<version.swagger>3.0.0</version.swagger>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>

<!-- property to be used for add opens jvm arguments in plugins -->
<java.17.addopens>--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
</java.17.addopens>
<version.commonsApi>0.3.24-SNAPSHOT</version.commonsApi>
<version.springBoot>2.5.14</version.springBoot>

<!-- overwrite version defined in spring boot parent pom -->
<mongodb.version>4.7.2</mongodb.version>
<version.morphia>1.6.1</version.morphia>

<springdoc.version>1.6.14</springdoc.version>

<version.httpClient>3.1</version.httpClient>
<version.javax.annotation>1.3.2</version.javax.annotation>
<version.jettison>1.3</version.jettison>
<version.jaxb>2.3.1</version.jaxb>
<version.junit>5.7.2</version.junit>
<version.commonsIO>2.8.0</version.commonsIO>
<version.surefire>3.0.0-M7</version.surefire>
<version.failsafe>3.0.0-M7</version.failsafe>

<!-- java version properties -->
<maven.compiler.source>${version.java}</maven.compiler.source>
Expand All @@ -62,10 +71,11 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- test dependencies -->
<version.testcontainers>1.16.0</version.testcontainers>
<version.testcontainers>1.19.7</version.testcontainers>

<!-- maven plugins -->
<version.maven-surfire-plugin>3.0.0-M6</version.maven-surfire-plugin>
<version.maven-surefire-plugin>3.0.0-M7</version.maven-surefire-plugin>
<version.maven-failsafe-plugin>3.0.0-M7</version.maven-failsafe-plugin>
<git-commit-id.version>5.0.0</git-commit-id.version>

<!-- sonar - jacoco properties -->
Expand All @@ -76,6 +86,7 @@
<sonar.java.pmd.reportPaths>${project.build.directory}/pmd.xml</sonar.java.pmd.reportPaths>
<sonar.java.spotbugs.reportPaths>${project.build.directory}/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
<sonar.organization>europeana</sonar.organization>
<!-- project key cannot be sent both as property and in command line (check github action) -->
<!--
<sonar.projectKey>europeana_set-api</sonar.projectKey>
-->
Expand All @@ -98,15 +109,87 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- upgrade mongo driver and morphia to support mongo V6-->
<!-- SG: for some reason, the versions from spring boot take precedence over the versions from api-commons depencies, therefore we need to replicate here the configs from api-commons -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-legacy</artifactId>
<version>${mongodb.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>${mongodb.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>${mongodb.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>${mongodb.version}</version>
</dependency>

<dependency>
<groupId>dev.morphia.morphia</groupId>
<artifactId>core</artifactId>
<version>${version.morphia}</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-legacy</artifactId>
</exclusion>
</exclusions>
</dependency>



<!-- excude conflicting dependecies for mongo and logging-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${version.springBoot}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>
</dependencyManagement>


<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>*.bk</exclude>
</excludes>
</resource>
</resources>
<testResources>
Expand Down Expand Up @@ -139,16 +222,18 @@
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
<includeOnlyProperty>git.branch</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--
<version>${version.spring.boot}</version>
-->
<configuration>
<jvmArguments>${java.17.addopens}</jvmArguments>
</configuration>

<executions>
<execution>
<goals>
Expand All @@ -160,6 +245,9 @@
<!-- For some reason BuildProperties.getName() doesn't return the correct value,
so we set the name under a different property -->
<project.name>${project.name}</project.name>
<!--
<custom.value>123</custom.value>
-->
</additionalProperties>
</configuration>
</execution>
Expand All @@ -168,7 +256,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.failsafe}</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -216,6 +303,9 @@
<resource>
<filtering>true</filtering>
<directory>src/integration-test/resources</directory>
<excludes>
<exclude>*.bk</exclude>
</excludes>
</resource>
</resources>
</configuration>
Expand All @@ -242,16 +332,25 @@
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${version.java}</source>
<target>${version.java}</target>
</configuration>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.maven-surfire-plugin}</version>
<version>${version.maven-surefire-plugin}</version>
<configuration>
<argLine>${java.17.addopens}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.maven-failsafe-plugin}</version>
<configuration>
<argLine>${java.17.addopens}</argLine>
</configuration>
</plugin>

<!-- sonar plugings -->
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
Expand Down
14 changes: 6 additions & 8 deletions set-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@
<target>${version.java}</target>
</configuration>
</plugin>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

</project>
6 changes: 1 addition & 5 deletions set-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@
</properties>

<dependencies>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${version.log4j2}</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${version.log4j2}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -90,5 +87,4 @@
</dependency>

</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

public interface UserSetConfiguration {

public static final String BEAN_SET_MONGO_STORE = "set_db_morphia_datastore_set";
public static final String BEAN_SET_PERSITENCE_SERVICE = "set_db_setService";


public String getComponentName();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void setSetProperties(Properties setProperties) {

public boolean isAuthDisabled() {
final String property = getSetProperties().getProperty(KEY_AUTH_DISABLED);
return Boolean.valueOf(property);
return Boolean.parseBoolean(property);
}

@Override
Expand Down
Loading

0 comments on commit fd6cff5

Please sign in to comment.