Search in sources :

Example 16 with RepositoryException

use of org.eclipse.ceylon.model.cmr.RepositoryException 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));
    }
}
Also used : ToolUsageError(org.eclipse.ceylon.common.tool.ToolUsageError) RepositoryException(org.eclipse.ceylon.model.cmr.RepositoryException) LegacyImporter(org.eclipse.ceylon.cmr.ceylon.LegacyImporter) IOException(java.io.IOException) RepositoryException(org.eclipse.ceylon.model.cmr.RepositoryException)

Aggregations

RepositoryException (org.eclipse.ceylon.model.cmr.RepositoryException)16 IOException (java.io.IOException)15 File (java.io.File)11 Node (org.eclipse.ceylon.cmr.spi.Node)5 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)5 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)3 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)3 ZipFile (java.util.zip.ZipFile)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 ZipEntry (java.util.zip.ZipEntry)1 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)1