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

The following examples show how to use org.apache.ivy.util.Message#warn() . 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: IvyBuildList.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void onMissingDescriptor(File buildFile, File ivyFile, List<File> noDescriptor) {
    switch (onMissingDescriptor) {
        case OnMissingDescriptor.FAIL:
            throw new BuildException("a module has no module descriptor and"
                    + " onMissingDescriptor=fail. Build file: " + buildFile
                    + ". Expected descriptor: " + ivyFile);
        case OnMissingDescriptor.SKIP:
            Message.debug("skipping " + buildFile + ": descriptor " + ivyFile
                    + " doesn't exist");
            break;
        case OnMissingDescriptor.WARN:
            Message.warn("a module has no module descriptor. " + "Build file: " + buildFile
                    + ". Expected descriptor: " + ivyFile);
            // fall through
        default:
            Message.verbose(String.format("no descriptor for %s: descriptor=%s: adding it at the %s of the path",
                    buildFile, ivyFile, (OnMissingDescriptor.TAIL.equals(onMissingDescriptor) ? "tail" : "head")));
            Message.verbose("\t(change onMissingDescriptor if you want to take another action");
            noDescriptor.add(buildFile);
            break;
    }
}
 
Example 2
Source File: CapabilityAdapter.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public static void adapt(BundleInfo bundleInfo, Capability capability) throws ParseException {
    String name = capability.getName();
    switch (name) {
        case BundleInfo.PACKAGE_TYPE:
            bundleInfo.addCapability(getExportPackage(bundleInfo, capability));
            break;
        case BundleInfo.BUNDLE_TYPE:
            // nothing to do, already handled at the resource tag level
            break;
        case BundleInfo.SERVICE_TYPE:
            bundleInfo.addCapability(getOSGiService(bundleInfo, capability));
            break;
        default:
            Message.warn("Unsupported capability '" + name + "' on the bundle '"
                    + bundleInfo.getSymbolicName() + "'");
            break;
    }
}
 
Example 3
Source File: ResolverHelper.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public static String[] listAll(URLLister lister, URL root) {
    try {
        if (lister.accept(root.toExternalForm())) {
            Message.debug("\tusing " + lister + " to list all in " + root);
            List<URL> all = lister.listAll(root);
            Message.debug("\t\tfound " + all.size() + " urls");
            List<String> names = new ArrayList<>(all.size());
            for (URL dir : all) {
                String path = dir.getPath();
                if (path.endsWith("/")) {
                    path = path.substring(0, path.length() - 1);
                }
                int slashIndex = path.lastIndexOf('/');
                names.add(path.substring(slashIndex + 1));
            }
            return names.toArray(new String[names.size()]);
        }
        return null;
    } catch (Exception e) {
        Message.warn("problem while listing directories in " + root, e);
        return null;
    }
}
 
Example 4
Source File: Main.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the <code>cp</code> option from the command line, and returns a list of {@link File}.
 * <p>
 * All the files contained in the returned List exist, non existing files are simply skipped
 * with a warning.
 * </p>
 *
 * @param line
 *            the command line in which the cp option should be parsed
 * @return a List of files to include as extra classpath entries, or <code>null</code> if no cp
 *         option was provided.
 */
private static List<File> getExtraClasspathFileList(CommandLine line) {
    List<File> fileList = null;
    if (line.hasOption("cp")) {
        fileList = new ArrayList<>();
        for (String cp : line.getOptionValues("cp")) {
            StringTokenizer tokenizer = new StringTokenizer(cp, File.pathSeparator);
            while (tokenizer.hasMoreTokens()) {
                String token = tokenizer.nextToken();
                File file = new File(token);
                if (file.exists()) {
                    fileList.add(file);
                } else {
                    Message.warn("Skipping extra classpath '" + file
                            + "' as it does not exist.");
                }
            }
        }
    }
    return fileList;
}
 
Example 5
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 6
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 7
Source File: IvyNode.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Deprecated
public void discardConf(String rootModuleConf, String conf) {
    Set<String> depConfs = usage.addAndGetConfigurations(rootModuleConf);
    if (md == null) {
        depConfs.remove(conf);
    } else {
        // remove all given dependency configurations to the set + extended ones
        Configuration c = md.getConfiguration(conf);
        if (conf == null) {
            Message.warn("unknown configuration in " + getId() + ": " + conf);
        } else {
            // recursive remove of extended configurations
            for (String ext : c.getExtends()) {
                discardConf(rootModuleConf, ext);
            }
            depConfs.remove(c.getName());
        }
    }
}
 
