diff --git a/core-common/pom.xml b/core-common/pom.xml new file mode 100644 index 000000000..5cbe3a4d2 --- /dev/null +++ b/core-common/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + + org.mapstruct + mapstruct-parent + 1.0.0-SNAPSHOT + ../parent/pom.xml + + + mapstruct-common + jar + MapStruct Core Common + + + + junit + junit + test + + + org.easytesting + fest-assert + test + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + check-style + verify + + checkstyle + + + + + + + diff --git a/core/src/main/java/org/mapstruct/DecoratedWith.java b/core-common/src/main/java/org/mapstruct/DecoratedWith.java similarity index 100% rename from core/src/main/java/org/mapstruct/DecoratedWith.java rename to core-common/src/main/java/org/mapstruct/DecoratedWith.java diff --git a/core/src/main/java/org/mapstruct/IterableMapping.java b/core-common/src/main/java/org/mapstruct/IterableMapping.java similarity index 100% rename from core/src/main/java/org/mapstruct/IterableMapping.java rename to core-common/src/main/java/org/mapstruct/IterableMapping.java diff --git a/core/src/main/java/org/mapstruct/MapMapping.java b/core-common/src/main/java/org/mapstruct/MapMapping.java similarity index 100% rename from core/src/main/java/org/mapstruct/MapMapping.java rename to core-common/src/main/java/org/mapstruct/MapMapping.java diff --git a/core/src/main/java/org/mapstruct/Mapper.java b/core-common/src/main/java/org/mapstruct/Mapper.java similarity index 100% rename from core/src/main/java/org/mapstruct/Mapper.java rename to core-common/src/main/java/org/mapstruct/Mapper.java diff --git a/core/src/main/java/org/mapstruct/MapperConfig.java b/core-common/src/main/java/org/mapstruct/MapperConfig.java similarity index 100% rename from core/src/main/java/org/mapstruct/MapperConfig.java rename to core-common/src/main/java/org/mapstruct/MapperConfig.java diff --git a/core/src/main/java/org/mapstruct/MappingTarget.java b/core-common/src/main/java/org/mapstruct/MappingTarget.java similarity index 100% rename from core/src/main/java/org/mapstruct/MappingTarget.java rename to core-common/src/main/java/org/mapstruct/MappingTarget.java diff --git a/core/src/main/java/org/mapstruct/ReportingPolicy.java b/core-common/src/main/java/org/mapstruct/ReportingPolicy.java similarity index 100% rename from core/src/main/java/org/mapstruct/ReportingPolicy.java rename to core-common/src/main/java/org/mapstruct/ReportingPolicy.java diff --git a/core/src/main/java/org/mapstruct/TargetType.java b/core-common/src/main/java/org/mapstruct/TargetType.java similarity index 100% rename from core/src/main/java/org/mapstruct/TargetType.java rename to core-common/src/main/java/org/mapstruct/TargetType.java diff --git a/core/src/main/java/org/mapstruct/factory/Mappers.java b/core-common/src/main/java/org/mapstruct/factory/Mappers.java similarity index 100% rename from core/src/main/java/org/mapstruct/factory/Mappers.java rename to core-common/src/main/java/org/mapstruct/factory/Mappers.java diff --git a/core/src/main/java/org/mapstruct/factory/package-info.java b/core-common/src/main/java/org/mapstruct/factory/package-info.java similarity index 100% rename from core/src/main/java/org/mapstruct/factory/package-info.java rename to core-common/src/main/java/org/mapstruct/factory/package-info.java diff --git a/core/src/main/java/org/mapstruct/package-info.java b/core-common/src/main/java/org/mapstruct/package-info.java similarity index 100% rename from core/src/main/java/org/mapstruct/package-info.java rename to core-common/src/main/java/org/mapstruct/package-info.java diff --git a/core/src/test/java/org/mapstruct/MappersTest.java b/core-common/src/test/java/org/mapstruct/MappersTest.java similarity index 100% rename from core/src/test/java/org/mapstruct/MappersTest.java rename to core-common/src/test/java/org/mapstruct/MappersTest.java diff --git a/core/src/test/java/org/mapstruct/test/model/Foo.java b/core-common/src/test/java/org/mapstruct/test/model/Foo.java similarity index 100% rename from core/src/test/java/org/mapstruct/test/model/Foo.java rename to core-common/src/test/java/org/mapstruct/test/model/Foo.java diff --git a/core/src/test/java/org/mapstruct/test/model/FooImpl.java b/core-common/src/test/java/org/mapstruct/test/model/FooImpl.java similarity index 100% rename from core/src/test/java/org/mapstruct/test/model/FooImpl.java rename to core-common/src/test/java/org/mapstruct/test/model/FooImpl.java diff --git a/core-jdk8/pom.xml b/core-jdk8/pom.xml new file mode 100644 index 000000000..b4f06141f --- /dev/null +++ b/core-jdk8/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + + org.mapstruct + mapstruct-parent + 1.0.0-SNAPSHOT + ../parent/pom.xml + + + mapstruct-jdk8 + jar + MapStruct Core JDK 8 + + + + ${project.groupId} + mapstruct-common + true + + + junit + junit + test + + + org.easytesting + fest-assert + test + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + check-style + verify + + checkstyle + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-dependency-plugin + + + process-resources + + unpack-dependencies + + + mapstruct-common + **/*.class + ${project.build.outputDirectory} + + + + + + + diff --git a/core-jdk8/src/main/java/org/mapstruct/Mapping.java b/core-jdk8/src/main/java/org/mapstruct/Mapping.java new file mode 100644 index 000000000..c37abbeb1 --- /dev/null +++ b/core-jdk8/src/main/java/org/mapstruct/Mapping.java @@ -0,0 +1,62 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Configures the mapping of one bean attribute or enum constant. + * + * @author Gunnar Morling + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.METHOD) +@Repeatable(Mappings.class) +public @interface Mapping { + + /** + * The source name of the configured property as defined by the JavaBeans specification. If used to map an enum + * constant, the name of the constant member is to be given. + * + * @return The source name of the configured property or enum constant + */ + String source(); + + /** + * The target name of the configured property as defined by the JavaBeans specification. Defaults to the source name + * if not given. If used to map an enum constant, the name of the constant member is to be given. + * + * @return The target name of the configured property or enum constant + */ + String target() default ""; + + /** + * A format string as processable by {@link SimpleDateFormat} if the attribute is mapped from {@code String} to + * {@link Date} or vice-versa. Will be ignored for all other attribute types and when mapping enum constants. + * + * @return A date format string as processable by {@link SimpleDateFormat}. + */ + String dateFormat() default ""; +} diff --git a/core-jdk8/src/main/java/org/mapstruct/Mappings.java b/core-jdk8/src/main/java/org/mapstruct/Mappings.java new file mode 100644 index 000000000..9f77980d4 --- /dev/null +++ b/core-jdk8/src/main/java/org/mapstruct/Mappings.java @@ -0,0 +1,41 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Configures the mappings of several bean attributes. + * + * @author Gunnar Morling + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.METHOD) +public @interface Mappings { + + /** + * The configuration of the bean attributes. + * + * @return The configuration of the bean attributes. + */ + Mapping[] value(); +} diff --git a/core/pom.xml b/core/pom.xml index d8ce4f737..7c196eded 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -34,6 +34,11 @@ MapStruct Core + + ${project.groupId} + mapstruct-common + true + junit junit @@ -74,6 +79,23 @@ + + org.apache.maven.plugins + maven-dependency-plugin + + + process-resources + + unpack-dependencies + + + mapstruct-common + **/*.class + ${project.build.outputDirectory} + + + + diff --git a/parent/pom.xml b/parent/pom.xml index ca269774f..6a94af70f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -185,11 +185,21 @@ + + ${project.groupId} + mapstruct-common + ${project.version} + ${project.groupId} mapstruct ${project.version} + + ${project.groupId} + mapstruct-jdk8 + ${project.version} + ${project.groupId} mapstruct-processor diff --git a/pom.xml b/pom.xml index 9ddd86ac5..194d9ffb1 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,9 @@ parent build-config + core-common core + core-jdk8 processor integrationtest