// TODO: This is not reliable, file might have different name
// FIXME: Surefire might user jar in the classpath instead of the target/classes
final File pomFile = getPomFile(file);
if (pomFile.isFile())
{
final Artifact foundArtifact = getFoundArtifact(pomFile);
if (foundArtifact.getGroupId().equals(artifact.getGroupId())
&& foundArtifact.getArtifactId().equals(artifact.getArtifactId())
&& foundArtifact.getBaseVersion().equals(artifact.getBaseVersion()))
{
if ("pom".equals(artifact.getExtension()))
{
return pomFile;
}
else
{
return new File(file.getParentFile(), "classes");
}
}
}
}
// this is needed for Surefire when run as 'mvn package'
else if (file.isFile())
{
final StringBuilder name = new StringBuilder(artifact.getArtifactId()).append("-").append(
artifact.getBaseVersion());
// TODO: This is nasty
// we need to get a a pom.xml file to be sure we fetch transitive deps as well
if (file.getName().contains(name.toString()))
{
if ("pom".equals(artifact.getExtension()))
{
// try to get pom file for the project
final File pomFile = new File(file.getParentFile().getParentFile(), "pom.xml");
if (pomFile.isFile())
{
Artifact foundArtifact = getFoundArtifact(pomFile);
if (foundArtifact.getGroupId().equals(artifact.getGroupId())
&& foundArtifact.getArtifactId().equals(artifact.getArtifactId())
&& foundArtifact.getBaseVersion().equals(artifact.getBaseVersion()))
{
// System.out
// .println("BUILD: ################################# Artifact: " + artifact + " POM: "
// + pomFile);