Search in sources :

Example 6 with PropertiesFile

use of org.apache.ivy.util.PropertiesFile in project ant-ivy by apache.

the class Main method initSettings.

private static IvySettings initSettings(CommandLine line, Ivy ivy) throws java.text.ParseException, IOException, ParseException {
    IvySettings settings = ivy.getSettings();
    settings.addAllVariables(System.getProperties());
    if (line.hasOption("properties")) {
        settings.addAllVariables(new PropertiesFile(new File(line.getOptionValue("properties")), "additional properties"));
    }
    if (line.hasOption("m2compatible")) {
        settings.setVariable("ivy.default.configuration.m2compatible", "true");
    }
    configureURLHandler(line.getOptionValue("realm", null), line.getOptionValue("host", null), line.getOptionValue("username", null), line.getOptionValue("passwd", null));
    String settingsPath = line.getOptionValue("settings", "");
    if ("".equals(settingsPath)) {
        settingsPath = line.getOptionValue("conf", "");
        if (!"".equals(settingsPath)) {
            Message.deprecated("-conf is deprecated, use -settings instead");
        }
    }
    if ("".equals(settingsPath)) {
        ivy.configureDefault();
    } else {
        File conffile = new File(settingsPath);
        if (!conffile.exists()) {
            error("ivy configuration file not found: " + conffile);
        } else if (conffile.isDirectory()) {
            error("ivy configuration file is not a file: " + conffile);
        }
        ivy.configure(conffile);
    }
    return settings;
}
Also used : IvySettings(org.apache.ivy.core.settings.IvySettings) PropertiesFile(org.apache.ivy.util.PropertiesFile) PropertiesFile(org.apache.ivy.util.PropertiesFile) File(java.io.File)

Example 7 with PropertiesFile

use of org.apache.ivy.util.PropertiesFile in project ant-ivy by apache.

the class DefaultRepositoryCacheManager method saveResolver.

/**
 * Saves the information of which resolver was used to resolve a md, so that this info can be
 * retrieve later (even after a jvm restart) by getSavedResolverName(ModuleDescriptor md)
 *
 * @param md
 *            the module descriptor resolved
 * @param name
 *            resolver name
 */
private void saveResolver(ModuleDescriptor md, String name) {
    // should always be called with a lock on module metadata artifact
    PropertiesFile cdf = getCachedDataFile(md);
    cdf.setProperty("resolver", name);
    cdf.save();
}
Also used : PropertiesFile(org.apache.ivy.util.PropertiesFile)

Example 8 with PropertiesFile

use of org.apache.ivy.util.PropertiesFile in project ant-ivy by apache.

the class DefaultRepositoryCacheManager method saveResolvedRevision.

public void saveResolvedRevision(String resolverName, ModuleRevisionId mrid, String revision) {
    if (!lockMetadataArtifact(mrid)) {
        Message.error("impossible to acquire lock for " + mrid);
        return;
    }
    try {
        PropertiesFile cachedResolvedRevision;
        if (resolverName == null) {
            cachedResolvedRevision = getCachedDataFile(mrid);
        } else {
            cachedResolvedRevision = getCachedDataFile(resolverName, mrid);
        }
        cachedResolvedRevision.setProperty("resolved.time", String.valueOf(System.currentTimeMillis()));
        cachedResolvedRevision.setProperty("resolved.revision", revision);
        if (resolverName != null) {
            cachedResolvedRevision.setProperty("resolver", resolverName);
        }
        cachedResolvedRevision.save();
    } finally {
        unlockMetadataArtifact(mrid);
    }
}
Also used : PropertiesFile(org.apache.ivy.util.PropertiesFile)

Aggregations

PropertiesFile (org.apache.ivy.util.PropertiesFile)8 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 ArtifactRevisionId (org.apache.ivy.core.module.id.ArtifactRevisionId)1 IvySettings (org.apache.ivy.core.settings.IvySettings)1