From a1c4f6261252ba543ffa1ee07e71666def4b9512 Mon Sep 17 00:00:00 2001 From: Vincent FUCHS Date: Mon, 23 Mar 2020 09:35:14 +0100 Subject: [PATCH 1/3] upgrading to ArchUnit plugin core 2.5.1 + mapping for new config element --- pom.xml | 4 ++-- .../commons/plugin/maven/ArchUnitMojo.java | 6 +++++- .../commons/plugin/maven/ArchUnitMojoTest.java | 12 ++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 8bcf987..d5b3685 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ 0.8.3 3.1.0 - 2.4.0 + 2.5.1 ${project.build.directory}/test-results @@ -86,7 +86,6 @@ - com.societegenerale.commons arch-unit-build-plugin-core @@ -102,6 +101,7 @@ test + com.tngtech.junit.dataprovider junit4-dataprovider diff --git a/src/main/java/com/societegenerale/commons/plugin/maven/ArchUnitMojo.java b/src/main/java/com/societegenerale/commons/plugin/maven/ArchUnitMojo.java index c0315a2..26ba565 100644 --- a/src/main/java/com/societegenerale/commons/plugin/maven/ArchUnitMojo.java +++ b/src/main/java/com/societegenerale/commons/plugin/maven/ArchUnitMojo.java @@ -19,6 +19,7 @@ import org.apache.maven.project.MavenProject; import static java.net.URLClassLoader.newInstance; +import static java.util.Collections.emptyList; /** * @goal generate @@ -47,6 +48,9 @@ public class ArchUnitMojo extends AbstractMojo { @Parameter(property = "projectPath") private String projectPath = "./target"; + @Parameter(property = "excludedPaths") + private List excludedPaths = emptyList(); + @Parameter(property = "rules") private MavenRules rules; @@ -82,7 +86,7 @@ public void execute() throws MojoFailureException { try { configureContextClassLoader(); - ruleInvokerService = new RuleInvokerService(new MavenLogAdapter(getLog()),new MavenScopePathProvider()); + ruleInvokerService = new RuleInvokerService(new MavenLogAdapter(getLog()),new MavenScopePathProvider(),excludedPaths); ruleFailureMessage = ruleInvokerService.invokeRules(coreRules, projectPath); } catch (final Exception e) { diff --git a/src/test/java/com/societegenerale/commons/plugin/maven/ArchUnitMojoTest.java b/src/test/java/com/societegenerale/commons/plugin/maven/ArchUnitMojoTest.java index bd955c1..c74d510 100644 --- a/src/test/java/com/societegenerale/commons/plugin/maven/ArchUnitMojoTest.java +++ b/src/test/java/com/societegenerale/commons/plugin/maven/ArchUnitMojoTest.java @@ -11,7 +11,7 @@ import com.google.common.collect.ImmutableSet; import com.societegenerale.aut.test.TestClassWithPowerMock; -import com.societegenerale.commons.plugin.rules.MyCustomRules; +import com.societegenerale.commons.plugin.rules.MyCustomAndDummyRules; import com.societegenerale.commons.plugin.rules.NoPowerMockRuleTest; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; @@ -113,7 +113,7 @@ public void shouldFailWronglyDefinedConfigurableRule() throws Exception { PlexusConfiguration configurableRule = new DefaultPlexusConfiguration("configurableRule"); String missingCheck = "notThere"; - String ruleClass = MyCustomRules.class.getName(); + String ruleClass = MyCustomAndDummyRules.class.getName(); configurableRule.addChild("rule", ruleClass); configurableRule.addChild(buildChecksBlock(missingCheck)); @@ -137,7 +137,7 @@ public void shouldExecuteSingleConfigurableRuleCheck(String checkName) throws Ex PlexusConfiguration configurableRule = new DefaultPlexusConfiguration("configurableRule"); - configurableRule.addChild("rule", MyCustomRules.class.getName()); + configurableRule.addChild("rule", MyCustomAndDummyRules.class.getName()); configurableRule.addChild(buildChecksBlock(checkName)); configurableRule.addChild(buildApplyOnBlock("com.societegenerale.aut.test.specificCase", "test")); @@ -155,7 +155,7 @@ public void shouldExecuteAllConfigurableRuleChecksIfUnconfigured() throws Except PlexusConfiguration configurableRule = new DefaultPlexusConfiguration("configurableRule"); - configurableRule.addChild("rule", MyCustomRules.class.getName()); + configurableRule.addChild("rule", MyCustomAndDummyRules.class.getName()); configurableRule.addChild(buildApplyOnBlock("com.societegenerale.aut.test.specificCase", "test")); PlexusConfiguration configurableRules = pluginConfiguration.getChild("rules").getChild("configurableRules"); @@ -176,7 +176,7 @@ public void shouldExecuteBothConfigurableRule_and_PreConfiguredRule() throws Exc PlexusConfiguration configurableRule = new DefaultPlexusConfiguration("configurableRule"); - configurableRule.addChild("rule", MyCustomRules.class.getName()); + configurableRule.addChild("rule", MyCustomAndDummyRules.class.getName()); configurableRule.addChild(buildChecksBlock("annotatedWithTest_asField")); configurableRule.addChild(buildApplyOnBlock("com.societegenerale.aut.test.specificCase", "test")); @@ -198,7 +198,7 @@ public void shouldNotExecuteConfigurableRule_and_PreConfiguredRule_IfSkipIsTrue( PlexusConfiguration configurableRule = new DefaultPlexusConfiguration("configurableRule"); - configurableRule.addChild("rule", MyCustomRules.class.getName()); + configurableRule.addChild("rule", MyCustomAndDummyRules.class.getName()); configurableRule.addChild(buildChecksBlock("annotatedWithTest_asField")); configurableRule.addChild(buildApplyOnBlock("com.societegenerale.commons.plugin.rules.classesForTests.specificCase", "test")); From 77e11f175f45b22fb4cc5f7a5afab1c5f4bfd76f Mon Sep 17 00:00:00 2001 From: Vincent FUCHS Date: Mon, 23 Mar 2020 19:29:21 +0100 Subject: [PATCH 2/3] updating version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d5b3685..a8911d2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.societegenerale.commons arch-unit-maven-plugin maven-plugin - 2.3.1-SNAPSHOT + 2.4.0-SNAPSHOT ArchUnit Maven plugin From 9afbddfabfc26d08564b70cd08244ff280a8b46c Mon Sep 17 00:00:00 2001 From: Vincent FUCHS Date: Mon, 23 Mar 2020 19:29:39 +0100 Subject: [PATCH 3/3] updated changelog and documentation --- CHANGELOG.md | 5 +++++ README.md | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93271a7..3c2f097 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ ### Fixed +## [2.4.0] - 2020-03-23 + +### Changed +- using latest Mockito so that it runs fine with JDK 11 +- upgrading Archunit plugin core to 2.5.1 : now can configure excludedPaths ## [2.3.0] - 2019-10-06 diff --git a/README.md b/README.md index f3c0d67..54122a3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add below plugin in your root pom.xml : all available `````` are mentioned com.societegenerale.commons arch-unit-maven-plugin - 2.3.0 + 2.4.0 ${project.basedir}/target @@ -98,9 +98,15 @@ So your config would become something like : com.societegenerale.commons arch-unit-maven-plugin - 2.3.0 + 2.4.0 ${project.basedir}/target + + + + generated-sources + + @@ -192,6 +198,12 @@ and then you can switch the parameter `archunit.skip` either on runtime (via `-D Since v2.2.0, you can benefit from ArchUnit advanced configuration, as the plugin can find `archunit.properties` file. More infos in [ArchUnit's user guide](https://www.archunit.org/userguide/html/000_Index.html#_advanced_configuration) +## Excluding paths + +Since v2.4.0, configuration can take an optional `excludedPaths` element. All classes that have a location that contains one the mentioned Strings will be excluded from the ArchUnit checks : can be useful in case some classes are generated (Lombok, Mapstruct, ..) and you have little or no control on what gets generated. + +See [ExclusionImportOption.java](https://github.com/societe-generale/arch-unit-build-plugin-core/blob/2a6f5d009b96a7921bf2de65fcc0aad85edc006a/src/main/java/com/societegenerale/commons/plugin/utils/ExclusionImportOption.java) for details on the (very simple) logic. + ## Contribute !