use of org.eclipse.tycho.core.osgitools.project.BuildOutputJar in project tycho by eclipse.
the class TestMojo method getBuildOutputDirectories.
private String getBuildOutputDirectories() {
StringBuilder sb = new StringBuilder();
ReactorProject reactorProject = getReactorProject();
sb.append(reactorProject.getOutputDirectory());
sb.append(',').append(reactorProject.getTestOutputDirectory());
for (BuildOutputJar outputJar : osgiBundle.getEclipsePluginProject(reactorProject).getOutputJars()) {
if (".".equals(outputJar.getName())) {
// handled above
continue;
}
appendCommaSeparated(sb, outputJar.getOutputDirectory().getAbsolutePath());
}
return sb.toString();
}
use of org.eclipse.tycho.core.osgitools.project.BuildOutputJar 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);
}
use of org.eclipse.tycho.core.osgitools.project.BuildOutputJar in project tycho by eclipse.
the class PackagePluginMojo method createPluginJar.
private File createPluginJar() throws MojoExecutionException {
try {
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
File pluginFile = new File(buildDirectory, finalName + ".jar");
if (pluginFile.exists()) {
pluginFile.delete();
}
BuildProperties buildProperties = pdeProject.getBuildProperties();
List<String> binIncludesList = buildProperties.getBinIncludes();
List<String> binExcludesList = buildProperties.getBinExcludes();
// 1. additional filesets should win over bin.includes, so we add them first
if (additionalFileSets != null) {
for (DefaultFileSet fileSet : additionalFileSets) {
if (fileSet.getDirectory() != null && fileSet.getDirectory().isDirectory()) {
archiver.getArchiver().addFileSet(fileSet);
}
}
}
List<String> binIncludesIgnoredForValidation = new ArrayList<>();
// 2. handle dir classpath entries and "."
for (BuildOutputJar outputJar : pdeProject.getOutputJarMap().values()) {
String jarName = outputJar.getName();
if (binIncludesList.contains(jarName) && outputJar.isDirClasspathEntry()) {
binIncludesIgnoredForValidation.add(jarName);
String prefix = ".".equals(jarName) ? "" : jarName;
archiver.getArchiver().addDirectory(outputJar.getOutputDirectory(), prefix);
}
}
// 3. handle nested jars and included resources
checkBinIncludesExist(buildProperties, binIncludesIgnoredForValidation.toArray(new String[0]));
archiver.getArchiver().addFileSet(getFileSet(project.getBasedir(), binIncludesList, binExcludesList));
File manifest = updateManifest();
if (manifest.exists()) {
archive.setManifestFile(manifest);
}
archiver.setOutputFile(pluginFile);
if (!archive.isForced()) {
// optimized archive creation not supported for now because of build qualifier mismatch issues
// see TYCHO-502
getLog().warn("ignoring unsupported archive forced = false parameter.");
archive.setForced(true);
}
archiver.createArchive(session, project, archive);
return pluginFile;
} catch (IOException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling JAR", e);
}
}
use of org.eclipse.tycho.core.osgitools.project.BuildOutputJar 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);
}
use of org.eclipse.tycho.core.osgitools.project.BuildOutputJar 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);
}
}
}
}
}
Aggregations