Search in sources :

Example 16 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class ConfigWriterTest method testSimpleWipe.

@Test
public void testSimpleWipe() throws IOException {
    String contents = readFile(new File("test/src/org/eclipse/ceylon/common/test/writer-wiped.config"));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ConfigWriter.instance().write(new CeylonConfig(), testFile, out);
    Assert.assertEquals(contents, out.toString("UTF-8"));
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) Test(org.junit.Test)

Example 17 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class CeylonConfigAntTask method execute.

@Override
public void execute() throws BuildException {
    Java7Checker.check();
    CeylonConfig config = getConfig();
    for (String key : config.getOptionNames(null)) {
        String[] values = config.getOptionValues(key);
        setConfigValueAsProperty(values, getPrefix() + key);
    }
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig)

Example 18 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class CeylonConfigRepositoryAntTask method execute.

@Override
public void execute() throws BuildException {
    Java7Checker.check();
    if (name == null && type == null) {
        throw new BuildException("Either the 'name' or 'type' attribute has to be specified for 'ceylon-config-repository'");
    }
    if (name != null && type != null) {
        throw new BuildException("The 'name' and 'type' attributes cannot both be specified for 'ceylon-config-repository'");
    }
    if (key == null) {
        throw new BuildException("'key' is a required attribute for 'ceylon-config-repository'");
    }
    if (property == null) {
        throw new BuildException("'property' is a required attribute for 'ceylon-config-value'");
    }
    CeylonConfig config = getConfig();
    Repositories reps = Repositories.withConfig(config);
    Repository rep;
    String repdesc;
    if (name != null) {
        rep = reps.getRepository(name);
        repdesc = "of name '" + name + "'";
    } else {
        rep = reps.getRepositoryByTypeWithDefaults(type.name());
        repdesc = "of type '" + type.name() + "'";
    }
    if (rep != null) {
        String value = null;
        switch(key) {
            case name:
                value = rep.getName();
                break;
            case url:
                value = rep.getUrl();
                break;
            default:
                Credentials cred = rep.getCredentials();
                if (cred != null) {
                    switch(key) {
                        case user:
                            value = cred.getUser();
                            break;
                        case password:
                            value = cred.getPassword();
                            break;
                        case keystore:
                            value = cred.getKeystore();
                            break;
                        case alias:
                            value = cred.getAlias();
                            break;
                        default:
                    }
                } else {
                    log("No credentials found for repository " + repdesc, Project.MSG_WARN);
                }
        }
        if (value != null) {
            setProjectProperty(property, value);
        }
    } else {
        log("Repository " + repdesc + " not found", Project.MSG_WARN);
    }
}
Also used : Repositories(org.eclipse.ceylon.common.config.Repositories) Repository(org.eclipse.ceylon.common.config.Repositories.Repository) CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) BuildException(org.apache.tools.ant.BuildException) Credentials(org.eclipse.ceylon.common.config.Credentials)

Example 19 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class CeylonConfigValueAntTask method execute.

@Override
public void execute() throws BuildException {
    Java7Checker.check();
    if (key == null) {
        throw new BuildException("'key' is a required attribute for 'ceylon-config-value'");
    }
    if (property == null) {
        throw new BuildException("'property' is a required attribute for 'ceylon-config-value'");
    }
    CeylonConfig config = getConfig();
    String[] values = config.getOptionValues(key);
    setConfigValueAsProperty(values, property);
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) BuildException(org.apache.tools.ant.BuildException)

Example 20 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class CompilerConfig method instance.

public static CeylonConfig instance(Context context) {
    CeylonConfig instance = context.get(CeylonConfig.class);
    if (instance == null) {
        Options options = Options.instance(context);
        String cwd = options.get(Option.CEYLONCWD);
        if (cwd == null) {
            cwd = ".";
        }
        instance = CeylonConfig.createFromLocalDir(new File(cwd));
        context.put(CeylonConfig.class, instance);
    }
    return instance;
}
Also used : Options(org.eclipse.ceylon.langtools.tools.javac.util.Options) CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) File(java.io.File)

Aggregations

CeylonConfig (org.eclipse.ceylon.common.config.CeylonConfig)28 Test (org.junit.Test)16 File (java.io.File)12 Authentication (org.eclipse.ceylon.common.config.Authentication)7 Proxy (org.eclipse.ceylon.common.config.Proxies.Proxy)7 PasswordAuthentication (java.net.PasswordAuthentication)6 Proxies (org.eclipse.ceylon.common.config.Proxies)6 InetSocketAddress (java.net.InetSocketAddress)5 Repositories (org.eclipse.ceylon.common.config.Repositories)3 Repository (org.eclipse.ceylon.common.config.Repositories.Repository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 BuildException (org.apache.tools.ant.BuildException)2 CeylonBaseTool (org.eclipse.ceylon.common.tool.CeylonBaseTool)2 Before (org.junit.Before)2 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 HashSet (java.util.HashSet)1