当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationException类代码示例

本文整理汇总了Java中org.srcdeps.core.config.ConfigurationException的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationException类的具体用法?Java ConfigurationException怎么用?Java ConfigurationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfigurationException类属于org.srcdeps.core.config包,在下文中一共展示了ConfigurationException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeFull

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Test
public void writeFull() throws ConfigurationException, UnsupportedEncodingException, IOException {
    final StringWriter out = new StringWriter();
    final Configuration configFromFile;
    try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-full.yaml"), "utf-8");
            YamlWriterVisitor writerVisitor = new YamlWriterVisitor(out,
                    YamlWriterConfiguration.builder().build());) {
        configFromFile = new YamlConfigurationIo() //
                .read(in) //
                .accept(writerVisitor) //
                .build();
    }

    /*
     * now read the serialized output we have written to the out StringWriter back into a new Configuration instance
     */
    try (Reader in = new StringReader(out.toString())) {
        Configuration configFromOut = new YamlConfigurationIo() //
                .read(in) //
                .build();

        Assert.assertEquals(configFromFile, configFromOut);
    }

}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:26,代码来源:YamlWriterVisitorTest.java

示例2: readMinimal

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Test
public void readMinimal() throws ConfigurationException, UnsupportedEncodingException, IOException {
    try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-minimal.yaml"), "utf-8")) {
        Configuration actual = new YamlConfigurationIo() //
                .read(in) //
                .accept(new DefaultsAndInheritanceVisitor()) //
                .build();
        Configuration expected = Configuration.builder() //
                .sourcesDirectory(Paths.get("/home/me/.m2/srcdeps")) //
                .repository( //
                        ScmRepository.builder() //
                                .id("srcdepsTestArtifact") //
                                .include("org.l2x6.maven.srcdeps.itest") //
                                .url("git:https://github.com/srcdeps/srcdeps-test-artifact.git") //
                ) //
                .accept(new DefaultsAndInheritanceVisitor()) //
                .build();
        Assert.assertEquals(expected, actual);
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:21,代码来源:YamlConfigurationIoTest.java

示例3: ConfigurationService

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Inject
public ConfigurationService(@Named(SRCDEPS_YAML_PATH) Path srcdepsYamlPath) {
    super();
    this.configurationLocation = srcdepsYamlPath;
    this.multimoduleProjectRootDirectory = srcdepsYamlPath.getParent();

    final Configuration.Builder configBuilder;
    if (Files.exists(srcdepsYamlPath)) {
        log.debug("srcdeps: Using configuration {}", srcdepsYamlPath);
        final String encoding = System.getProperty(Configuration.getSrcdepsEncodingProperty(), "utf-8");
        final Charset cs = Charset.forName(encoding);
        try (Reader r = Files.newBufferedReader(srcdepsYamlPath, cs)) {
            configBuilder = new YamlConfigurationIo().read(r);
        } catch (IOException | ConfigurationException e) {
            throw new RuntimeException(e);
        }
    } else {
        log.warn("srcdeps: Could not locate srcdeps configuration at {}, defaulting to an empty configuration",
                srcdepsYamlPath);
        configBuilder = Configuration.builder();
    }

    this.configuration = configBuilder //
            .accept(new OverrideVisitor(System.getProperties())) //
            .accept(new DefaultsAndInheritanceVisitor()) //
            .build();
}
 
开发者ID:srcdeps,项目名称:srcdeps-gradle-plugin,代码行数:28,代码来源:ConfigurationService.java

示例4: read

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public Configuration.Builder read(Reader in) throws ConfigurationException {
    Yaml yaml = new Yaml(new SrcdepsConstructor());
    Configuration.Builder builder = yaml.loadAs(in, Configuration.Builder.class);
    return builder;

}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:8,代码来源:YamlConfigurationIo.java

示例5: writeComments

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Test
public void writeComments() throws ConfigurationException, UnsupportedEncodingException, IOException {
    Configuration.Builder config = Configuration.builder();
    final StringWriter out = new StringWriter();
    try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-full.yaml"), "utf-8");
            YamlWriterVisitor writerVisitor = new YamlWriterVisitor(out,
                    YamlWriterConfiguration.builder().build());) {
        config//
                .commentBefore("") //
                .commentBefore("srcdeps comment line 1") //
                .commentBefore("srcdeps comment line 2") //
                .repository( //
                        ScmRepository.builder() //
                                .commentBefore("repo1 comment line 1") //
                                .commentBefore("repo1 comment line 2") //
                                .id("repo1") //
                                .include("org.repo1") //
                                .url("git:url1")) //
                .accept(new DefaultsAndInheritanceVisitor()).accept(writerVisitor) //
                .build();
    }

    String expectedConfig = "#\n" //
                    + "# srcdeps comment line 1\n" //
                    + "# srcdeps comment line 2\n" //
                    + "configModelVersion: 2.2\n" //
                    + "repositories:\n" //
                    + "\n" //
                    + "  # repo1 comment line 1\n" //
                    + "  # repo1 comment line 2\n" //
                    + "  repo1:\n" //
                    + "    includes:\n" //
                    + "    - org.repo1\n" //
                    + "    urls:\n" //
                    + "    - git:url1\n";

    Assert.assertEquals(expectedConfig, out.toString());

}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:40,代码来源:YamlWriterVisitorTest.java

