Java Code Examples for org.apache.ivy.util.Message#info()

The following examples show how to use org.apache.ivy.util.Message#info() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryAnalyser.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public void analyse(String pattern, DependencyAnalyser depAnalyser) {
    JarModuleFinder finder = new JarModuleFinder(pattern);
    ModuleDescriptor[] mds = depAnalyser.analyze(finder.findJarModules());
    Message.info("found " + mds.length + " modules");
    for (ModuleDescriptor md : mds) {
        File ivyFile = new File(IvyPatternHelper.substitute(
                pattern,
                DefaultArtifact.newIvyArtifact(md.getModuleRevisionId(),
                        md.getPublicationDate())));
        try {
            Message.info("generating " + ivyFile);
            XmlModuleDescriptorWriter.write(md, ivyFile);
        } catch (IOException e) {
            Message.debug(e);
        }
    }
}
 
Example 2
Source File: IvyNode.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void moveToRealNode(String rootModuleConf, IvyNode parent, String parentConf,
        String conf, boolean shouldBePublic, IvyNode resolved) {
    if (resolved.md == null) {
        resolved.md = md;
    }
    if (resolved.module == null) {
        resolved.module = module;
    }
    resolved.downloaded |= module.getReport().isDownloaded();
    resolved.searched |= module.getReport().isSearched();
    resolved.dds.putAll(dds);
    resolved.updateDataFrom(this, rootModuleConf, true);
    resolved.loadData(rootModuleConf, parent, parentConf, conf, shouldBePublic, usage);
    resolved.usage.updateDataFrom(getAllUsages(), rootModuleConf);
    usage = resolved.usage;

    data.replaceNode(getId(), resolved, rootModuleConf); // this actually discards the node

    if (settings.logResolvedRevision()
            && LogOptions.LOG_DEFAULT.equals(getData().getOptions().getLog())) {
        Message.info("\t[" + module.getId().getRevision() + "] " + getId());
    } else {
        Message.verbose("\t[" + module.getId().getRevision() + "] " + getId());
    }
}
 
Example 3
Source File: RepositoryManagementEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Loads data from the repository.
 * <p>
 * This method usually takes a long time to proceed. It should never be called from event
 * dispatch thread in a GUI.
 * </p>
 */
public void load() {
    long startingMemoryUse = 0;
    if (settings.dumpMemoryUsage()) {
        startingMemoryUse = MemoryUtil.getUsedMemory();
    }
    long startTime = System.currentTimeMillis();
    Message.rawinfo("searching modules... ");
    ModuleRevisionId[] mrids = searchModules();
    Message.info("loading repository metadata...");
    for (ModuleRevisionId mrid : mrids) {
        try {
            loadModuleRevision(mrid);
        } catch (Exception e) {
            Message.debug(e);
            errors.put(mrid, e.getMessage());
        }
    }
    long endTime = System.currentTimeMillis();
    Message.info(String.format("%nrepository loaded: %d modules; %d revisions; %s%ss",
            modules.size(), revisions.size(), settings.dumpMemoryUsage()
                    ? (MemoryUtil.getUsedMemory() - startingMemoryUse) / KILO + "kB; " : "",
            (endTime - startTime) / THOUSAND));
    loaded = true;
}
 
Example 4
Source File: RepositoryManagementEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Analyze data in the repository.
 * <p>
 * This method may take a long time to proceed. It should never be called from event dispatch
 * thread in a GUI.
 * </p>
 *
 * @throws IllegalStateException
 *             if the repository has not been loaded yet
 * @see #load()
 */
public void analyze() {
    ensureLoaded();
    Message.info("\nanalyzing dependencies...");
    for (ModuleDescriptor md : revisions.values()) {
        for (DependencyDescriptor dd : md.getDependencies()) {
            ModuleRevisionId dep = getDependency(dd);
            if (dep == null) {
                Message.warn("inconsistent repository: declared dependency not found: " + dd);
            } else {
                getDependers(dep).add(md.getModuleRevisionId());
            }
        }
        Message.progress();
    }
    analyzed = true;
}
 
