Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-21 13:32:27 +0000
committerMilos Kleint2010-12-21 13:32:27 +0000
commite4d0f6894d00c8303eb050f26a1b28e5fcca6f80 (patch)
tree1f7fb1785f56dfcccce2b93987c0c9063e0b22fb /org.eclipse.m2e.editor.xml
parentef9d5db6837e30ce0c5e339bab85077856015896 (diff)
downloadm2e-core-e4d0f6894d00c8303eb050f26a1b28e5fcca6f80.tar.gz
m2e-core-e4d0f6894d00c8303eb050f26a1b28e5fcca6f80.tar.xz
m2e-core-e4d0f6894d00c8303eb050f26a1b28e5fcca6f80.zip
addition to fileForInputLocation() - now capable of finding a java.io.File for a local repository artifact as well. fixes/improves the behavior of hyperlinks
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
index d1beb33d..280480d2 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
@@ -29,6 +29,7 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
@@ -40,6 +41,8 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.core.MavenLogger;
+import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.internal.project.MavenMarkerManager;
import org.eclipse.m2e.core.project.IMavenProjectCache;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
@@ -129,7 +132,11 @@ public class XmlUtils {
}
return mp;
}
-
+ /**
+ * you are encouraged to use the extractMavenProject(ITextViewer) method instead
+ * @param project
+ * @return
+ */
public static MavenProject extractMavenProject(IProject project) {
//TODO we might want to eventually reduce our dependency on IProject
if (project != null) {
@@ -165,6 +172,17 @@ public class XmlUtils {
IMavenProjectFacade facade = MavenPlugin.getDefault().getMavenProjectManager().getMavenProject(splitStrings[0], splitStrings[1], splitStrings[2]);
if (facade != null) {
file = facade.getPomFile();
+ } else {
+ //if not in the workspace, try looking into the local repository.
+ IMaven maven = MavenPlugin.getDefault().getMaven();
+ try {
+ String path = maven.getArtifactPath(maven.getLocalRepository(), splitStrings[0], splitStrings[1], splitStrings[2], "pom", null);
+ if (path != null) {
+ file = new File(maven.getLocalRepositoryPath(), path);
+ }
+ } catch(CoreException e) {
+ MavenLogger.log("Failed to calculate local repository path of artifact", e);
+ }
}
}
return file;

Back to the top