示例6: readBadVersion

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Test(expected = ConstructorException.class)
public void readBadVersion() throws ConfigurationException, UnsupportedEncodingException, IOException {
    try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-bad-version.yaml"), "utf-8")) {
        new YamlConfigurationIo().read(in);
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:7,代码来源:YamlConfigurationIoTest.java

示例7: readFull

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Test
public void readFull() throws ConfigurationException, UnsupportedEncodingException, IOException {
    try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-full.yaml"), "utf-8")) {
        Configuration actual = new YamlConfigurationIo().read(in).build();
        Configuration expected = Configuration.builder() //
                .configModelVersion("2.2") //
                .forwardProperty("myProp1") //
                .forwardProperty("myProp2") //
                .builderIo(BuilderIo.builder().stdin("read:/path/to/input/file")
                        .stdout("write:/path/to/output/file").stderr("err2out"))
                .skip(true) //
                .sourcesDirectory(Paths.get("/home/me/.m2/srcdeps")) //
                .verbosity(Verbosity.debug) //
                .buildTimeout(new Duration(35, TimeUnit.MINUTES)) //
                .maven( //
                        Maven.builder() //
                                .versionsMavenPluginVersion("1.2") //
                                .failWith( //
                                        MavenAssertions.failWithBuilder() //
                                                .addDefaults(false) //
                                                .goal("goal1") //
                                                .goal("goal2") //
                                                .profile("profile1") //
                                                .profile("profile2") //
                                                .property("property1") //
                                                .property("property2") //
                        ) //
                                .failWithout( //
                                        MavenAssertions.failWithoutBuilder() //
                                                .goal("goalA") //
                                                .goal("goalB") //
                                                .profile("profileA") //
                                                .profile("profileB") //
                                                .property("propertyA") //
                                                .property("propertyB") //
                        ) //
                ) //
                .repository( //
                        ScmRepository.builder() //
                                .id("org.repo1") //
                                .verbosity(Verbosity.trace) //
                                .include("group1") //
                                .include("group2:artifact2:*") //
                                .exclude("group3") //
                                .exclude("group4:artifact4") //
                                .url("url1") //
                                .url("url2") //
                                .buildArgument("-arg1") //
                                .buildArgument("-arg2") //
                                .addDefaultBuildArguments(false) //
                                .skipTests(false) //
                                .buildTimeout(new Duration(64, TimeUnit.SECONDS)) //
                                .maven( //
                                        ScmRepositoryMaven.builder() //
                                                .versionsMavenPluginVersion("2.2") //
                        ) //
                                .gradle( //
                                        ScmRepositoryGradle.builder() //
                                                .modelTransformer(CharStreamSource.of("file:my/file")) //
                        ) //
                ) //
                .repository( //
                        ScmRepository.builder() //
                                .id("org.repo2") //
                                .include("group3:artifact3") //
                                .include("group4:artifact4:1.2.3") //
                                .url("url3") //
                                .url("url4") //
                                .buildArgument("arg3") //
                                .addDefaultBuildArguments(false) //
                                .skipTests(false)) //
                .build();
        Assert.assertEquals(expected, actual);
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:76,代码来源:YamlConfigurationIoTest.java

示例8: readFull21Selectors

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
@Test
public void readFull21Selectors() throws ConfigurationException, UnsupportedEncodingException, IOException {
    try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-full-2.1-selectors.yaml"), "utf-8")) {
        Configuration actual = new YamlConfigurationIo().read(in).build();
        Configuration expected = Configuration.builder() //
                .configModelVersion("2.1") //
                .forwardProperty("myProp1") //
                .forwardProperty("myProp2") //
                .builderIo(BuilderIo.builder().stdin("read:/path/to/input/file")
                        .stdout("write:/path/to/output/file").stderr("err2out"))
                .skip(true) //
                .sourcesDirectory(Paths.get("/home/me/.m2/srcdeps")) //
                .verbosity(Verbosity.debug) //
                .buildTimeout(new Duration(35, TimeUnit.MINUTES)) //
                .maven( //
                        Maven.builder() //
                                .versionsMavenPluginVersion("1.2") //
                                .failWith( //
                                        MavenAssertions.failWithBuilder() //
                                                .addDefaults(false) //
                                                .goal("goal1") //
                                                .goal("goal2") //
                                                .profile("profile1") //
                                                .profile("profile2") //
                                                .property("property1") //
                                                .property("property2") //
                        ) //
                                .failWithout( //
                                        MavenAssertions.failWithoutBuilder() //
                                                .goal("goalA") //
                                                .goal("goalB") //
                                                .profile("profileA") //
                                                .profile("profileB") //
                                                .property("propertyA") //
                                                .property("propertyB") //
                        ) //
                ) //
                .repository( //
                        ScmRepository.builder() //
                                .id("org.repo1") //
                                .verbosity(Verbosity.trace) //
                                .include("group1") //
                                .include("group2:artifact2:*") //
                                .url("url1") //
                                .url("url2") //
                                .buildArgument("-arg1") //
                                .buildArgument("-arg2") //
                                .addDefaultBuildArguments(false) //
                                .skipTests(false) //
                                .buildTimeout(new Duration(64, TimeUnit.SECONDS)) //
                                .maven( //
                                        ScmRepositoryMaven.builder() //
                                                .versionsMavenPluginVersion("2.2") //
                        ) //
                ) //
                .repository( //
                        ScmRepository.builder() //
                                .id("org.repo2") //
                                .include("group3:artifact3") //
                                .include("group4:artifact4:1.2.3") //
                                .url("url3") //
                                .url("url4") //
                                .buildArgument("arg3") //
                                .addDefaultBuildArguments(false) //
                                .skipTests(false)) //
                .build();
        Assert.assertEquals(expected, actual);
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:70,代码来源:YamlConfigurationIoTest.java

示例9: ConfigurationProducer

import org.srcdeps.core.config.ConfigurationException; //导入依赖的package包/类
public ConfigurationProducer() {
    super();

    String basePathString = System.getProperty(Constants.MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY);
    if (basePathString == null || basePathString.isEmpty()) {
        throw new RuntimeException(String.format("The system property %s must not be null or empty",
                Constants.MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY));
    }
    multimoduleProjectRootDirectory = Paths.get(basePathString).toAbsolutePath();
    final Path defaultSrcdepsYamlPath = multimoduleProjectRootDirectory.resolve(SRCDEPS_YAML_PATH);
    final Path legacySrcdepsYamlPath = multimoduleProjectRootDirectory.resolve(MVN_SRCDEPS_YAML_PATH);
    Path srcdepsYamlPath = defaultSrcdepsYamlPath;
    if (!Files.exists(srcdepsYamlPath)) {
        srcdepsYamlPath = legacySrcdepsYamlPath;
    }

    this.configurationLocation = srcdepsYamlPath;

    final Configuration.Builder configBuilder;
    if (Files.exists(srcdepsYamlPath)) {
        log.debug("SrcdepsLocalRepositoryManager using configuration {}", configurationLocation);
        final String encoding = System.getProperty(Configuration.getSrcdepsEncodingProperty(), "utf-8");
        final Charset cs = Charset.forName(encoding);
        try (Reader r = Files.newBufferedReader(configurationLocation, cs)) {
            configBuilder = new YamlConfigurationIo().read(r);
        } catch (IOException | ConfigurationException e) {
            throw new RuntimeException(e);
        }
    } else {
        log.warn(
                "Could not locate srcdeps configuration at neither {} nor {}, defaulting to an empty configuration",
                defaultSrcdepsYamlPath, legacySrcdepsYamlPath);
        configBuilder = Configuration.builder();
    }

    this.configuration = configBuilder //
            .accept(new OverrideVisitor(System.getProperties())) //
            .accept(new DefaultsAndInheritanceVisitor()) //
            .build();

}
 
开发者ID:srcdeps,项目名称:srcdeps-maven,代码行数:42,代码来源:ConfigurationProducer.java


注:本文中的org.srcdeps.core.config.ConfigurationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。