}
else if (!repositoryDirectory.isDirectory()) {
throw new MojoExecutionException("Invalid reposiory directory: " + repositoryDirectory);
}
WriteableRepository repository = new Maven2Repository(repositoryDirectory);
// Install all of the artifacts we were asked to...
for (int i=0; i<artifacts.length; i++) {
Artifact artifact = getArtifact(artifacts[i]);
log.info("Installing: " + artifact);
org.apache.geronimo.kernel.repository.Artifact gartifact = mavenArtifactToGeronimo(artifact);
if (repository.contains(gartifact)) {
if (force) {
File file = repository.getLocation(gartifact);
log.debug("Force deletion of: " + file);
if (!file.delete()) {
throw new MojoExecutionException("Failed to delete artifact from repository: " + artifacts[i]);
}
}
else {
throw new MojoExecutionException("Artifact already exists in repository: " + artifacts[i]);
}
}
repository.copyToRepository(artifact.getFile(), gartifact, null);
}
}