Releases: TNG/ArchUnit
ArchUnit 0.9.2
ArchUnit 0.9.1
Bug Fixes
- Fixed a bug where classes in Jars with white spaces (like Kotlin class files could have) cause an exception during the import (see #103)
ArchUnit 0.9.0
Important
The Maven coordinates for com.tngtech.archunit:archunit-junit
have changed, since there is now support for JUnit 4 and JUnit 5. The new coordinates for the equivalent artifact are now
com.tngtech.archunit:archunit-junit4:0.9.0
Enhancements
Core
-
archunit-ignore-patterns.txt
can now contain comments (see #88; many thanks to @bedla) -
a
JavaClass
'directDependenciesFromSelf
anddirectDependenciesToSelf
now contain further dependencies. This affects many rules as well, likelayeredArchitecture()
which might now detect more violations than before. In particular dependencies now contain dependencies from- fields of a certain type
- method/constructor parameters of a certain type
- method return types
(see #92 and #96; many thanks to @msherman32)
-
the plugin mechanism activating Java >= 9 support now supports EA versions (see #93; many thanks to @jqno)
Lang
- the rule API now supports a concise way to assert properties of a single class (see #60; many thanks to @msherman32)
- the rule API can now assert that classes
haveOnlyFinalFields()
(see #86; many thanks to @bgalek) - the rule API now allows to assert that there are at least / at most / exactly
x
classes matched by a rule (see #83; many thanks to @bedla) - rules can now be derived from PlantUML component diagrams (compare the User Guide; see #4; many thanks to @msherman32)
- the rule API now allows to check more general for dependencies instead of just accesses (like interfaces, field types, method parameters, ...) (see #69)
- the rule API now includes several methods to restrict what classes should "only" do, i.e.
classes().should().onlyDependOnClassesThat()...
oronlyCallMethodsThat(..)
, etc. (see #84)
JUnit
- ArchUnit now offers extended JUnit 5 support (compare the User Guide; see #34)
Kotlin
- rule suits with JUnit 4 / JUnit 5 can now be written in a concise way and source locations are reported correctly (compare the User Guide; see #77)
ArchUnit 0.8.3
Bug Fixes
Fixed bug where deeply nested super classes missing from the import were not resolved correctly from the classpath (see #91; many thanks to @svenackermann for reporting and debugging)
ArchUnit 0.8.2
Bug Fixes
Fixed a bug where the classpath property could not be parsed on Windows when using Eclipse Neon. Former versions of ArchUnit assumed all entries would be of the form C:\some\path
(which seems to be the case for most IDEs/build tools), now also entries of the form /C:/some/path
can be processed (see #79)
ArchUnit 0.8.1
Bug Fixes
- Fixed a bug where classes in Jars would not be imported on Windows, if Java version >= 9 and the whole classpath is imported; this only affects an import of the whole classpath with Jars, it does not affect
importPackages(..)
,importPaths(..)
orimportJars(..)
(see #73)
Enhancements
- When specifying a
layeredArchitecture()
, referring to a missing layer withinonlyBeAccessedBy(..)
will now throw an exception with a better error message (see #74)
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
@AnalyzeClasses
now allows to specify aCacheMode
to 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.SimpleConditionEvent
had 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
ClassFileImporter
now 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
ArchUnitRunner
didn't evaluate@ArchIgnore
on rule sets (i.e. fields of typeArchRules
used to include other rules; fixed in #29)
Enhancements
There were enhancements in different areas:
Core
JavaClass
has now a methodJavaClass#isEnum
(added in #5; many thanks to @storozhukBM )- The
ClassFileImporter
can now import multiple JARs at once (added in #8) and multiple paths at once (added in #10) - The
ClassFileImporter
is 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
/contains
on 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
@AnalyzeClasses
now allows to specify customLocationProviders
, which can return any set ofLocations
(added in #37).- The cache used by
ArchUnitRunner
now 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
ConditionEvents
and 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)