Search in sources :

Example 6 with ArtifactKey

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

the class DefaultDependencyArtifactsTest method testInconsistentArtifacts.

@Test
public void testInconsistentArtifacts() {
    DefaultDependencyArtifacts tp = new DefaultDependencyArtifacts();
    ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
    File location = new File("location");
    tp.addArtifactFile(key, location, asSet("a"));
    try {
        tp.addArtifactFile(key, location, asSet("b"));
    } catch (IllegalStateException e) {
    // expected
    }
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) File(java.io.File) Test(org.junit.Test)

Example 7 with ArtifactKey

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

the class LocalDependencyResolverTest method testBundleIdParsing.

public void testBundleIdParsing() throws Exception {
    DependencyArtifacts platform = getTargetPlatform(new File("src/test/resources/targetplatforms/basic"));
    ArtifactDescriptor artifact = platform.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "bundle01", null);
    ArtifactKey key = artifact.getKey();
    assertEquals("bundle01", key.getId());
    assertEquals("0.0.1", key.getVersion());
    File file = artifact.getLocation();
    assertEquals("bundle01_0.0.1", file.getName());
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) File(java.io.File)

Example 8 with ArtifactKey

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

the class OsgiSourceMojo method addSourceBundleManifestEntries.

private void addSourceBundleManifestEntries(MavenArchiveConfiguration mavenArchiveConfiguration) {
    TychoProject projectType = projectTypes.get(project.getPackaging());
    ArtifactKey artifactKey = projectType.getArtifactKey(DefaultReactorProject.adapt(project));
    String symbolicName = artifactKey.getId();
    String version = artifactKey.getVersion();
    if (symbolicName != null && version != null) {
        mavenArchiveConfiguration.addManifestEntry(BUNDLE_MANIFESTVERSION, "2");
        mavenArchiveConfiguration.addManifestEntry(BUNDLE_SYMBOLICNAME, symbolicName + sourceBundleSuffix);
        Version expandedVersion = getExpandedVersion(version);
        mavenArchiveConfiguration.addManifestEntry(BUNDLE_VERSION, expandedVersion.toString());
        mavenArchiveConfiguration.addManifestEntry(MANIFEST_HEADER_ECLIPSE_SOURCE_BUNDLE, symbolicName + ";version=\"" + expandedVersion + "\";roots:=\"" + getEclipseHeaderSourceRoots() + "\"");
        mavenArchiveConfiguration.addManifestEntry(BUNDLE_NAME, I18N_KEY_PREFIX + I18N_KEY_BUNDLE_NAME);
        mavenArchiveConfiguration.addManifestEntry(BUNDLE_VENDOR, I18N_KEY_PREFIX + I18N_KEY_BUNDLE_VENDOR);
        mavenArchiveConfiguration.addManifestEntry(BUNDLE_LOCALIZATION, MANIFEST_BUNDLE_LOCALIZATION_BASENAME);
    } else {
        getLog().info("NOT adding source bundle manifest entries. Incomplete or no bundle information available.");
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) TychoProject(org.eclipse.tycho.core.TychoProject) Version(org.osgi.framework.Version)

Example 9 with ArtifactKey

use of org.eclipse.tycho.ArtifactKey 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 10 with ArtifactKey

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

the class AbstractJUnitProvider method isEnabled.

@Override
public boolean isEnabled(List<ClasspathEntry> testBundleClassPath, Properties surefireProperties) {
    Set<String> junitBundleNames = getJUnitBundleNames();
    VersionRange range = getJUnitVersionRange();
    for (ClasspathEntry classpathEntry : testBundleClassPath) {
        ArtifactKey artifactKey = classpathEntry.getArtifactKey();
        if (junitBundleNames.contains(artifactKey.getId())) {
            Version version = Version.parseVersion(artifactKey.getVersion());
            if (range.includes(version)) {
                return true;
            }
        }
    }
    return false;
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) Version(org.osgi.framework.Version) VersionRange(org.osgi.framework.VersionRange) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry)

Aggregations

ArtifactKey (org.eclipse.tycho.ArtifactKey)41 File (java.io.File)19 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)15 Test (org.junit.Test)14 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)13 ReactorProject (org.eclipse.tycho.ReactorProject)8 DefaultArtifactDescriptor (org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor)6 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)6 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)5 LinkedHashMap (java.util.LinkedHashMap)3 MavenProject (org.apache.maven.project.MavenProject)3 BundleStartLevel (org.eclipse.sisu.equinox.launching.BundleStartLevel)3 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)3 FeatureRef (org.eclipse.tycho.model.FeatureRef)3 PluginRef (org.eclipse.tycho.model.PluginRef)3 Version (org.osgi.framework.Version)3 Element (de.pdark.decentxml.Element)2 Map (java.util.Map)2 Artifact (org.apache.maven.artifact.Artifact)2 Dependency (org.apache.maven.model.Dependency)2