Example 5
Source File: DefaultRepositoryCacheManager.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void unpackArtifact(Artifact artifact, ArtifactDownloadReport adr,
        CacheDownloadOptions options) {
    Artifact unpacked = packagingManager.getUnpackedArtifact(artifact);
    if (unpacked == null) {
        // nothing to unpack
        return;
    }

    File archiveFile = getArchiveFileInCache(unpacked, null, false);
    if (archiveFile.exists() && !options.isForce()) {
        adr.setUnpackedLocalFile(archiveFile);
        adr.setUnpackedArtifact(unpacked);
    } else {
        Message.info("\tUnpacking " + artifact.getId());
        try {
            final Artifact unpackedArtifact = packagingManager.unpackArtifact(artifact, adr.getLocalFile(), archiveFile);
            adr.setUnpackedLocalFile(archiveFile);
            adr.setUnpackedArtifact(unpackedArtifact);
        } catch (Exception e) {
            Message.debug(e);
            adr.setDownloadStatus(DownloadStatus.FAILED);
            adr.setDownloadDetails("The packed artifact " + artifact.getId()
                    + " could not be unpacked (" + e.getMessage() + ")");
        }
    }
}
 
Example 6
Source File: IvySettings.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public synchronized void load(File settingsFile) throws ParseException, IOException {
    Message.info(":: loading settings :: file = " + settingsFile);
    long start = System.currentTimeMillis();
    setSettingsVariables(settingsFile);
    if (getVariable("ivy.default.ivy.user.dir") != null) {
        setDefaultIvyUserDir(Checks.checkAbsolute(getVariable("ivy.default.ivy.user.dir"),
            "ivy.default.ivy.user.dir"));
    } else {
        getDefaultIvyUserDir();
    }

    loadDefaultProperties();
    try {
        new XmlSettingsParser(this).parse(settingsFile.toURI().toURL());
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException(
                "given file cannot be transformed to url: " + settingsFile, e);
    }
    setVariable("ivy.default.ivy.user.dir", getDefaultIvyUserDir().getAbsolutePath(), false);
    Message.verbose("settings loaded (" + (System.currentTimeMillis() - start) + "ms)");
    dumpSettings();
}
 
Example 7
Source File: IvySettings.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public synchronized void load(URL settingsURL) throws ParseException, IOException {
    Message.info(":: loading settings :: url = " + settingsURL);
    long start = System.currentTimeMillis();
    setSettingsVariables(settingsURL);
    if (getVariable("ivy.default.ivy.user.dir") != null) {
        setDefaultIvyUserDir(Checks.checkAbsolute(getVariable("ivy.default.ivy.user.dir"),
            "ivy.default.ivy.user.dir"));
    } else {
        getDefaultIvyUserDir();
    }

    loadDefaultProperties();
    new XmlSettingsParser(this).parse(settingsURL);
    setVariable("ivy.default.ivy.user.dir", getDefaultIvyUserDir().getAbsolutePath(), false);
    Message.verbose("settings loaded (" + (System.currentTimeMillis() - start) + "ms)");
    dumpSettings();
}
 
Example 8
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
    RepositoryCacheManager cacheManager = getRepositoryCacheManager();

    clearArtifactAttempts();
    DownloadReport dr = new DownloadReport();
    for (Artifact artifact : artifacts) {
        ArtifactDownloadReport adr = cacheManager.download(artifact, artifactResourceResolver,
            downloader, getCacheDownloadOptions(options));
        if (DownloadStatus.FAILED == adr.getDownloadStatus()) {
            if (!ArtifactDownloadReport.MISSING_ARTIFACT.equals(adr.getDownloadDetails())) {
                Message.warn("\t" + adr);
            }
        } else if (DownloadStatus.NO == adr.getDownloadStatus()) {
            Message.verbose("\t" + adr);
        } else if (LogOptions.LOG_QUIET.equals(options.getLog())) {
            Message.verbose("\t" + adr);
        } else {
            Message.info("\t" + adr);
        }
        dr.addArtifactReport(adr);
        checkInterrupted();
    }
    return dr;
}
 
Example 9
Source File: FileUtilTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    try {
        final Path tmpFile = Files.createTempFile(null, null);
        tmpFile.toFile().deleteOnExit();
        final Path symlink = Files.createSymbolicLink(Paths.get(Files.createTempDirectory(null).toString(),
                "symlink-test-file"), tmpFile);
        symlinkCapable = true;
        symlink.toFile().deleteOnExit();
    } catch (IOException ioe) {
        // ignore and move on
        symlinkCapable = false;
        Message.info("Current system isn't considered to have symlink capability due to ", ioe);
    }
}
 
