Search in sources :

Example 1 with DevBundleInfo

use of org.eclipse.tycho.dev.DevBundleInfo in project tycho by eclipse.

the class TestMojo method createEclipseInstallation.

private EquinoxInstallation createEclipseInstallation() throws MojoExecutionException {
    DependencyResolver platformResolver = dependencyResolverLocator.lookupDependencyResolver(project);
    final List<Dependency> extraDependencies = getExtraDependencies();
    List<ReactorProject> reactorProjects = getReactorProjects();
    final DependencyResolverConfiguration resolverConfiguration = new DependencyResolverConfiguration() {

        @Override
        public OptionalResolutionAction getOptionalResolutionAction() {
            return OptionalResolutionAction.IGNORE;
        }

        @Override
        public List<Dependency> getExtraRequirements() {
            return extraDependencies;
        }
    };
    DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project, null, reactorProjects, resolverConfiguration);
    if (testRuntimeArtifacts == null) {
        throw new MojoExecutionException("Cannot determinate build target platform location -- not executing tests");
    }
    work.mkdirs();
    EquinoxInstallationDescription testRuntime = new DefaultEquinoxInstallationDescription();
    testRuntime.setDefaultBundleStartLevel(defaultStartLevel);
    testRuntime.addBundlesToExplode(getBundlesToExplode());
    testRuntime.addFrameworkExtensions(getFrameworkExtensions());
    if (bundleStartLevel != null) {
        for (BundleStartLevel level : bundleStartLevel) {
            testRuntime.addBundleStartLevel(level);
        }
    }
    TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
    createSurefireProperties(provider);
    for (ArtifactDescriptor artifact : testRuntimeArtifacts.getArtifacts(ArtifactType.TYPE_ECLIPSE_PLUGIN)) {
        // note that this project is added as directory structure rooted at project basedir.
        // project classes and test-classes are added via dev.properties file (see #createDevProperties())
        // all other projects are added as bundle jars.
        ReactorProject otherProject = artifact.getMavenProject();
        if (otherProject != null) {
            if (otherProject.sameProject(project)) {
                testRuntime.addBundle(artifact.getKey(), project.getBasedir());
                continue;
            }
            File file = otherProject.getArtifact(artifact.getClassifier());
            if (file != null) {
                testRuntime.addBundle(artifact.getKey(), file);
                continue;
            }
        }
        testRuntime.addBundle(artifact);
    }
    Set<Artifact> testFrameworkBundles = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
    for (Artifact artifact : testFrameworkBundles) {
        DevBundleInfo devInfo = workspaceState.getBundleInfo(session, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), project.getPluginArtifactRepositories());
        if (devInfo != null) {
            testRuntime.addBundle(devInfo.getArtifactKey(), devInfo.getLocation(), true);
            testRuntime.addDevEntries(devInfo.getSymbolicName(), devInfo.getDevEntries());
        } else {
            File bundleLocation = artifact.getFile();
            ArtifactKey bundleArtifactKey = getBundleArtifactKey(bundleLocation);
            testRuntime.addBundle(bundleArtifactKey, bundleLocation, true);
        }
    }
    testRuntime.addDevEntries(getTestBundleSymbolicName(), getBuildOutputDirectories());
    reportsDirectory.mkdirs();
    return installationFactory.createInstallation(testRuntime, work);
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) BundleStartLevel(org.eclipse.sisu.equinox.launching.BundleStartLevel) ArtifactKey(org.eclipse.tycho.ArtifactKey) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) Dependency(org.apache.maven.model.Dependency) DependencyResolverConfiguration(org.eclipse.tycho.core.DependencyResolverConfiguration) Artifact(org.apache.maven.artifact.Artifact) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) EquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription) DefaultEquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) DevBundleInfo(org.eclipse.tycho.dev.DevBundleInfo) DefaultEquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription) TestFrameworkProvider(org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider) File(java.io.File)

Example 2 with DevBundleInfo

use of org.eclipse.tycho.dev.DevBundleInfo in project tycho by eclipse.

the class WorkspaceTychoOsgiRuntimeLocator method addBundle.

public boolean addBundle(EquinoxRuntimeDescription result, Artifact pom) {
    DevBundleInfo bundleInfo = workspaceState.getBundleInfo(pom.getFile().getParentFile());
    if (bundleInfo == null) {
        return false;
    }
    addBundle(result, bundleInfo);
    return true;
}
Also used : DevBundleInfo(org.eclipse.tycho.dev.DevBundleInfo)

Example 3 with DevBundleInfo

use of org.eclipse.tycho.dev.DevBundleInfo in project tycho by eclipse.

the class WorkspaceTychoOsgiRuntimeLocator method addProduct.

public boolean addProduct(EquinoxRuntimeDescription result, Artifact pom) throws MavenExecutionException {
    ProductConfiguration product;
    try {
        product = ProductConfiguration.read(new File(pom.getFile().getParentFile(), pom.getArtifactId() + ".product"));
    } catch (IOException e) {
        return false;
    }
    // the above fails with IOException if .product file is not available or can't be read
    // we get here only when we have valid product instance
    Set<String> missing = new LinkedHashSet<>();
    for (PluginRef pluginRef : product.getPlugins()) {
        DevBundleInfo bundleInfo = workspaceState.getBundleInfo(pluginRef.getId(), pluginRef.getVersion());
        if (bundleInfo != null) {
            addBundle(result, bundleInfo);
        } else {
            missing.add(pluginRef.toString());
        }
    }
    if (!missing.isEmpty()) {
        throw new MavenExecutionException("Inconsistent m2e-tycho workspace state, missing bundles: " + missing.toString(), (Throwable) null);
    }
    Map<String, BundleConfiguration> bundleConfigurations = product.getPluginConfiguration();
    if (bundleConfigurations != null) {
        for (BundleConfiguration bundleConfiguration : bundleConfigurations.values()) {
            result.addBundleStartLevel(bundleConfiguration.getId(), bundleConfiguration.getStartLevel(), bundleConfiguration.isAutoStart());
        }
    }
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MavenExecutionException(org.apache.maven.MavenExecutionException) BundleConfiguration(org.eclipse.tycho.model.BundleConfiguration) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) DevBundleInfo(org.eclipse.tycho.dev.DevBundleInfo) PluginRef(org.eclipse.tycho.model.PluginRef) IOException(java.io.IOException) File(java.io.File)

Aggregations

DevBundleInfo (org.eclipse.tycho.dev.DevBundleInfo)3 File (java.io.File)2 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 MavenExecutionException (org.apache.maven.MavenExecutionException)1 Artifact (org.apache.maven.artifact.Artifact)1 Dependency (org.apache.maven.model.Dependency)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 BundleStartLevel (org.eclipse.sisu.equinox.launching.BundleStartLevel)1 DefaultEquinoxInstallationDescription (org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription)1 EquinoxInstallationDescription (org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription)1 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)1 ArtifactKey (org.eclipse.tycho.ArtifactKey)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)1 DependencyResolver (org.eclipse.tycho.core.DependencyResolver)1 DependencyResolverConfiguration (org.eclipse.tycho.core.DependencyResolverConfiguration)1 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)1 BundleConfiguration (org.eclipse.tycho.model.BundleConfiguration)1 PluginRef (org.eclipse.tycho.model.PluginRef)1