use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class AbstractArtifactDependencyWalker method traversePlugin.
private void traversePlugin(PluginRef ref, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
if (!matchTargetEnvironment(ref)) {
return;
}
ArtifactDescriptor artifact = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, ref.getId(), ref.getVersion());
if (artifact != null) {
ArtifactKey key = artifact.getKey();
if (visited.visited(key)) {
return;
}
File location = artifact.getLocation();
ReactorProject project = artifact.getMavenProject();
String classifier = artifact.getClassifier();
Set<Object> installableUnits = artifact.getInstallableUnits();
PluginDescription description = new DefaultPluginDescription(key, location, project, classifier, ref, installableUnits);
visited.enter(description);
try {
visitor.visitPlugin(description);
} finally {
visited.leave(description);
}
} else {
visitor.missingPlugin(ref, visited.getWalkback());
}
}
use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class OsgiBundleProject method getDependencyWalker.
@Override
public ArtifactDependencyWalker getDependencyWalker(MavenProject project) {
final DependencyArtifacts artifacts = getDependencyArtifacts(project);
final List<ClasspathEntry> cp = getClasspath(project);
return new ArtifactDependencyWalker() {
@Override
public void walk(ArtifactDependencyVisitor visitor) {
for (ClasspathEntry entry : cp) {
ArtifactDescriptor artifact = artifacts.getArtifact(entry.getArtifactKey());
ArtifactKey key = artifact.getKey();
File location = artifact.getLocation();
ReactorProject project = artifact.getMavenProject();
String classifier = artifact.getClassifier();
Set<Object> installableUnits = artifact.getInstallableUnits();
PluginDescription plugin = new DefaultPluginDescription(key, location, project, classifier, null, installableUnits);
visitor.visitPlugin(plugin);
}
}
@Override
public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) {
}
@Override
public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor artifactDependencyVisitor) {
}
@Override
public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) {
}
};
}
use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class MavenDependencyInjector method newProjectDependencies.
private List<Dependency> newProjectDependencies(ArtifactDescriptor artifact) {
ReactorProject dependentMavenProjectProxy = artifact.getMavenProject();
List<Dependency> result = new ArrayList<>();
if (!artifact.getMavenProject().sameProject(project)) {
result.add(createProvidedScopeDependency(dependentMavenProjectProxy));
}
// TODO treat eclipse-test-plugins in the same way?
if (PackagingType.TYPE_ECLIPSE_PLUGIN.equals(dependentMavenProjectProxy.getPackaging())) {
for (String classpathElement : getClasspathElements(dependentMavenProjectProxy.getBasedir())) {
if (".".equals(classpathElement)) {
// covered by provided-scope dependency above
continue;
} else /* nested classpath entry */
{
File jar = new File(dependentMavenProjectProxy.getBasedir(), classpathElement);
// otherwise maven will throw a DependencyResolutionException
if (jar.isFile()) {
Dependency systemScopeDependency = createSystemScopeDependency(artifact.getKey(), artifact.getMavenProject().getGroupId(), jar);
systemScopeDependency.setClassifier(classpathElement);
result.add(systemScopeDependency);
} else {
logger.debug("Dependency from " + project.getBasedir() + " to nested classpath entry " + jar.getAbsolutePath() + " can not be represented in Maven model and will not be visible to non-OSGi aware Maven plugins");
}
}
}
}
return result;
}
use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class PackagePluginMojo method updateManifest.
private File updateManifest() throws IOException, MojoExecutionException {
File mfile = new File(project.getBasedir(), "META-INF/MANIFEST.MF");
InputStream is = new FileInputStream(mfile);
Manifest mf;
try {
mf = new Manifest(is);
} finally {
is.close();
}
Attributes attributes = mf.getMainAttributes();
if (attributes.getValue(Name.MANIFEST_VERSION) == null) {
attributes.put(Name.MANIFEST_VERSION, "1.0");
}
ReactorProject reactorProject = DefaultReactorProject.adapt(project);
attributes.putValue("Bundle-Version", reactorProject.getExpandedVersion());
soureReferenceComputer.addSourceReferenceHeader(mf, sourceReferences, project);
mfile = new File(project.getBuild().getDirectory(), "MANIFEST.MF");
mfile.getParentFile().mkdirs();
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(mfile));
try {
mf.write(os);
} finally {
os.close();
}
return mfile;
}
use of org.eclipse.tycho.ReactorProject 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