GithubHelp home page GithubHelp logo

aknyazev-betpawa / arch-unit-gradle-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from societe-generale/arch-unit-gradle-plugin

0.0 0.0 0.0 152 KB

A Gradle wrapper around ArchUnit, to easily share and enforce architecture rules across projects

License: Apache License 2.0

Java 93.41% Shell 6.59%

arch-unit-gradle-plugin's Introduction

ArchUnit Gradle plugin

Build Status

Context

In our dev team at Gefa Bank GmbH, we really liked how ArchUnit Maven plugin was enabling teams to distribute rules across projects. Only "problem" was that we're using Gradle, not Maven. So we decided to write an equivalent plugin for Gradle.

What is it, and how does it work ?

ArchUnit-Gradle-plugin is a wrapper around Arch-Unit-Build-Plugin-Core, which itself is a wrapper around ArchUnit, that enables you to easily make sure all your projects follow the same architecture rules.

Using a plugin brings a way to manage the rules through build configuration and to easily share and enforce architecture rules across projects.

To use the plugin, your build.gradle require these changes:

  1. Declare the dependency to the plugin :
   buildscript {
       dependencies {
           classpath "com.societegenerale.commons:arch-unit-gradle-plugin:1.1.1"
       }
       repositories {
           mavenCentral()
       }
   }
  1. Apply the java plugin and the ArchUnitGradlePlugin, then configure it:
    allprojects {
    
        apply plugin: 'java'
        apply plugin: 'com.societegenerale.commons.plugin.gradle.ArchUnitGradlePlugin'
    
        archUnit{
        
                 excludedPaths=["generated-sources"]

                  preConfiguredRules=["com.societegenerale.commons.plugin.rules.NoInjectedFieldTest",
                            "com.societegenerale.commons.plugin.rules.NoAutowiredFieldTest",
                            "com.societegenerale.commons.plugin.rules.NoTestIgnoreWithoutCommentRuleTest",
                            "com.societegenerale.commons.plugin.rules.NoPrefixForInterfacesRuleTest",
                            "com.societegenerale.commons.plugin.rules.NoPowerMockRuleTest",
                            "com.societegenerale.commons.plugin.rules.NoJodaTimeRuleTest",
                            "com.societegenerale.commons.plugin.rules.NoJunitAssertRuleTest",
                            "com.societegenerale.commons.plugin.rules.HexagonalArchitectureTest",
                            "com.societegenerale.commons.plugin.rules.DontReturnNullCollectionTest",
                            "com.societegenerale.commons.plugin.rules.StringFieldsThatAreActuallyDatesRuleTest"
                                    ]

                  configurableRules=[configurableRule("com.tngtech.archunit.library.GeneralCodingRules", applyOn("com.my.project","main") )]
  
        }
    }
    
  1. Build your project with gradlew clean build : if some of your code is not compliant with the rules defined, the build will fail, pointing you to the rule(s) and the class(es) that are violating it.

Adding new rules

All rules referenced in the configuration have to be available in the classpath. Therefore, you have 2 solutions :

  • package your rule into a custom jar, add a dependency to this jar (probably with test scope) and declare the rule in the config
  • Propose your rule through a PullRequest to Arch-Unit-Build-Plugin-Core : if it's accepted, it will be part of the next release and usable by everyone.

Releasing a new version of the plugin

(to publish in local repo during tests, use gradlew -Dmaven.repo.local=.m2/repository publishToMavenLocal)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.