Example 8
Source File: RepositoryManagementEngine.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void loadModuleRevision(ModuleRevisionId mrid) throws Exception {
    ResolvedModuleRevision module = settings.getResolver(mrid).getDependency(
        new DefaultDependencyDescriptor(mrid, false), newResolveData());
    if (module == null) {
        Message.warn("module not found while listed: " + mrid);
    } else {
        revisions.put(module.getId(), module.getDescriptor());
        getAllRevisions(module.getId()).add(module.getDescriptor());
    }
    Message.progress();
}
 
Example 9
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public static List<PomDependencyMgt> getDependencyManagements(ModuleDescriptor md) {
    List<PomDependencyMgt> result = new ArrayList<>();

    if (md instanceof PomModuleDescriptor) {
        result.addAll(((PomModuleDescriptor) md).getDependencyManagementMap().values());
    } else {
        for (ExtraInfoHolder extraInfoHolder : md.getExtraInfos()) {
            String key = extraInfoHolder.getName();
            if (key.startsWith(DEPENDENCY_MANAGEMENT)) {
                String[] parts = key.split(EXTRA_INFO_DELIMITER);
                if (parts.length != DEPENDENCY_MANAGEMENT_KEY_PARTS_COUNT) {
                    Message.warn("what seem to be a dependency management extra info "
                            + "doesn't match expected pattern: " + key);
                } else {
                    String versionKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + parts[1]
                            + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER
                            + "version";
                    String scopeKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + parts[1]
                            + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER + "scope";

                    String version = md.getExtraInfoContentByTagName(versionKey);
                    String scope = md.getExtraInfoContentByTagName(scopeKey);

                    List<ModuleId> exclusions = getDependencyMgtExclusions(md, parts[1],
                        parts[2]);
                    result.add(new DefaultPomDependencyMgt(parts[1], parts[2], version, scope,
                            exclusions));
                }
            }
        }
    }
    return result;
}
 
Example 10
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void checkNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef,
        ResolveData data) {
    if (!getNamespace().equals(Namespace.SYSTEM_NAMESPACE) && !systemMd.isDefault()
            && data.getSettings().logNotConvertedExclusionRule()
            && systemMd instanceof DefaultModuleDescriptor) {
        DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) systemMd;
        if (dmd.isNamespaceUseful()) {
            Message.warn("the module descriptor " + ivyRef.getResource()
                    + " has information which can't be converted into the system namespace. It will require the availability of the namespace '"
                    + getNamespace().getName() + "' to be fully usable.");
        }
    }
}
 
Example 11
Source File: IvySettings.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public synchronized void setSettingsVariables(URL settingsURL) {
    String settingsURLStr = settingsURL.toExternalForm();
    setVariable("ivy.settings.url", settingsURLStr);
    setDeprecatedVariable("ivy.conf.url", "ivy.settings.url");
    int slashIndex = settingsURLStr.lastIndexOf('/');
    if (slashIndex != -1) {
        String dirUrl = settingsURLStr.substring(0, slashIndex);
        setVariable("ivy.settings.dir", dirUrl);
        setVariable("ivy.settings.dir.url", dirUrl);
        setDeprecatedVariable("ivy.conf.dir", "ivy.settings.dir");
    } else {
        Message.warn("settings url does not contain any slash (/): "
                + "ivy.settings.dir variable not set");
    }
}
 
Example 12
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public void reportFailure(Artifact art) {
    Message.warn("==== " + getName() + ": tried");
    List<String> attempts = artattempts.get(art);
    if (attempts != null) {
        for (String m : attempts) {
            Message.warn("  " + m);
        }
    }
}
 