Example 10
Source File: LocalFileRepoOverHttp.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(final HttpExchange httpExchange) throws IOException {
    final URI requestURI = httpExchange.getRequestURI();
    Message.info("Handling " + httpExchange.getRequestMethod() + " request " + requestURI);
    final URI artifactURI;
    try {
        artifactURI = new URI(webContextRoot).relativize(requestURI);
    } catch (URISyntaxException e) {
        throw new IOException(e);
    }
    final Path localFilePath = localFileRepoRoot.resolve(artifactURI.toString());
    if (httpExchange.getRequestMethod().equals("HEAD")) {
        final boolean available = this.isPresent(localFilePath);
        if (!available) {
            httpExchange.sendResponseHeaders(404, -1);
        } else {
            httpExchange.sendResponseHeaders(200, -1);
        }
        return;
    }
    if (!httpExchange.getRequestMethod().equals("GET")) {
        throw new IOException("Cannot handle " + httpExchange.getRequestMethod() + " HTTP method");
    }
    final OutputStream responseStream = httpExchange.getResponseBody();
    @SuppressWarnings("unused")
    final int numBytes = this.serve(httpExchange, localFilePath, responseStream);
    responseStream.close();
}
 
Example 11
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * If the system {@link #systemHasSymlinkAbility has symlink ability} then asserts that the
 * passed {@code filePath} is a {@link Files#isSymbolicLink(Path) symbolic link}. Else asserts
 * that the {@code filePath} {@link Files#exists(Path, LinkOption...) exists}.
 *
 * @param filePath String
 */
private void assertLinkOrExists(final String filePath) {
    if (systemHasSymlinkAbility) {
        assertTrue(filePath + " was expected to be a symlink", Files.isSymbolicLink(Paths.get(filePath)));
        return;
    }
    Message.info("System doesn't have symlink ability so checking if path " + filePath + " exists instead of checking for it to be a symlink");
    assertTrue("Missing " + filePath, Files.exists(Paths.get(filePath)));
}
 
Example 12
Source File: FileSystemResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public void commitPublishTransaction() throws IOException {
    if (supportTransaction()) {
        if (!isTransactionStarted()) {
            throw new IllegalStateException("no current transaction!");
        }
        if (transactionDestDir.exists()) {
            throw new IOException(
                    "impossible to commit transaction: transaction destination directory "
                            + "already exists: "
                            + transactionDestDir
                            + "\npossible cause: usage of identifying tokens after the revision token");
        }
        try {
            getFileRepository().move(transactionTempDir, transactionDestDir);

            Message.info("\tpublish committed: moved " + transactionTempDir + " \n\t\tto "
                    + transactionDestDir);
        } catch (IOException ex) {
            String message;
            try {
                getFileRepository().delete(transactionTempDir);
                message = "publish transaction commit error for "
                            + transactionDestDir + ": rolled back";
            } catch (IOException deleteEx) {
                message = "publish transaction commit error for "
                            + transactionDestDir + ": rollback impossible either, "
                            + "please remove " + transactionTempDir + " manually";
            }
            throw new IOException(message, ex);
        } finally {
            closeTransaction();
        }
    }
}
 
Example 13
Source File: FileSystemResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public void abortPublishTransaction() throws IOException {
    if (supportTransaction()) {
        if (isTransactionStarted()) {
            try {
                getFileRepository().delete(transactionTempDir);
                Message.info("\tpublish aborted: deleted " + transactionTempDir);
            } finally {
                closeTransaction();
            }
        } else {
            Message.info("\tpublish aborted: nothing was started");
        }
    }
}
 
Example 14
Source File: IvySettings.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private Class<?> classForName(String className, boolean silentFail) {
    try {
        return getClassLoader().loadClass(className);
    } catch (ClassNotFoundException e) {
        if (silentFail) {
            Message.info("impossible to define new type: class not found: " + className
                    + " in " + classpathURLs + " nor Ivy classloader");
            return null;
        } else {
            throw new RuntimeException("impossible to define new type: class not found: "
                    + className + " in " + classpathURLs + " nor Ivy classloader");
        }
    }
}
 
Example 15
Source File: IvyNode.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Blacklists the current node, so that a new resolve process won't ever consider this node as
 * available in the repository.
 * <p>
 * This is useful in combination with {@link RestartResolveProcess} for conflict manager
 * implementation which use a best effort strategy to find compatible dependency set, like
 * {@link LatestCompatibleConflictManager}
 * </p>
 *
 * @param bdata
 *            the root module configuration in which the node should be blacklisted
 */
public void blacklist(IvyNodeBlacklist bdata) {
    if (data.getSettings().logResolvedRevision()) {
        Message.info("BLACKLISTING " + bdata);
    } else {
        Message.verbose("BLACKLISTING " + bdata);
    }

    Stack<IvyNode> callerStack = new Stack<>();
    callerStack.push(this);
    clearEvictionDataInAllCallers(bdata.getRootModuleConf(), callerStack);

    usage.blacklist(bdata);
    data.blacklist(this);
}
 
Example 16
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void outputReport(ResolveReport report, ResolutionCacheManager cacheMgr,
        ResolveOptions options) throws IOException {
    if (ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
        Message.info(":: resolution report :: resolve " + report.getResolveTime() + "ms"
                + " :: artifacts dl " + report.getDownloadTime() + "ms");
    } else {
        Message.verbose(":: resolution report :: resolve " + report.getResolveTime() + "ms"
                + " :: artifacts dl " + report.getDownloadTime() + "ms");
    }
    report.setProblemMessages(Message.getProblems());
    // output report
    report.output(settings.getReportOutputters(), cacheMgr, options);
}
 
Example 17
Source File: OBRXMLWriter.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public static void writeManifests(Iterable<ManifestAndLocation> manifestAndLocations,
        ContentHandler handler, boolean quiet) throws SAXException {
    int level = quiet ? Message.MSG_DEBUG : Message.MSG_WARN;
    handler.startDocument();
    AttributesImpl atts = new AttributesImpl();
    handler.startElement("", RepositoryHandler.REPOSITORY, RepositoryHandler.REPOSITORY, atts);
    int nbOk = 0;
    int nbRejected = 0;
    for (ManifestAndLocation manifestAndLocation : manifestAndLocations) {
        BundleInfo bundleInfo;
        try {
            bundleInfo = ManifestParser.parseManifest(manifestAndLocation.getManifest());
            bundleInfo
                    .addArtifact(new BundleArtifact(false, manifestAndLocation.getUri(), null));
            if (manifestAndLocation.getSourceURI() != null) {
                bundleInfo.addArtifact(new BundleArtifact(true, manifestAndLocation
                        .getSourceURI(), null));
            }
            nbOk++;
        } catch (ParseException e) {
            nbRejected++;
            IvyContext
                    .getContext()
                    .getMessageLogger()
                    .log("Rejected " + manifestAndLocation.getUri() + ": " + e.getMessage(),
                        level);
            continue;
        }
        saxBundleInfo(bundleInfo, handler);
    }
    handler.endElement("", RepositoryHandler.REPOSITORY, RepositoryHandler.REPOSITORY);
    handler.endDocument();
    Message.info(nbOk + " bundle" + (nbOk > 1 ? "s" : "") + " added, " + nbRejected + " bundle"
            + (nbRejected > 1 ? "s" : "") + " rejected.");
}
 
Example 18
Source File: AntCallTrigger.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void progress(IvyEvent event) {
    Project project = (Project) IvyContext.peekInContextStack(IvyTask.ANT_PROJECT_CONTEXT_KEY);
    if (project == null) {
        Message.info("ant call trigger can only be used from an ant build. Ignoring.");
        return;
    }
    if (onlyonce && isTriggered(event)) {
        Message.verbose("call already triggered for this event, skipping: " + event);
    } else {
        CallTarget call = new CallTarget();

        call.setProject(project);
        call.setTaskName("antcall");

        Map<String, String> attributes = event.getAttributes();
        String target = IvyPatternHelper.substituteTokens(getTarget(), attributes);
        call.setTarget(target);

        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            Property p = call.createParam();
            p.setName(prefix == null ? entry.getKey() : prefix + entry.getKey());
            p.setValue(entry.getValue() == null ? "" : entry.getValue());
        }

        Message.verbose("triggering ant call: target=" + target + " for " + event);
        call.execute();
        markTriggered(event);

        Message.debug("triggered ant call finished: target=" + target + " for " + event);
    }
}
 
Example 19
Source File: SshCache.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void showMessage(String message) {
    Message.info(message);
}
 
Example 20
Source File: FileBasedLockStrategy.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private static void debugLocking(String msg) {
    Message.info(Thread.currentThread() + " " + System.currentTimeMillis() + " " + msg);
}