Add support for <exclusions>

The Bio-Formats release 5.0.0 unfortunately comes with incorrect
dependency declarations in its deployed .pom files. For example, testng
lacks the test scope and drags in a completely outdated xercesImpl
dependency that interferes e.g. with TrackMate when installed into
an ImageJ.app/jars/ directory (as noticed by Larry Lindsey).

Thankfully, Curtis Rueden added a work-around by putting appropriate
(huge) <exclusions> lists into the few projects' pom.xml files still
referencing Bio-Formats over SCIFIO (which does not sport incorrect
dependency declarations).

Let's teach MiniMaven about this, fixing
https://github.com/imagej/imagej/issues/33.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a regression test for the <exclusions> support

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge pull request #1 from imagej/exclusions

Support <exclusions>
When a dependency is missing a version, look at the parent

Dependency information is inherited from parents in Maven
configurations; Child projects can repeat the dependencies declared
in the parent project when they need to configure them, but in that
case, the version need not be specified again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When dependencies are missing versions, look into the dependencyManagement

In the upcoming pom-scijava version, we have a big dependencyManagement
section that preconfigures the dependency versions so that child projects
need not specify the versions but inherit pom-scijava's setting.

Let's support that in MiniMaven.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Introduce a new, protected constructor for Coordinates

This constructor requires values to be provided for *all* fields. It
is not intended to be public API so that we can use it to enforce
the use of the full constructor inside MiniMaven.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make sure that expand(Coordinate) does not forget exclusions

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Refactor findVersion()

The findVersion() method is supposed to traverse the
<dependencyManagement> and also the parents' <dependencies> and
<dependencyManagement> sections to find the appropriate <version> tag
for dependencies whose version is not set in the current project's
<dependencies> section.

But the method itself was conflating two concepts: querying the
dependencyManagement information, and returning just one version.

For exclusions, we require the first concept: to query the
dependencyManagement information (because Bio-Formats' kryo dependency
has exclusions managed that way).

So let's refactor it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Handle <exclusions> properly

We tried to punt on the issue and just filter dependencies *after*
gathering them.

That did not work, however: if a dependency has exclusions, the
*transitive* dependencies of the excluded ones *also* need to be
excluded.

So let's stop punting on the issue and do it properly.

While at it, heed exclusions declared in <dependencyManagement>
sections as well as exclusions declared in the parents.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move a couple of methods into a dedicated TestUtils class

Incidentally, this fixes a problem where the temporary directories were
not created in the target/ directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Refactor the initialisation of test MavenProjects

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use simpler way to write pom.xml files for exclusions test

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move more helpers into TestUtils

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use static imports

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make sure that transitive dependencies of excluded ones are excluded, too

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a unit test for <dependencyManagement> handling

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge pull request #2 from imagej/dependency-management

Support <dependencyManagement>
Avoid using the deprecated Coordinate constructor

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Avoid cluttering the target/ directory with test directories

Let's have a consistent naming, based on the test method and the line
number, and reuse the directory names of the output directories.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Fix MavenProject#compareTo()

We would like to sort MavenProjects into TreeSets; For that, they
have to be Comparable. The previous version of the compareTo()
method failed to take classifiers into account; As a consequence,
MavenProject instances representing artifacts with classifiers were
ignored when accumulating dependencies, if the same artifact is a
dependency *without* the classifier already. This happened for example
with ImageJ2's miglayout dependency (which comes as an artifact without
a classifier as well as an artifact with the 'swing' classifier).

While at it, we also implement the equals() and hashCode() methods,
as mandated by the Comparable contract.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>