Skip to content

Commit

Permalink
added jakarta support (#859)
Browse files Browse the repository at this point in the history
* jakarta migration

* jakarta migration

* jakarta migration

* jakarta migration

* jakarta migration

* fixed checkstyle issues and reverted temp changes

* fixed el packages

* set minimum version of java to 11

* fixed formatting

* removed lombok annotations because no support in jaxb plugin

* fixed formatting

* exclude tests for wildfly because not easy to migrate to newest version of wildfly

---------

Co-authored-by: Ruslan Hryn <[email protected]>
  • Loading branch information
RuslanHryn and Ruslan Hryn authored Mar 5, 2024
1 parent cae0383 commit 326c21d
Show file tree
Hide file tree
Showing 45 changed files with 902 additions and 404 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![License](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)]()

# Dozer

## Project Activity
The project is currently not active and will more than likely be deprecated in the future. If you are looking to use Dozer
on a greenfield project, we would discourage that. If you have been using Dozer for a while, we would suggest you start to think about migrating
Expand Down
33 changes: 15 additions & 18 deletions bom-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
<commons-beanutils.version>1.9.4</commons-beanutils.version>
<commons-lang3.version>3.7</commons-lang3.version>
<commons-io.version>2.7</commons-io.version>
<javax.el.version>3.0.0</javax.el.version>
<jakarta.el.version>4.0.0</jakarta.el.version>
<felix.version>5.6.8</felix.version>
<jaxb-runtime.version>2.4.0-b180830.0438</jaxb-runtime.version>
<jaxb.version>4.0.3</jaxb.version>
<guava.version>22.0</guava.version>
<hamcrest-all.version>1.3</hamcrest-all.version>
<hibernate-core.version>5.6.8.Final</hibernate-core.version>
<jackson-dataformat.version>2.10.1</jackson-dataformat.version>
<javax.inject.version>1</javax.inject.version>
<jakarta.inject.version>2.0.1</jakarta.inject.version>
<javassist.version>3.24.0-GA</javassist.version>
<jmh.version>1.19</jmh.version>
<junit5-vintage.version>5.1.0</junit5-vintage.version>
Expand All @@ -65,6 +65,13 @@
<dependencyManagement>
<!-- Dependency; alphabetical order -->
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-bom</artifactId>
<version>${jaxb.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
Expand Down Expand Up @@ -96,26 +103,16 @@
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>${javax.el.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>${javax.el.version}</version>
<artifactId>jakarta.el</artifactId>
<version>${jakarta.el.version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>${felix.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
Expand Down Expand Up @@ -147,9 +144,9 @@
<version>${jackson-dataformat.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>${javax.inject.version}</version>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>${jakarta.inject.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
Expand Down
2 changes: 1 addition & 1 deletion building-tools/src/main/resources/loose-checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="ImportOrder">
<property name="groups" value="java,javax,org.w3c,org.xml"/>
<property name="groups" value="java,jakarta,javax,org.w3c,org.xml"/>
<property name="ordered" value="true"/>
</module>

Expand Down
2 changes: 1 addition & 1 deletion building-tools/src/main/resources/strict-checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="ImportOrder">
<property name="groups" value="java,javax,org.w3c,org.xml"/>
<property name="groups" value="java,jakarta,javax,org.w3c,org.xml"/>
<property name="ordered" value="true"/>
</module>

Expand Down
91 changes: 30 additions & 61 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
<osgi.Export-Package>com.github.dozermapper.core.*</osgi.Export-Package>
<!-- ServiceLoader Capability -->
<osgi.Require-Capability>
osgi.serviceloader; filter:="(osgi.serviceloader=com.github.dozermapper.core.DozerModule)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;
filter:="(osgi.serviceloader=com.github.dozermapper.core.DozerModule)";cardinality:=multiple;resolution:=optional,
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional
</osgi.Require-Capability>
<osgi.SPI-Consumer>*</osgi.SPI-Consumer>
Expand Down Expand Up @@ -86,21 +87,27 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<!-- EL -->
<!--JAXB-API-->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>provided</scope>
<optional>true</optional>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
</dependency>
<!-- EL -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<artifactId>jakarta.el</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<!-- YAML -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
Expand Down Expand Up @@ -277,52 +284,10 @@

<profiles>
<profile>
<id>jdk8-build</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>schemagen</id>
<phase>generate-resources</phase>
<goals>
<goal>schemagen</goal>
</goals>
<configuration>
<workDirectory>${project.build.directory}/generated-resources/schemagen</workDirectory>
<includes>
com/github/dozermapper/core/builder/model/jaxb/**
</includes>
<transformSchemas>
<transformSchema>
<uri>http://dozermapper.github.io/schema/bean-mapping</uri>
<toFile>bean-mapping.xsd</toFile>
</transformSchema>
</transformSchemas>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk9-and-above-build</id>
<id>jdk11-and-above-build</id>
<activation>
<jdk>[9,)</jdk>
<jdk>[11,)</jdk>
</activation>
<properties>
<!-- Remove once servicemix jaxb-2.3 is released: https://issues.apache.org/jira/browse/SM-3854 -->
<osgi.additional.Import-Package>
javax.xml.bind;version="[2.2,3)",
javax.xml.bind.annotation;version="[2.2,3)"
</osgi.additional.Import-Package>
</properties>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
Expand All @@ -342,18 +307,21 @@
<goal>schemagen</goal>
</goals>
<configuration>
<workDirectory>${project.build.directory}/generated-resources/schemagen</workDirectory>
<includes>
com/github/dozermapper/core/builder/model/jaxb/**
</includes>
<workDirectory>${project.build.directory}/generated-resources/schemagen
</workDirectory>
<sources>
<source>
src/main/java/com/github/dozermapper/core/builder/model/jaxb
</source>
</sources>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.4.0-b180830.0438</version>
<version>4.0.3</version>
</dependency>
</dependencies>
</plugin>
Expand All @@ -367,9 +335,10 @@
<configuration>
<target>
<echo>Copying XSD schema to be included in JAR</echo>
<replace file="${project.build.directory}/generated-resources/schemagen/schema1.xsd"
token="xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;"
value="xmlns=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;"/>
<replace
file="${project.build.directory}/generated-resources/schemagen/schema1.xsd"
token="xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;"
value="xmlns=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;"/>
<move file="${project.build.directory}/generated-resources/schemagen/schema1.xsd"
tofile="${project.build.directory}/generated-resources/schemagen/bean-mapping.xsd"/>
</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ private <T> T createByCreationDirectiveAndMap(BeanCreationDirective creationDire
*/
private void mapToDestObject(ClassMap classMap, Object srcObj, Object destObj, boolean bypassSuperMappings, String mapId) {
Object result = destObj;
if (javax.xml.bind.JAXBElement.class.isAssignableFrom(destObj.getClass())) {
classMap = getClassMap(srcObj.getClass(), javax.xml.bind.JAXBElement.class.cast(destObj).getDeclaredType(), mapId);
result = javax.xml.bind.JAXBElement.class.cast(destObj).getValue();
if (jakarta.xml.bind.JAXBElement.class.isAssignableFrom(destObj.getClass())) {
classMap = getClassMap(srcObj.getClass(), jakarta.xml.bind.JAXBElement.class.cast(destObj).getDeclaredType(), mapId);
result = jakarta.xml.bind.JAXBElement.class.cast(destObj).getValue();
}

map(classMap, srcObj, result, bypassSuperMappings, new ArrayList<>(), mapId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,17 @@

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import com.github.dozermapper.core.config.BeanContainer;
import com.github.dozermapper.core.util.MappingUtils;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter(AccessLevel.PROTECTED)
@ToString
@EqualsAndHashCode
@XmlAccessorType(XmlAccessType.FIELD)
Expand Down Expand Up @@ -88,4 +81,16 @@ public List<Class<RuntimeException>> build(BeanContainer beanContainer) {
public ConfigurationDefinition end() {
return parent;
}

public ConfigurationDefinition getParent() {
return parent;
}

public List<String> getExceptions() {
return exceptions;
}

protected void setExceptions(List<String> exceptions) {
this.exceptions = exceptions;
}
}
Loading

0 comments on commit 326c21d

Please sign in to comment.