Search in sources :

Example 11 with ReactorProject

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());
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription)

Example 12 with ReactorProject

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) {
        }
    };
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactKey(org.eclipse.tycho.ArtifactKey) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) ReactorProject(org.eclipse.tycho.ReactorProject) ArtifactDependencyWalker(org.eclipse.tycho.core.ArtifactDependencyWalker) Feature(org.eclipse.tycho.model.Feature) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription) UpdateSite(org.eclipse.tycho.model.UpdateSite)

Example 13 with ReactorProject

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;
}
Also used : ReactorProject(org.eclipse.tycho.ReactorProject) ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency) File(java.io.File)

Example 14 with ReactorProject

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;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) Attributes(java.util.jar.Attributes) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject) Manifest(java.util.jar.Manifest) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) FileInputStream(java.io.FileInputStream)

Example 15 with ReactorProject

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);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IllegalArtifactReferenceException(org.eclipse.tycho.artifacts.IllegalArtifactReferenceException) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ComponentDependency(org.codehaus.plexus.component.repository.ComponentDependency) Dependency(org.apache.maven.model.Dependency) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) MultiEnvironmentDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts) DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) File(java.io.File)

Aggregations

ReactorProject (org.eclipse.tycho.ReactorProject)32 File (java.io.File)20 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)16 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)10 ArtifactKey (org.eclipse.tycho.ArtifactKey)8 MavenProject (org.apache.maven.project.MavenProject)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 LinkedHashSet (java.util.LinkedHashSet)4 Artifact (org.apache.maven.artifact.Artifact)4 Dependency (org.apache.maven.model.Dependency)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)4 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)4 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3