本文整理汇总了Java中org.srcdeps.core.config.BuilderIo类的典型用法代码示例。如果您正苦于以下问题:Java BuilderIo类的具体用法?Java BuilderIo怎么用?Java BuilderIo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuilderIo类属于org.srcdeps.core.config包,在下文中一共展示了BuilderIo类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SrcdepsConstructor
import org.srcdeps.core.config.BuilderIo; //导入依赖的package包/类
public SrcdepsConstructor() {
super();
this.yamlClassConstructors.put(NodeId.scalar, new PathConstruct());
this.setPropertyUtils(new BuilderPropertyUtils(Configuration.Builder.class, BuilderIo.Builder.class,
Maven.Builder.class, MavenAssertions.FailWithoutBuilder.class, MavenAssertions.FailWithBuilder.class,
ScmRepository.Builder.class, ScmRepositoryMaven.Builder.class, ScmRepositoryGradle.Builder.class));
}
示例2: buildIfNecessary
import org.srcdeps.core.config.BuilderIo; //导入依赖的package包/类
/**
* Builds the artifact given by the arguments if necessary and installs it to the Local Maven Repository.
*
* @param groupId
* @param artifactId
* @param version
*/
public void buildIfNecessary(String groupId, String artifactId, String version) {
final Configuration configuration = configurationService.getConfiguration();
if (configuration.isSkip()) {
log.info("srcdeps: Skipped");
}
Gavtc artifactGavtc = new Gavtc(groupId, artifactId, version, "jar"); // FIXME: "jar" should not be hard
// coded but Gradle does not seem to have
// a notion of type an classifier (does
// it?)
Path artfactPath = localRepository.resolve(artifactGavtc);
if (!Files.exists(artfactPath)) {
ScmRepository scmRepo = findScmRepo(configuration.getRepositories(), groupId, artifactId, version);
SrcVersion srcVersion = SrcVersion.parse(version);
try (PathLock projectBuildDir = buildDirectoriesManager.openBuildDirectory(scmRepo.getIdAsPath(),
srcVersion)) {
/* query the delegate again, because things may have changed since we requested the lock */
if (Files.exists(artfactPath)) {
log.debug("srcdeps: Found in the local repo and using it as is: {}", artfactPath);
return;
} else {
/* no change in the local repo, let's build */
BuilderIo builderIo = scmRepo.getBuilderIo();
IoRedirects ioRedirects = IoRedirects.builder() //
.stdin(IoRedirects.parseUri(builderIo.getStdin())) //
.stdout(IoRedirects.parseUri(builderIo.getStdout())) //
.stderr(IoRedirects.parseUri(builderIo.getStderr())) //
.build();
List<String> buildArgs = enhanceBuildArguments(scmRepo.getBuildArguments(),
configurationService.getConfigurationLocation(),
localRepository.getRootDirectory().toString());
BuildRequest buildRequest = BuildRequest.builder() //
.dependentProjectRootDirectory(configurationService.getMultimoduleProjectRootDirectory())
.projectRootDirectory(projectBuildDir.getPath()) //
.scmUrls(scmRepo.getUrls()) //
.srcVersion(srcVersion) //
.buildArguments(buildArgs) //
.timeoutMs(scmRepo.getBuildTimeout().toMilliseconds()) //
.skipTests(scmRepo.isSkipTests()) //
.forwardProperties(configuration.getForwardProperties()) //
.addDefaultBuildArguments(scmRepo.isAddDefaultBuildArguments()) //
.verbosity(scmRepo.getVerbosity()) //
.ioRedirects(ioRedirects) //
.versionsMavenPluginVersion(scmRepo.getMaven().getVersionsMavenPluginVersion())
.gradleModelTransformer(scmRepo.getGradle().getModelTransformer()).build();
buildService.build(buildRequest);
/* check once again if the delegate sees the newly built artifact */
if (!Files.exists(artfactPath)) {
log.error(
"srcdeps: Build succeeded but the artifact {}:{}:{} is still not available in the local repository",
groupId, artifactId, version);
}
}
} catch (BuildException | IOException e) {
log.error("srcdeps: Could not build {}:{}:{}" + groupId, artifactId, version, e);
}
}
}
示例3: readFull
import org.srcdeps.core.config.BuilderIo; //导入依赖的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);
}
}
示例4: readFull21Selectors
import org.srcdeps.core.config.BuilderIo; //导入依赖的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);
}
}
示例5: find
import org.srcdeps.core.config.BuilderIo; //导入依赖的package包/类
/**
* In case the {@link #delegate} does not find the given artifact and the given artifact's version string is a
* srcdeps version string, then the version is built from source and returned.
*
* @see org.eclipse.aether.repository.LocalRepositoryManager#find(org.eclipse.aether.RepositorySystemSession,
* org.eclipse.aether.repository.LocalArtifactRequest)
*/
@Override
public LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request) {
log.debug("Srcdeps looking up locally {}", request.getArtifact());
final LocalArtifactResult result = delegate.find(session, request);
Artifact artifact = request.getArtifact();
String version = artifact.getVersion();
if (!result.isAvailable() && SrcVersion.isSrcVersion(version)) {
final Configuration configuration = configurationProducer.getConfiguration();
if (!configuration.isSkip()) {
final ScmRepository scmRepo = findScmRepo(configuration.getRepositories(), artifact.getGroupId(), artifact.getArtifactId(),
version);
SrcVersion srcVersion = SrcVersion.parse(version);
try (PathLock projectBuildDir = buildDirectoriesManager.openBuildDirectory(scmRepo.getIdAsPath(),
srcVersion)) {
/* query the delegate again, because things may have changed since we requested the lock */
final LocalArtifactResult result2 = delegate.find(session, request);
if (result2.isAvailable()) {
return result2;
} else {
/* no change in the local repo, let's build */
BuilderIo builderIo = scmRepo.getBuilderIo();
IoRedirects ioRedirects = IoRedirects.builder() //
.stdin(IoRedirects.parseUri(builderIo.getStdin())) //
.stdout(IoRedirects.parseUri(builderIo.getStdout())) //
.stderr(IoRedirects.parseUri(builderIo.getStderr())) //
.build();
List<String> buildArgs = enhanceBuildArguments(scmRepo.getBuildArguments(),
configurationProducer.getConfigurationLocation(),
delegate.getRepository().getBasedir().getAbsolutePath());
BuildRequest buildRequest = BuildRequest.builder() //
.dependentProjectRootDirectory(configurationProducer.getMultimoduleProjectRootDirectory()) //
.projectRootDirectory(projectBuildDir.getPath()) //
.scmUrls(scmRepo.getUrls()) //
.srcVersion(srcVersion) //
.buildArguments(buildArgs) //
.timeoutMs(scmRepo.getBuildTimeout().toMilliseconds()) //
.skipTests(scmRepo.isSkipTests()) //
.forwardProperties(configuration.getForwardProperties()) //
.addDefaultBuildArguments(scmRepo.isAddDefaultBuildArguments()) //
.verbosity(scmRepo.getVerbosity()) //
.ioRedirects(ioRedirects) //
.versionsMavenPluginVersion(scmRepo.getMaven().getVersionsMavenPluginVersion())
.gradleModelTransformer(scmRepo.getGradle().getModelTransformer()).build();
buildService.build(buildRequest);
/* check once again if the delegate sees the newly built artifact */
final LocalArtifactResult newResult = delegate.find(session, request);
if (!newResult.isAvailable()) {
log.error(
"Srcdeps build succeeded but the artifact {} is still not available in the local repository",
artifact);
}
return newResult;
}
} catch (BuildException | IOException e) {
log.error("Srcdeps could not build " + request, e);
}
}
}
return result;
}