Skip to content

Commit

Permalink
Merge 9afbddf into 9adf22e
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-fuchs committed Mar 23, 2020
2 parents 9adf22e + 9afbddf commit c53e357
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
16 changes: 14 additions & 2 deletions README.md
Expand Up @@ -21,7 +21,7 @@ Add below plugin in your root pom.xml : all available ```<rule>``` are mentioned
<plugin>
<groupId>com.societegenerale.commons</groupId>
<artifactId>arch-unit-maven-plugin</artifactId>
<version>2.3.0</version>
<version>2.4.0</version>
<configuration>
<projectPath>${project.basedir}/target</projectPath>
<rules>
Expand Down Expand Up @@ -98,9 +98,15 @@ So your config would become something like :
<plugin>
<groupId>com.societegenerale.commons</groupId>
<artifactId>arch-unit-maven-plugin</artifactId>
<version>2.3.0</version>
<version>2.4.0</version>
<configuration>
<projectPath>${project.basedir}/target</projectPath>

<!-- optional - you can exclude classes that have a path containing any of the mentioned paths -->
<excludedPaths>
<excludedPath>generated-sources</excludedPath>
</excludedPaths>

<rules>
<!-- using a rule available out of the box... -->
<preConfiguredRules>
Expand Down Expand Up @@ -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 !

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -4,7 +4,7 @@
<groupId>com.societegenerale.commons</groupId>
<artifactId>arch-unit-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.3.1-SNAPSHOT</version>
<version>2.4.0-SNAPSHOT</version>

<name>ArchUnit Maven plugin</name>

Expand Down Expand Up @@ -54,7 +54,7 @@
<jacoco.version>0.8.3</jacoco.version>
<mockito.version>3.1.0</mockito.version>

<arch-unit-build-plugin-core.version>2.4.0</arch-unit-build-plugin-core.version>
<arch-unit-build-plugin-core.version>2.5.1</arch-unit-build-plugin-core.version>

<project.testresult.directory>${project.build.directory}/test-results
</project.testresult.directory>
Expand Down Expand Up @@ -86,7 +86,6 @@
</distributionManagement>
<dependencies>


<dependency>
<groupId>com.societegenerale.commons</groupId>
<artifactId>arch-unit-build-plugin-core</artifactId>
Expand All @@ -102,6 +101,7 @@
<scope>test</scope>
</dependency>


<dependency>
<groupId>com.tngtech.junit.dataprovider</groupId>
<artifactId>junit4-dataprovider</artifactId>
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.apache.maven.project.MavenProject;

import static java.net.URLClassLoader.newInstance;
import static java.util.Collections.emptyList;

/**
* @goal generate
Expand Down Expand Up @@ -47,6 +48,9 @@ public class ArchUnitMojo extends AbstractMojo {
@Parameter(property = "projectPath")
private String projectPath = "./target";

@Parameter(property = "excludedPaths")
private List<String> excludedPaths = emptyList();

@Parameter(property = "rules")
private MavenRules rules;

Expand Down Expand Up @@ -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) {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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"));

Expand All @@ -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");
Expand All @@ -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"));

Expand All @@ -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"));

Expand Down

0 comments on commit c53e357

Please sign in to comment.