Search in sources :

Example 21 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class OsgiBundleProject method resolveClassPath.

@Override
public void resolveClassPath(MavenSession session, MavenProject project) {
    DependencyArtifacts artifacts = getDependencyArtifacts(project);
    State state = getResolverState(project, artifacts);
    if (getLogger().isDebugEnabled() && DebugUtils.isDebugEnabled(session, project)) {
        getLogger().debug(resolver.toDebugString(state));
    }
    BundleDescription bundleDescription = state.getBundleByLocation(project.getBasedir().getAbsolutePath());
    List<ClasspathEntry> classpath = new ArrayList<>();
    // project itself
    ArtifactDescriptor artifact = getArtifact(artifacts, project.getBasedir(), bundleDescription.getSymbolicName());
    ReactorProject projectProxy = DefaultReactorProject.adapt(project);
    List<File> projectClasspath = getThisProjectClasspath(artifact, projectProxy);
    classpath.add(new DefaultClasspathEntry(projectProxy, artifact.getKey(), projectClasspath, null));
    // build.properties/jars.extra.classpath
    addExtraClasspathEntries(classpath, projectProxy, artifacts);
    // dependencies
    List<AccessRule> strictBootClasspathAccessRules = new ArrayList<>();
    strictBootClasspathAccessRules.add(new DefaultAccessRule("java/**", false));
    for (DependencyEntry entry : dependencyComputer.computeDependencies(state.getStateHelper(), bundleDescription)) {
        if (EquinoxResolver.SYSTEM_BUNDLE_ID == entry.desc.getBundleId()) {
            if (entry.rules != null) {
                strictBootClasspathAccessRules.addAll(entry.rules);
            }
            if (EquinoxResolver.SYSTEM_BUNDLE_SYMBOLIC_NAME.equals(entry.desc.getSymbolicName())) {
                // synthetic system.bundle has no filesystem location
                continue;
            }
        }
        File location = new File(entry.desc.getLocation());
        ArtifactDescriptor otherArtifact = getArtifact(artifacts, location, entry.desc.getSymbolicName());
        ReactorProject otherProject = otherArtifact.getMavenProject();
        List<File> locations;
        if (otherProject != null) {
            locations = getOtherProjectClasspath(otherArtifact, otherProject, null);
        } else {
            locations = getBundleClasspath(otherArtifact);
        }
        if (locations.isEmpty() && !entry.rules.isEmpty()) {
            getLogger().warn("Empty classpath of required bundle " + otherArtifact);
        }
        classpath.add(new DefaultClasspathEntry(otherProject, otherArtifact.getKey(), locations, entry.rules));
    }
    project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_CLASSPATH, classpath);
    project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_STRICT_BOOTCLASSPATH_ACCESSRULES, strictBootClasspathAccessRules);
    project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_BOOTCLASSPATH_EXTRA_ACCESSRULES, dependencyComputer.computeBootClasspathExtraAccessRules(state.getStateHelper(), bundleDescription));
    addPDESourceRoots(project);
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ArrayList(java.util.ArrayList) ReactorProject(org.eclipse.tycho.ReactorProject) DependencyEntry(org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry) DefaultAccessRule(org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) State(org.eclipse.osgi.service.resolver.State) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry) File(java.io.File) DefaultAccessRule(org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule) AccessRule(org.eclipse.tycho.classpath.ClasspathEntry.AccessRule)

Example 22 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class ArtifactCollection method toDebugString.

public void toDebugString(StringBuilder sb, String linePrefix) {
    for (ArtifactDescriptor artifact : artifacts.values()) {
        sb.append(linePrefix);
        sb.append(artifact.getKey().toString());
        sb.append(": ");
        ReactorProject project = artifact.getMavenProject();
        if (project != null) {
            sb.append(project.toString());
        } else {
            sb.append(artifact.getLocation());
        }
        sb.append("\n");
    }
}
Also used : DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject)

Example 23 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class LocalDependencyResolver method addProjects.

private void addProjects(MavenSession session, DefaultDependencyArtifacts platform) {
    File parentDir = null;
    for (MavenProject project : session.getProjects()) {
        ReactorProject projectProxy = DefaultReactorProject.adapt(project);
        TychoProject dr = projectTypes.get(project.getPackaging());
        if (dr != null) {
            ArtifactKey key = dr.getArtifactKey(projectProxy);
            platform.removeAll(key.getType(), key.getId());
            platform.addReactorArtifact(key, projectProxy, null, null);
            if (parentDir == null || isSubdir(project.getBasedir(), parentDir)) {
                parentDir = project.getBasedir();
            }
        }
    }
}
Also used : DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) MavenProject(org.apache.maven.project.MavenProject) AbstractTychoProject(org.eclipse.tycho.core.osgitools.AbstractTychoProject) TychoProject(org.eclipse.tycho.core.TychoProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject) File(java.io.File)

Example 24 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class TychoMavenLifecycleParticipant method afterProjectsRead.

@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
    try {
        if (disableLifecycleParticipation(session)) {
            return;
        }
        List<MavenProject> projects = session.getProjects();
        validate(projects);
        // setting this system property to let EF figure out where the traffic
        // is coming from (#467418)
        System.setProperty(P2_USER_AGENT_KEY, P2_USER_AGENT_VALUE + TychoVersion.getTychoVersion());
        configureComponents(session);
        for (MavenProject project : projects) {
            resolver.setupProject(session, project, DefaultReactorProject.adapt(project));
        }
        List<ReactorProject> reactorProjects = DefaultReactorProject.adapt(session);
        for (MavenProject project : projects) {
            resolver.resolveProject(session, project, reactorProjects);
        }
    } catch (BuildFailureException e) {
        // trace by wrapping it in MavenExecutionException
        throw new MavenExecutionException(e.getMessage(), e);
    }
}
Also used : MavenExecutionException(org.apache.maven.MavenExecutionException) MavenProject(org.apache.maven.project.MavenProject) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject)

Example 25 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class DefaultReactorProject method adapt.

public static ReactorProject adapt(MavenProject project) {
    if (project == null) {
        return null;
    }
    ReactorProject reactorProject = (ReactorProject) project.getContextValue(CTX_REACTOR_PROJECT);
    if (reactorProject == null) {
        reactorProject = new DefaultReactorProject(project);
        project.setContextValue(CTX_REACTOR_PROJECT, reactorProject);
    }
    return reactorProject;
}
Also used : ReactorProject(org.eclipse.tycho.ReactorProject)

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