}
protected <T extends MavenProjectDescriptor> T resolveProject(MavenProject project, Class<T> expectedType) {
Artifact artifact = project.getArtifact();
String id = createId(artifact.getGroupId(), artifact.getArtifactId(), null, null, artifact.getVersion());
MavenProjectDescriptor projectDescriptor = getStore().find(MavenProjectDescriptor.class, id);
if (projectDescriptor == null) {
projectDescriptor = store.create(expectedType, id);
projectDescriptor.setName(project.getName());
projectDescriptor.setGroupId(artifact.getGroupId());
projectDescriptor.setArtifactId(artifact.getArtifactId());
projectDescriptor.setVersion(artifact.getVersion());
} else if (!expectedType.isAssignableFrom(projectDescriptor.getClass())) {
projectDescriptor = getStore().migrate(projectDescriptor, expectedType);
}
return expectedType.cast(projectDescriptor);
}