Example 13
Source File: RetrieveOptions.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * @param makeSymlinksInMass ditto
 * @return RetrieveOptions
 * @deprecated Starting 2.5, creating symlinks in mass is no longer supported and this
 * method plays no role in creation of symlinks. Use {@link #setMakeSymlinks(boolean)} instead
 */
@Deprecated
public RetrieveOptions setMakeSymlinksInMass(boolean makeSymlinksInMass) {
    this.makeSymlinksInMass = makeSymlinksInMass;
    Message.warn("symlinkmass option has been deprecated and will no longer be supported");
    return this;
}
 
Example 14
Source File: WarningNonMatchingVersionReporter.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected void reportMessage(String msg) {
    Message.warn(msg);
}
 
Example 15
Source File: AbstractModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
@Override
public void warning(SAXParseException ex) {
    Message.warn("xml parsing: " + getLocationString(ex) + ": " + ex.getMessage());
}
 
Example 16
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void doFetchDependencies(VisitNode node, String conf, Set<String> fetchedSet) {
    Configuration c = node.getConfiguration(conf);
    if (c == null) {
        if (!node.isConfRequiredByMergedUsageOnly(conf)) {
            Message.warn("configuration not found '" + conf + "' in " + node.getResolvedId()
                    + ": ignoring");
            if (node.getParent() != null) {
                Message.warn("it was required from " + node.getParent().getResolvedId());
            }
        }
        return;
    }
    // we handle the case where the asked configuration extends others:
    // we have to first fetch the extended configurations

    // first we check if this is the actual requested conf (not an extended one)
    boolean requestedConfSet = false;
    if (node.getRequestedConf() == null) {
        node.setRequestedConf(conf);
        requestedConfSet = true;
    }
    // now let's recurse in extended confs
    String[] extendedConfs = c.getExtends();
    if (extendedConfs.length > 0) {
        node.updateConfsToFetch(Arrays.asList(extendedConfs));
    }
    for (String extendedConf : extendedConfs) {
        fetchDependencies(node, extendedConf, fetchedSet, false);
    }

    // now we can actually resolve this configuration dependencies
    if (!isDependenciesFetched(node.getNode(), conf, fetchedSet) && node.isTransitive()) {
        for (VisitNode dep : node.getDependencies(conf)) {
            dep.useRealNode(); // the node may have been resolved to another real one while
            // resolving other deps
            for (String rconf : dep.getRequiredConfigurations(node, conf)) {
                fetchDependencies(dep, rconf, fetchedSet, true);
            }
            if (!dep.isEvicted() && !dep.hasProblem()) {
                // if there are still confs to fetch (usually because they have
                // been updated when evicting another module), we fetch them now
                for (String fconf : dep.getConfsToFetch()) {
                    // shouldBeFixed=false to because some of those dependencies might
                    // be private when they were actually extending public conf.
                    // Should we keep two list of confs to fetch (private&public)?
                    // I don't think, visibility is already checked, and a change in the
                    // configuration between version might anyway have worse problems.
                    fetchDependencies(dep, fconf, fetchedSet, false);
                }
            }
        }
        markDependenciesFetched(node.getNode(), conf, fetchedSet);
    }
    // we have finished with this configuration, if it was the original requested conf
    // we can clean it now
    if (requestedConfSet) {
        node.setRequestedConf(null);
    }

}
 
Example 17
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void handleTransitiveEviction(ModuleDescriptor md, String[] confs, ResolveData data,
                                      List<IvyNode> sortedDependencies) {
    // handle transitive eviction now:
    // if a module has been evicted then all its dependencies required only by it should be
    // evicted too. Since nodes are now sorted from the more dependent to the less one, we
    // can traverse the list and check only the direct parent and not all the ancestors
    for (IvyNode node : sortedDependencies) {
        if (!node.isCompletelyEvicted()) {
            for (String conf : confs) {
                IvyNodeCallers.Caller[] callers = node.getCallers(conf);
                if (settings.debugConflictResolution()) {
                    Message.debug("checking if " + node.getId()
                            + " is transitively evicted in " + conf);
                }
                boolean allEvicted = callers.length > 0;
                for (IvyNodeCallers.Caller caller : callers) {
                    if (caller.getModuleRevisionId().equals(md.getModuleRevisionId())) {
                        // the caller is the root module itself, it can't be evicted
                        allEvicted = false;
                        break;
                    } else {
                        IvyNode callerNode = data.getNode(caller.getModuleRevisionId());
                        if (callerNode == null) {
                            Message.warn("ivy internal error: no node found for "
                                    + caller.getModuleRevisionId() + ": looked in "
                                    + data.getNodeIds() + " and root module id was "
                                    + md.getModuleRevisionId());
                        } else if (!callerNode.isEvicted(conf)) {
                            allEvicted = false;
                            break;
                        } else {
                            if (settings.debugConflictResolution()) {
                                Message.debug("caller " + callerNode.getId() + " of "
                                        + node.getId() + " is evicted");
                            }
                        }
                    }
                }
                if (allEvicted) {
                    Message.verbose("all callers are evicted for " + node + ": evicting too");
                    node.markEvicted(conf, null, null, null);
                } else {
                    if (settings.debugConflictResolution()) {
                        Message.debug(node.getId()
                                + " isn't transitively evicted, at least one caller was"
                                + " not evicted");
                    }
                }
            }
        }
    }
}
 
Example 18
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void downloadArtifacts(ResolveReport report, Filter<Artifact> artifactFilter,
        DownloadOptions options) {
    long start = System.currentTimeMillis();

    eventManager.fireIvyEvent(new PrepareDownloadEvent(report.getArtifacts().toArray(
        new Artifact[report.getArtifacts().size()])));

    long totalSize = 0;
    for (IvyNode dependency : report.getDependencies()) {
        checkInterrupted();
        // download artifacts required in all asked configurations
        if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()
                && dependency.getModuleRevision() != null) {
            DependencyResolver resolver = dependency.getModuleRevision()
                    .getArtifactResolver();
            Artifact[] selectedArtifacts = dependency.getSelectedArtifacts(artifactFilter);
            DownloadReport dReport = resolver.download(selectedArtifacts, options);
            for (ArtifactDownloadReport adr : dReport.getArtifactsReports()) {
                if (adr.getDownloadStatus() == DownloadStatus.FAILED) {
                    if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) {
                        Message.warn("\tmerged artifact not found: " + adr.getArtifact()
                                + ". It was required in "
                                + adr.getArtifact().getExtraAttribute("ivy:merged"));
                    } else {
                        Message.warn("\t" + adr);
                        resolver.reportFailure(adr.getArtifact());
                    }
                } else if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
                    totalSize += adr.getSize();
                }
            }
            // update concerned reports
            for (String dconf : dependency.getRootModuleConfigurations()) {
                // the report itself is responsible to take into account only
                // artifacts required in its corresponding configuration
                // (as described by the Dependency object)
                if (dependency.isEvicted(dconf)
                        || dependency.isBlacklisted(dconf)) {
                    report.getConfigurationReport(dconf).addDependency(dependency);
                } else {
                    report.getConfigurationReport(dconf).addDependency(dependency,
                            dReport);
                }
            }
        }
    }
    report.setDownloadTime(System.currentTimeMillis() - start);
    report.setDownloadSize(totalSize);
}
 
