Releases: TNG/ArchUnit
Releases · TNG/ArchUnit
ArchUnit 0.8.0
Enhancements
Core
- ArchUnit now supports classes compiled with JDK 9 and JDK 10 (see #47)
- this includes a new URL type for JDK >= 9 runtime images, i.e. ArchUnit now supports URLs of the form
jrt:/java.base/... - support for JDK 9 / 10 classes is loaded dynamically, thus ArchUnit can still run with any JDK >= 7 and the change should be fully backwards compatible
- this includes a new URL type for JDK >= 9 runtime images, i.e. ArchUnit now supports URLs of the form
Lang
- the rule API now allows to assert properties of simple class names (see #41; many thanks to @SteluHH)
- the rule API now fails, if
annotatedWith(..)is called with an annotation type with@Retention(SOURCE)(see #48) - the rule API now supports testing for meta-annotations (e.g. custom annotations annotated with some stereotype like the Spring framework likes to use) (see #57; many thanks to @rweisleder)
- the rule API now creates hyperlinks within error messages that refer to whole classes (like wrong simple class name) (see #61)
JUnit 4
@AnalyzeClassesnow allows to specify aCacheModeto disable caching by location between different test classes (see #45)
ArchUnit 0.5.0
Minor Breaking Changes
There were two minor things that were changed in an incompatible way (the migration should literally only take 1 minute, otherwise this ugliness would have had to be dragged on for a long time):
@AnalyzeClasses(importOption = )is now a varargs@AnalyzeClasses(importOptions = )that accepts a variable number of import options (a simple rename of "importOption" to "importOptions" should fix this). Changed in #2.SimpleConditionEventhad a rather useless type parameter (since wherever it would be evaluated, the type would be '?' anyway, providing no further use), which was removed. This can be fixed, by performing a regex replace of "SimpleConditionEvent<[^>]*>" with "SimpleConditionEvent"
Apologies for any inconvenience this causes! This was mainly due to the fact, that the last release was the very first one and it should not happen again with the next release.
Bug Fixes
- The
ClassFileImporternow imports packages from JARs, even if the respective JAR entry is missing (it used to skip those, sinceclassLoader.getResource(packagePathWithoutJarEntry)would return nothing; fixed in #11) - The
ArchUnitRunnerdidn't evaluate@ArchIgnoreon rule sets (i.e. fields of typeArchRulesused to include other rules; fixed in #29)
Enhancements
There were enhancements in different areas:
Core
JavaClasshas now a methodJavaClass#isEnum(added in #5; many thanks to @storozhukBM )- The
ClassFileImportercan now import multiple JARs at once (added in #8) and multiple paths at once (added in #10) - The
ClassFileImporteris now more resilient, if a single class file is corrupt (before the whole import would fail, if a broken class file was encountered; added in #9)
Lang
should().onlyAccessedBy()now ignores self accesses (changed in #3)- Failing rules now report the number of violations in the error message (added in #24; many thanks to @hankem)
- classes syntax now allows to filter and assert implementing interfaces (i.e. select classes that implement an interface or assert that certain classes should implement an interface; added in #36; many thanks to @hajotka)
- classes syntax now allows to filter and assert
startsWith/endsWith/containson simple class names (added in #40 and #43; many thanks to @SteluHH) layeredArchitecture()now allowes to ignore certain dependencies programmatically (added in #42)- slice rules (
slices()...should().beFreeOfCycles()andslices()...should().notDependOnEachOther()) now allow to ignore certain dependencies programmatically (added in #46)
JUnit
@AnalyzeClassesnow allows to specify customLocationProviders, which can return any set ofLocations(added in #37).- The cache used by
ArchUnitRunnernow uses soft references, thus the garbage collector should free the heap of imported classes, if the heap runs low, while keeping the classes cached by URL as long as there is enough heap (changed in #45)
Experimental Features
The following features are marked with @PublicAPI(state = EXPERIMENTAL) which means, that any method / class may change in any release at will. Use only at your own risk.
- Added a new API to programmatically handle violations (i.e. react to the
ConditionEventsand their corresponding objects, likeJavaAccess; added in #16) - Added a new API to register custom extensions to react to violated rules. The idea is, to perform some custom reporting or visualization, but as long as there is no released part of ArchUnit that uses this API, it will remain experimental (added in #18)
First release of ArchUnit
This is the initial release of ArchUnit, it consists of
- ArchUnit core (an importer for class files and an API to analyse imported classes)
- ArchUnit lang (an API to specify rules on code structures, like package dependencies, method calls, field accesses, ...)
- ArchUnit library (some extensions, e.g. a compact API to specify layered architectures or rules on package slices, ...)
- ArchUnit JUnit (integration with JUnit 4, providing a custom runner to evaluate ArchRules declared as test fields and to cache imported URLs in between test runs)