Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2014-09-02 16:15:21 +0000
committerEike Stepper2014-09-02 16:15:21 +0000
commite2d20284488d175e4e3a4dff63ad374ce3a2d0e3 (patch)
tree321d769f068154940d167d073d9eef4e84288ae8 /plugins/org.eclipse.oomph.targlets.core/src/org/eclipse/oomph/targlets/internal
parentc9541a39465e42424a7f40e64e86fa2b7652504e (diff)
downloadorg.eclipse.oomph-e2d20284488d175e4e3a4dff63ad374ce3a2d0e3.tar.gz
org.eclipse.oomph-e2d20284488d175e4e3a4dff63ad374ce3a2d0e3.tar.xz
org.eclipse.oomph-e2d20284488d175e4e3a4dff63ad374ce3a2d0e3.zip
[443119] Provide a dynamic variable for the classpath jars of a targlet container
https://bugs.eclipse.org/bugs/show_bug.cgi?id=443119
Diffstat (limited to 'plugins/org.eclipse.oomph.targlets.core/src/org/eclipse/oomph/targlets/internal')
-rw-r--r--plugins/org.eclipse.oomph.targlets.core/src/org/eclipse/oomph/targlets/internal/core/TargletContainerClasspathResolver.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/plugins/org.eclipse.oomph.targlets.core/src/org/eclipse/oomph/targlets/internal/core/TargletContainerClasspathResolver.java b/plugins/org.eclipse.oomph.targlets.core/src/org/eclipse/oomph/targlets/internal/core/TargletContainerClasspathResolver.java
new file mode 100644
index 000000000..feeb75c47
--- /dev/null
+++ b/plugins/org.eclipse.oomph.targlets.core/src/org/eclipse/oomph/targlets/internal/core/TargletContainerClasspathResolver.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.oomph.targlets.internal.core;
+
+import org.eclipse.oomph.p2.core.Profile;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.IDynamicVariableResolver;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class TargletContainerClasspathResolver implements IDynamicVariableResolver
+{
+ public String resolveValue(IDynamicVariable variable, String containerID) throws CoreException
+ {
+ StringBuilder builder = new StringBuilder();
+
+ TargletContainerDescriptor descriptor = TargletContainerDescriptorManager.getInstance().getDescriptor(containerID, new NullProgressMonitor());
+ if (descriptor != null)
+ {
+ Profile profile = descriptor.getWorkingProfile();
+ if (profile != null)
+ {
+ IFileArtifactRepository artifactRepository = profile.getBundlePool().getFileArtifactRepository();
+
+ for (IInstallableUnit iu : profile.query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()))
+ {
+ for (IArtifactKey artifactKey : iu.getArtifacts())
+ {
+ if ("osgi.bundle".equals(artifactKey.getClassifier()) && !artifactKey.getId().endsWith(".source"))
+ {
+ File file = artifactRepository.getArtifactFile(artifactKey);
+ if (file != null)
+ {
+ if (builder.length() != 0)
+ {
+ builder.append(";");
+ }
+
+ builder.append(file.getAbsolutePath());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return builder.toString();
+ }
+}

Back to the top