Example 19
Source File: WarnCircularDependencyStrategy.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected void logCircularDependency(ModuleRevisionId[] mrids) {
    Message.warn("circular dependency found: " + CircularDependencyHelper.formatMessage(mrids));
}
 
Example 20
Source File: XmlModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected void infoStarted(Attributes attributes) {
    state = State.INFO;
    String org = settings.substitute(attributes.getValue("organisation"));
    String module = settings.substitute(attributes.getValue("module"));
    String revision = settings.substitute(attributes.getValue("revision"));
    String branch = settings.substitute(attributes.getValue("branch"));
    getMd().setModuleRevisionId(
        ModuleRevisionId.newInstance(
            org,
            module,
            branch,
            revision,
            ExtendableItemHelper.getExtraAttributes(settings, attributes, Arrays.asList(
                    "organisation", "module", "revision", "status", "publication",
                    "branch", "namespace", "default", "resolver"))));

    String namespace = settings.substitute(attributes.getValue("namespace"));
    if (namespace != null) {
        Namespace ns = settings.getNamespace(namespace);
        if (ns == null) {
            Message.warn("namespace not found for " + getMd().getModuleRevisionId() + ": "
                    + namespace);
        } else {
            getMd().setNamespace(ns);
        }
    }

    String status = settings.substitute(attributes.getValue("status"));
    getMd().setStatus(
        status == null ? settings.getStatusManager().getDefaultStatus() : status);
    getMd().setDefault(
            Boolean.valueOf(settings.substitute(attributes.getValue("default"))));
    String pubDate = settings.substitute(attributes.getValue("publication"));
    if (pubDate != null && pubDate.length() > 0) {
        try {
            getMd().setPublicationDate(DateUtil.parse(pubDate));
        } catch (ParseException e) {
            addError("invalid publication date format: " + pubDate);
            getMd().setPublicationDate(getDefaultPubDate());
        }
    } else {
        getMd().setPublicationDate(getDefaultPubDate());
    }
}