return "pom.xml";
}
@Override
public Metadata performMetadataExtraction(File existingFile, Diagnostic result) throws IOException {
Metadata metadata = new Metadata();
String gid = mavenProject.getGroupId();
String owner = gid.substring(gid.lastIndexOf('.') + 1);
metadata.setName(ModuleName.create(owner, mavenProject.getArtifactId(), true));
metadata.setVersion(Version.create(mavenProject.getVersion()));
metadata.setSummary(mavenProject.getName());
Scm scm = mavenProject.getScm();
if(scm != null)
metadata.setSource(scm.getUrl());
metadata.setProjectPage(mavenProject.getUrl());
List<Dependency> forgeDeps = null;
for(org.apache.maven.model.Dependency dep : mavenProject.getDependencies()) {
if("test".equals(dep.getScope()))
continue;
try {
org.apache.maven.artifact.versioning.VersionRange vr = org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec(dep.getVersion());
List<Restriction> restrictions = vr.getRestrictions();
if(restrictions.size() == 1) {
Restriction r = restrictions.get(0);
Version lower = r.getLowerBound() == null
? Version.MIN
: Version.create(r.getLowerBound().toString());
Version upper = r.getUpperBound() == null
? Version.MAX
: Version.create(r.getUpperBound().toString());
Dependency forgeDep = new Dependency();
String dgid = mavenProject.getGroupId();
String downer = dgid.substring(dgid.lastIndexOf('.') + 1);
forgeDep.setName(ModuleName.create(downer, dep.getArtifactId(), true));
forgeDep.setVersionRequirement(VersionRange.create(
lower, r.isLowerBoundInclusive(), upper, r.isUpperBoundInclusive()));
if(forgeDeps == null)
forgeDeps = new ArrayList<Dependency>();
forgeDeps.add(forgeDep);
}
}
catch(InvalidVersionSpecificationException e) {
result.addChild(new FileDiagnostic(
Diagnostic.WARNING, ValidationService.GEPPETTO, e.getMessage(), mavenProject.getFile()));
}
}
metadata.setDependencies(forgeDeps);
return metadata;
}