* @return String of dependency lines
* @throws MojoExecutionException In case the dependency version could not be determined
*/
String calculateDependencies(final MavenProject proj) throws MojoExecutionException {
Module module = new Module(
new ModuleIdentifier(CeylonUtil.ceylonModuleBaseName(proj.getGroupId(), proj.getArtifactId()),
proj.getVersion(), false, false));
for (Dependency dep : proj.getDependencies()) {
if (dep.getVersion() != null && !"".equals(dep.getVersion())) {
module.addDependency(new ModuleIdentifier(
CeylonUtil.ceylonModuleBaseName(dep.getGroupId(), dep.getArtifactId()), dep.getVersion(),
dep.isOptional(), false)
);
} else {
throw new MojoExecutionException(
"Dependency version could not be determined from the POM. Aborting.");
}
}
StringBuilder builder = new StringBuilder(CeylonUtil.STRING_BUILDER_SIZE);
for (ModuleIdentifier depMod : module.getDependencies()) {
builder.append(depMod.getName());
if (depMod.isOptional()) {
builder.append("?");
}