Skip to content

Commit f6d7d34

Browse files
committed
Enforce import order via checkstyle CustomImportOrder
Add CustomImportOrder module to checkstyle configuration enforcing: 1. java/javax imports (STANDARD_JAVA_PACKAGE) 2. Third-party imports (THIRD_PARTY_PACKAGE) 3. org.hibernate imports (SPECIAL_IMPORTS) 4. Static imports (STATIC) With alphabetical sorting within groups and blank line separators between groups, matching the existing IntelliJ formatter configuration.
1 parent acacdb8 commit f6d7d34

219 files changed

Lines changed: 332 additions & 340 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build-config/src/main/resources/build-config/checkstyle.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@
120120
<module name="ImportControl">
121121
<property name="file" value="${basedir}/../build-config/src/main/resources/build-config/import-control.xml" />
122122
</module>
123+
<module name="CustomImportOrder">
124+
<property name="customImportOrderRules"
125+
value="STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STATIC"/>
126+
<property name="standardPackageRegExp" value="^(java|javax)\."/>
127+
<property name="specialImportsRegExp" value="^org\.hibernate\."/>
128+
<property name="sortImportsInGroupAlphabetically" value="true"/>
129+
<property name="separateLineBetweenGroups" value="true"/>
130+
</module>
123131

124132

125133
<!-- Checks for Size Violations. -->

core/src/main/java/org/mapstruct/control/MappingControl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.lang.annotation.RetentionPolicy;
1212
import java.lang.annotation.Target;
1313

14-
1514
/**
1615
* Controls which means of mapping are considered between the source and the target in mappings.
1716
*

core/src/test/java/org/mapstruct/factory/MappersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
*/
66
package org.mapstruct.factory;
77

8-
import static org.assertj.core.api.Assertions.assertThat;
9-
108
import org.junit.jupiter.api.Test;
119
import org.mapstruct.test.model.Foo;
1210
import org.mapstruct.test.model.SomeClass;
1311

12+
import static org.assertj.core.api.Assertions.assertThat;
13+
1414
/**
1515
* Unit test for {@link Mappers}.
1616
*

integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/DecoratedSourceTargetMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66
package org.mapstruct.itest.cdi;
77

8+
import org.mapstruct.DecoratedWith;
89
import org.mapstruct.Mapper;
910
import org.mapstruct.MappingConstants;
10-
import org.mapstruct.DecoratedWith;
1111
import org.mapstruct.itest.cdi.other.DateMapper;
1212

1313
@Mapper( componentModel = MappingConstants.ComponentModel.CDI, uses = DateMapper.class )

integrationtest/src/test/resources/cdiTest/src/test/java/org/mapstruct/itest/cdi/CdiBasedMapperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
package org.mapstruct.itest.cdi;
77

8-
import static org.assertj.core.api.Assertions.assertThat;
9-
108
import javax.inject.Inject;
119

1210
import org.jboss.arquillian.container.test.api.Deployment;
@@ -18,6 +16,8 @@
1816
import org.junit.runner.RunWith;
1917
import org.mapstruct.itest.cdi.other.DateMapper;
2018

19+
import static org.assertj.core.api.Assertions.assertThat;
20+
2121
/**
2222
* Test for generation of CDI-based mapper implementations.
2323
*

integrationtest/src/test/resources/expressionTextBlocksTest/src/test/java/org/mapstruct/itest/textBlocks/TextBlocksTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import java.util.Arrays;
99

10-
import static org.assertj.core.api.Assertions.assertThat;
11-
1210
import org.junit.Test;
1311

12+
import static org.assertj.core.api.Assertions.assertThat;
13+
1414
public class TextBlocksTest {
1515

1616
@Test

integrationtest/src/test/resources/externalbeanjar/mapper/src/main/java/org/mapstruct/itest/externalbeanjar/Issue1121Mapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
*/
1111
package org.mapstruct.itest.externalbeanjar;
1212

13-
import org.mapstruct.itest.externalbeanjar.Source;
14-
import org.mapstruct.itest.externalbeanjar.Target;
1513
import org.mapstruct.Mapper;
1614
import org.mapstruct.Mapping;
1715
import org.mapstruct.factory.Mappers;
16+
import org.mapstruct.itest.externalbeanjar.Source;
17+
import org.mapstruct.itest.externalbeanjar.Target;
1818

1919
/**
2020
*

integrationtest/src/test/resources/externalbeanjar/mapper/src/test/java/org/mapstruct/itest/externalbeanjar/ConversionTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
package org.mapstruct.itest.simple;
77

88
import java.math.BigDecimal;
9-
import static org.assertj.core.api.Assertions.assertThat;
109

1110
import org.junit.Test;
12-
import org.mapstruct.itest.externalbeanjar.Source;
1311
import org.mapstruct.itest.externalbeanjar.Issue1121Mapper;
12+
import org.mapstruct.itest.externalbeanjar.Source;
1413
import org.mapstruct.itest.externalbeanjar.Target;
1514

15+
import static org.assertj.core.api.Assertions.assertThat;
16+
1617
public class ConversionTest {
1718

1819
@Test

integrationtest/src/test/resources/fullFeatureTest/src/test/java/org/mapstruct/itest/simple/AnimalTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
*/
66
package org.mapstruct.ap.test.ignore;
77

8-
import static org.assertj.core.api.Assertions.assertThat;
9-
108
import org.junit.Test;
11-
12-
import org.mapstruct.ap.test.ignore.AnimalMapper;
139
import org.mapstruct.ap.test.ignore.Animal;
1410
import org.mapstruct.ap.test.ignore.AnimalDto;
11+
import org.mapstruct.ap.test.ignore.AnimalMapper;
12+
13+
import static org.assertj.core.api.Assertions.assertThat;
1514

1615
/**
1716
* Test for ignoring properties during the mapping.

integrationtest/src/test/resources/gradleIncrementalCompilationTest/src/main/java/org/mapstruct/itest/gradle/lib/TestMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import org.mapstruct.Mapper;
99
import org.mapstruct.Mapping;
1010
import org.mapstruct.ReportingPolicy;
11-
12-
import org.mapstruct.itest.gradle.model.Target;
1311
import org.mapstruct.itest.gradle.model.Source;
12+
import org.mapstruct.itest.gradle.model.Target;
1413

1514
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
1615
public interface TestMapper {

0 commit comments

Comments
 (0)