本文整理汇总了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);
}
}
示例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);
}
}
示例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();
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}