Search in sources :

Example 1 with EclipsePluginProject

use of org.eclipse.tycho.core.osgitools.project.EclipsePluginProject in project tycho by eclipse.

the class OsgiBundleProject method getThisProjectClasspath.

/**
 * Returns project compile classpath entries.
 */
private List<File> getThisProjectClasspath(ArtifactDescriptor bundle, ReactorProject project) {
    LinkedHashSet<File> classpath = new LinkedHashSet<>();
    EclipsePluginProject pdeProject = getEclipsePluginProject(project);
    Map<String, BuildOutputJar> outputJars = pdeProject.getOutputJarMap();
    // unconditionally add all output jars (even if does not exist or not on Bundle-ClassPath)
    for (BuildOutputJar jar : outputJars.values()) {
        classpath.add(jar.getOutputDirectory());
    }
    // => assume it's checked into SCM or will be copied here later during build
    for (String cp : parseBundleClasspath(bundle)) {
        if (!outputJars.containsKey(cp)) {
            classpath.add(new File(project.getBasedir(), cp));
        }
    }
    return new ArrayList<>(classpath);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EclipsePluginProject(org.eclipse.tycho.core.osgitools.project.EclipsePluginProject) BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar) ArrayList(java.util.ArrayList) File(java.io.File)

Example 2 with EclipsePluginProject

use of org.eclipse.tycho.core.osgitools.project.EclipsePluginProject in project tycho by eclipse.

the class OsgiBundleProject method getOtherProjectClasspath.

/**
 * Returns bundle classpath entries. If <code>nestedPath</code> is not <code>null</code>,
 * returns single class folder that corresponds specified nestedPath. If <code>nestedPath</code>
 * is <code>null</code>, returns entries specified in Bundle-ClassPath.
 */
private List<File> getOtherProjectClasspath(ArtifactDescriptor bundle, ReactorProject otherProject, String nestedPath) {
    LinkedHashSet<File> classpath = new LinkedHashSet<>();
    EclipsePluginProject pdeProject = getEclipsePluginProject(otherProject);
    Map<String, BuildOutputJar> outputJars = pdeProject.getOutputJarMap();
    String[] bundleClassPath;
    if (nestedPath == null) {
        bundleClassPath = parseBundleClasspath(bundle);
    } else {
        bundleClassPath = new String[] { nestedPath };
    }
    for (String cp : bundleClassPath) {
        if (outputJars.containsKey(cp)) {
            // add output folder even if it does not exist (yet)
            classpath.add(outputJars.get(cp).getOutputDirectory());
        } else {
            // no associated output folder
            // => assume it's checked into SCM or will be copied here later during build
            classpath.add(new File(otherProject.getBasedir(), cp));
        }
    }
    return new ArrayList<>(classpath);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EclipsePluginProject(org.eclipse.tycho.core.osgitools.project.EclipsePluginProject) BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar) ArrayList(java.util.ArrayList) File(java.io.File)

Example 3 with EclipsePluginProject

use of org.eclipse.tycho.core.osgitools.project.EclipsePluginProject in project tycho by eclipse.

the class OsgiBundleProject method addExtraClasspathEntries.

private void addExtraClasspathEntries(List<ClasspathEntry> classpath, ReactorProject project, DependencyArtifacts artifacts) {
    EclipsePluginProject pdeProject = getEclipsePluginProject(project);
    Collection<BuildOutputJar> outputJars = pdeProject.getOutputJarMap().values();
    for (BuildOutputJar buildOutputJar : outputJars) {
        List<String> entries = buildOutputJar.getExtraClasspathEntries();
        for (String entry : entries) {
            Pattern platformURL = Pattern.compile("platform:/(plugin|fragment)/([^/]*)/*(.*)");
            Matcher m = platformURL.matcher(entry.trim());
            String bundleId = null;
            String path = null;
            if (m.matches()) {
                bundleId = m.group(2).trim();
                path = m.group(3).trim();
                if (path != null && path.length() <= 0) {
                    path = null;
                }
                ArtifactDescriptor matchingBundle = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, bundleId, null);
                if (matchingBundle != null) {
                    List<File> locations;
                    if (matchingBundle.getMavenProject() != null) {
                        locations = getOtherProjectClasspath(matchingBundle, matchingBundle.getMavenProject(), path);
                    } else if (path != null) {
                        locations = getBundleEntry(matchingBundle, path);
                    } else {
                        locations = getBundleClasspath(matchingBundle);
                    }
                    classpath.add(new DefaultClasspathEntry(matchingBundle.getMavenProject(), matchingBundle.getKey(), locations, null));
                } else {
                    getLogger().warn("Missing extra classpath entry " + entry.trim());
                }
            } else {
                entry = entry.trim();
                File file = new File(project.getBasedir(), entry).getAbsoluteFile();
                if (file.exists()) {
                    List<File> locations = Collections.singletonList(file);
                    ArtifactKey projectKey = getArtifactKey(project);
                    classpath.add(new DefaultClasspathEntry(project, projectKey, locations, null));
                } else {
                    getLogger().warn("Missing extra classpath entry " + entry);
                }
            }
        }
    }
}
Also used : EclipsePluginProject(org.eclipse.tycho.core.osgitools.project.EclipsePluginProject) Pattern(java.util.regex.Pattern) ArtifactKey(org.eclipse.tycho.ArtifactKey) BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar) Matcher(java.util.regex.Matcher) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) File(java.io.File)

Aggregations

File (java.io.File)3 BuildOutputJar (org.eclipse.tycho.core.osgitools.project.BuildOutputJar)3 EclipsePluginProject (org.eclipse.tycho.core.osgitools.project.EclipsePluginProject)3 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)1 ArtifactKey (org.eclipse.tycho.ArtifactKey)1