use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReaderTest method testExtraRequirementId.
@Test
public void testExtraRequirementId() throws Exception {
Xpp3Dom dom = createConfigurationDom("type", "versionRange");
try {
configurationReader.readExtraRequirements(new TargetPlatformConfiguration(), dom);
fail();
} catch (BuildFailureException e) {
assertTrue(e.getMessage().contains("Element <id> is missing in <extraRequirements><requirement> section."));
}
}
use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingGroupInTargetDefinition.
@Test
public void testAddTargetWithMissingGroupInTargetDefinition() {
Xpp3Dom dom = createGavConfiguration(null, "myArtifactId", "myVersion");
MavenSession session = setupMockSession();
TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
try {
configurationReader.addTargetArtifact(configuration, session, null, dom);
fail();
} catch (BuildFailureException e) {
assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
}
}
use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingArtifactIdInTargetDefinition.
@Test
public void testAddTargetWithMissingArtifactIdInTargetDefinition() {
Xpp3Dom dom = createGavConfiguration("myGroupId", null, "myVersion");
MavenSession session = setupMockSession();
TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
try {
configurationReader.addTargetArtifact(configuration, session, null, dom);
fail();
} catch (BuildFailureException e) {
assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
}
}
use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReader method addTargetArtifact.
protected void addTargetArtifact(TargetPlatformConfiguration result, MavenSession session, MavenProject project, Xpp3Dom artifactDom) {
Xpp3Dom groupIdDom = artifactDom.getChild("groupId");
Xpp3Dom artifactIdDom = artifactDom.getChild("artifactId");
Xpp3Dom versionDom = artifactDom.getChild("version");
if (groupIdDom == null || artifactIdDom == null || versionDom == null) {
throw new BuildFailureException("The target artifact configuration is invalid - <groupId>, <artifactId> and <version> are mandatory");
}
Xpp3Dom classifierDom = artifactDom.getChild("classifier");
String groupId = groupIdDom.getValue();
String artifactId = artifactIdDom.getValue();
String version = versionDom.getValue();
String classifier = classifierDom != null ? classifierDom.getValue() : null;
File targetFile = null;
for (MavenProject otherProject : session.getProjects()) {
if (groupId.equals(otherProject.getGroupId()) && artifactId.equals(otherProject.getArtifactId()) && version.equals(otherProject.getVersion())) {
String fileName;
if (classifier == null) {
// no classifier means target is provided using packaging type eclipse-target-definition
fileName = artifactId;
} else {
// backward compat for target files manually installed via build-helper-maven-plugin
fileName = classifier;
}
targetFile = new File(otherProject.getBasedir(), fileName + ".target");
break;
}
}
if (targetFile == null) {
Artifact artifact = repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, "target", classifier);
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setLocalRepository(session.getLocalRepository());
request.setRemoteRepositories(project.getRemoteArtifactRepositories());
repositorySystem.resolve(request);
if (!artifact.isResolved()) {
throw new RuntimeException("Could not resolve target platform specification artifact " + artifact);
}
targetFile = artifact.getFile();
}
result.addTarget(targetFile);
}
use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.
the class P2DependencyResolver method doResolveDependencies.
private DependencyArtifacts doResolveDependencies(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration, TargetPlatform targetPlatform, P2Resolver resolver, TargetPlatformConfiguration configuration) {
Map<File, ReactorProject> projects = new HashMap<>();
resolver.setEnvironments(configuration.getEnvironments());
resolver.setAdditionalFilterProperties(configuration.getProfileProperties());
for (ReactorProject otherProject : reactorProjects) {
projects.put(otherProject.getBasedir(), otherProject);
}
if (resolverConfiguration != null) {
for (Dependency dependency : resolverConfiguration.getExtraRequirements()) {
try {
resolver.addDependency(dependency.getType(), dependency.getArtifactId(), dependency.getVersion());
} catch (IllegalArtifactReferenceException e) {
throw new BuildFailureException("Invalid extraRequirement " + dependency.getType() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() + ": " + e.getMessage(), e);
}
}
}
// get reactor project with prepared optional dependencies // TODO use original IU and have the resolver create the modified IUs
ReactorProject optionalDependencyPreparedProject = getThisReactorProject(session, project, configuration);
if (!isAllowConflictingDependencies(project, configuration)) {
List<P2ResolutionResult> results = resolver.resolveDependencies(targetPlatform, optionalDependencyPreparedProject);
MultiEnvironmentDependencyArtifacts multiPlatform = new MultiEnvironmentDependencyArtifacts(DefaultReactorProject.adapt(project));
// FIXME this is just wrong
for (int i = 0; i < configuration.getEnvironments().size(); i++) {
TargetEnvironment environment = configuration.getEnvironments().get(i);
P2ResolutionResult result = results.get(i);
DefaultDependencyArtifacts platform = newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
multiPlatform.addPlatform(environment, platform);
}
return multiPlatform;
} else {
P2ResolutionResult result = resolver.collectProjectDependencies(targetPlatform, optionalDependencyPreparedProject);
return newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
}
}
Aggregations