use of org.eclipse.ceylon.cmr.ceylon.LegacyImporter in project ceylon by eclipse.
the class CeylonImportJarTool method run.
@Override
public void run() throws Exception {
LegacyImporter importer = createImporter().moduleDescriptor(applyCwd(descriptor)).missingDependenciesPackages(parsedMissingDependenciesPackages);
importer.setIgnoreAnnotations(ignoreAnnotations);
if (!force || updateDescriptor) {
try {
importer.loadModuleDescriptor();
} catch (ImportJarException x) {
throw x;
} catch (Exception x) {
String key = "error.descriptorFile.invalid.";
if (descriptor.getName().endsWith(".xml")) {
key += "xml";
} else {
key += "properties";
}
throw new ImportJarException(key, new Object[] { descriptor.getPath(), x.getMessage() }, x);
}
if (!showClasses) {
importer.listPackages(showSuggestions);
} else {
importer.listClasses();
}
}
boolean hasErrors = importer.hasErrors();
if (importer.hasProblems()) {
if (updateDescriptor && descriptor != null) {
if (!dryRun) {
importer.updateModuleDescriptor();
}
} else {
hasErrors = true;
}
}
if (!hasErrors || force) {
if (!hasErrors) {
if (force && !updateDescriptor) {
msg("info.forcedUpdate");
} else {
msg("info.noProblems");
}
} else {
msg("error.problemsFoundForced");
}
if (!dryRun) {
msg("info.noProblems.publishing").newline();
try {
importer.publish();
} catch (RepositoryException x) {
throw new ImportJarException("error.failedWriteArtifact", new Object[] { module, x.getLocalizedMessage() }, x);
} catch (Exception x) {
// FIXME: remove when the whole CMR is using RepositoryException
throw new ImportJarException("error.failedWriteArtifact", new Object[] { module, x.getLocalizedMessage() }, x);
}
String repoString = this.getOutputRepositoryManager().getRepositoriesDisplayString().toString();
msg("info.published", this.module.toString(), repoString.substring(1, repoString.length() - 1));
}
append(".").newline();
} else {
String msgKey;
if (!updateDescriptor && descriptor == null) {
msgKey = "error.problemsFoundSuggest";
} else {
msgKey = "error.problemsFound";
}
throw new ToolUsageError(Messages.msg(ImportJarMessages.RESOURCE_BUNDLE, msgKey));
}
}
Aggregations