-
Notifications
You must be signed in to change notification settings - Fork 2
Architecture Overview
There are several components that do the base 'stuff'. The base stuff generally is: dependency resolution and jar manipulation (extraction/compression).
Then there is the Minimizer which "simply" uses the components to find all the dependencies of a project (and their transitive dependencies) and package a new jar containing only them.
The Resolvers do the resolution.
There is a SourceDepencencyResolver which parses .java files and tells you what a given file depends on.
There is also a ClassDependencyResolver which parses binary compiled .class files and tells you what they depend on.
The both return the ClassName model object, representing source/class dependencies, but more on that later (in the domain section). They also both implement the DependencyResolver interface.
They both also make sure they're actually working with valid .java or .class files, so passing anything else to them, makes them angry and they throw exceptions.
You can have a look at their JavaDocs for more info.
There is basically a JarExploder, which extracts jars to a given directory.
There is also a JarMaker which makes a new jar from a list of given classes.
Both of them make sure they are actually working with real, existing jars and .class files and blow up if you try to cheat them (or at least they should).
Now we get to the overengineered part :)
This is the components that actually checks if a ClassName (a dependency) matches a file on the file system.
It does this by asking several Conditions whether they agree that a given class name matches a given .class file.
There are several conditions currently and they all need to 'agree' for Diet to decide that a class name matches a class file.
This snippet should be self explanatory:
<bean id="unanimousMatcher" class="org.codarama.diet.dependency.matcher.impl.UnanimousBasedDependencyMatcherStrategy">
<property name="conditions">
<set>
<bean class="org.codarama.diet.dependency.matcher.condition.impl.BinaryClassNameVsDependencyQualifiedName"/>
<bean class="org.codarama.diet.dependency.matcher.condition.impl.ClassnamePackagesVsClassfilePath"/>
<bean class="org.codarama.diet.dependency.matcher.condition.impl.ClassShortNameVsClassFilename"/>
</set>
</property>
</bean>If you're unfamiliar with Spring the JavaDocs of the matcher and the conditions should clear things up a bit.