[jbosstools-commits] JBoss Tools SVN: r43984 - in trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui: handlers and 2 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Sep 25 05:52:01 EDT 2012


Author: fbricon
Date: 2012-09-25 05:52:00 -0400 (Tue, 25 Sep 2012)
New Revision: 43984

Added:
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/DependencyResolutionJob.java
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentificationJob.java
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyJarJob.java
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyProjectJob.java
Removed:
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/handlers/IdentifyJarJob.java
Modified:
   trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/dialog/IdentifyMavenDependencyPage.java
Log:
JBIDE-12707 : identify maven project dependencies

Modified: trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/dialog/IdentifyMavenDependencyPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/dialog/IdentifyMavenDependencyPage.java	2012-09-25 01:50:49 UTC (rev 43983)
+++ trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/dialog/IdentifyMavenDependencyPage.java	2012-09-25 09:52:00 UTC (rev 43984)
@@ -55,10 +55,13 @@
 import org.eclipse.swt.widgets.TableItem;
 import org.jboss.tools.maven.conversion.ui.dialog.xpl.ConversionUtils;
 import org.jboss.tools.maven.conversion.ui.dialog.xpl.EditDependencyDialog;
-import org.jboss.tools.maven.conversion.ui.handlers.IdentifyJarJob;
-import org.jboss.tools.maven.conversion.ui.handlers.IdentifyJarJob.Task;
 import org.jboss.tools.maven.conversion.ui.internal.CellListener;
 import org.jboss.tools.maven.conversion.ui.internal.MavenDependencyConversionActivator;
+import org.jboss.tools.maven.conversion.ui.internal.jobs.DependencyResolutionJob;
+import org.jboss.tools.maven.conversion.ui.internal.jobs.IdentificationJob;
+import org.jboss.tools.maven.conversion.ui.internal.jobs.IdentifyJarJob;
+import org.jboss.tools.maven.conversion.ui.internal.jobs.IdentifyProjectJob;
+import org.jboss.tools.maven.conversion.ui.internal.jobs.IdentificationJob.Task;
 import org.jboss.tools.maven.core.identification.IFileIdentificationManager;
 import org.jboss.tools.maven.core.identification.IdentificationUtil;
 import org.jboss.tools.maven.core.internal.identification.FileIdentificationManager;
@@ -75,7 +78,7 @@
 
 	private Map<IClasspathEntry, Dependency> dependencyMap;
 
-	private Map<IClasspathEntry, IdentifyJarJob> identificationJobs;
+	private Map<IClasspathEntry, IdentificationJob> identificationJobs;
 
 	private Set<IClasspathEntry> initialEntries;
 
@@ -260,7 +263,7 @@
 				if (columnIndex == DEPENDENCY_COLUMN) {
 					IClasspathEntry cpe = (IClasspathEntry) item.getData();
 					
-					IdentifyJarJob job = identificationJobs.get(cpe);
+					IdentificationJob job = identificationJobs.get(cpe);
 					if (Job.RUNNING == job.getState()) {
 						return;
 					}
@@ -302,7 +305,7 @@
 
 	private void resolve(IClasspathEntry cpe, Dependency d) {
 		if (d != null) {
-			IdentifyJarJob job = identificationJobs.get(cpe);
+			IdentificationJob job = identificationJobs.get(cpe);
 			job.setDependency(d);
 			job.setRequestedProcess(Task.RESOLUTION_ONLY);
 			job.schedule();
@@ -310,7 +313,7 @@
 	}
 	
 	public boolean hasNoRunningJobs() {
-		for (IdentifyJarJob job : identificationJobs.values()) {
+		for (IdentificationJob job : identificationJobs.values()) {
 			if (job.getState() == Job.RUNNING){
 				return false;
 			}
@@ -386,7 +389,7 @@
 				//don't need to run identification
 				//continue;
 			}
-			IdentifyJarJob job = identificationJobs.get(entry.getKey());
+			IdentificationJob job = identificationJobs.get(entry.getKey());
 			if (job != null) {
 				job.setProgressGroup(monitor, 1);
 				int jobState = job.getState();
@@ -427,7 +430,7 @@
     
     private void initJobs() {
     	if (identificationJobs == null) {
-    		identificationJobs = new HashMap<IClasspathEntry, IdentifyJarJob>(dependencyMap.size());
+    		identificationJobs = new HashMap<IClasspathEntry, IdentificationJob>(dependencyMap.size());
     		
     		Table t = dependenciesViewer.getTable();
     		IFileIdentificationManager fileIdentificationManager = new FileIdentificationManager();
@@ -441,9 +444,16 @@
     			}
     			File jar;
 				try {
-					jar = ConversionUtils.getFile(cpe);
+					final IdentificationJob job;
+					if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+						job = new IdentifyProjectJob("Search the Maven coordinates for "+cpe.getPath(), cpe.getPath());
+					} else if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+						jar = ConversionUtils.getFile(cpe);
+						job = new IdentifyJarJob("Search the Maven coordinates for "+jar.getAbsolutePath(), fileIdentificationManager, jar);
+					} else {
+						job = new DependencyResolutionJob("Resolve the Maven dependency for "+cpe.getPath());
+					}
 					
-					final IdentifyJarJob job = new IdentifyJarJob("Search the Maven coordinates for "+jar.getAbsolutePath(), fileIdentificationManager, jar);
 					job.addJobChangeListener(new IJobChangeListener() {
 						
 						@Override
@@ -508,6 +518,13 @@
 			final IClasspathEntry cpe = (IClasspathEntry)item.getData();
 			if (cpe.equals(key)) {
 				dependenciesViewer.refresh(cpe, false);
+				//Don't force check when there's an existing dependency, only uncheck if they're is not.
+				if (dependencyMap.get(cpe) == null) {
+					Job job = identificationJobs.get(cpe);
+					if (job != null && job.getState() == Job.NONE) {
+						dependenciesViewer.setChecked(cpe, false);
+					}
+				}
 				setPageComplete(hasNoRunningJobs());
 				return;
 			}
@@ -530,7 +547,6 @@
 		return dependencies;
 	}
 
-
 	public boolean isDeleteJars() {
 		return deleteJars;
 	}
@@ -548,7 +564,7 @@
 			@SuppressWarnings("unchecked")
 			public String getText(Object element) {
 				IClasspathEntry cpe = (IClasspathEntry) element;
-				IdentifyJarJob job = identificationJobs ==null? null:identificationJobs.get(cpe);
+				IdentificationJob job = identificationJobs ==null? null:identificationJobs.get(cpe);
 				if (job != null) {
 					int jobState = job.getState();
 					if (jobState == Job.RUNNING || jobState == Job.WAITING) {
@@ -563,7 +579,7 @@
 			@SuppressWarnings("unchecked")
 			public Image getImage(Object element) {
 				IClasspathEntry cpe = (IClasspathEntry) element;
-				IdentifyJarJob job = identificationJobs ==null? null:identificationJobs.get(cpe);
+				IdentificationJob job = identificationJobs ==null? null:identificationJobs.get(cpe);
 				if (job != null) {
 					int jobState = job.getState();
 					if (jobState == Job.RUNNING || jobState == Job.WAITING) {
@@ -588,7 +604,7 @@
 	}
 
 	public void cancel() {
-		for (IdentifyJarJob job : identificationJobs.values()) {
+		for (IdentificationJob job : identificationJobs.values()) {
 			job.cancel();
 		}
 	}

Deleted: trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/handlers/IdentifyJarJob.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/handlers/IdentifyJarJob.java	2012-09-25 01:50:49 UTC (rev 43983)
+++ trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/handlers/IdentifyJarJob.java	2012-09-25 09:52:00 UTC (rev 43984)
@@ -1,130 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2012 Red Hat, Inc. 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:
- *     JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.maven.conversion.ui.handlers;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Dependency;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.ArtifactKey;
-import org.eclipse.m2e.core.embedder.IMaven;
-import org.jboss.tools.maven.conversion.ui.internal.MavenDependencyConversionActivator;
-import org.jboss.tools.maven.core.identification.IFileIdentificationManager;
-
-public class IdentifyJarJob extends Job {
-
-	public enum Task  {
-		ALL, IDENTIFICATION_ONLY, RESOLUTION_ONLY
-	}
-	
-	private File file;
-	
-	private IFileIdentificationManager fileIdentificationManager;
-
-	private Dependency dependency;
-	
-	private Boolean resolvable;
-
-	private Task task;
-	
-	public IdentifyJarJob(String name, IFileIdentificationManager fileIdentificationManager, File file) {
-		super(name);
-		this.fileIdentificationManager = fileIdentificationManager;
-		this.file = file;
-		setRequestedProcess(Task.ALL);
-	}
-
-	@Override
-	protected IStatus run(IProgressMonitor monitor) {
-		if (monitor == null) {
-			monitor = new NullProgressMonitor();
-		}
-		
-		if (monitor.isCanceled()) {
-			return Status.OK_STATUS;
-		}
-		
-		if (Task.ALL.equals(task) 
-			|| Task.IDENTIFICATION_ONLY.equals(task)) {
-
-			monitor.subTask("Identifying "+ file);
-			ArtifactKey artifactKey;
-			try {
-				artifactKey = fileIdentificationManager.identify(file, monitor);
-			} catch (CoreException e) {
-				monitor.worked(1);
-				return new Status(IStatus.ERROR, MavenDependencyConversionActivator.PLUGIN_ID, e.getMessage(), e);
-			}
-			if (artifactKey != null) {
-				dependency = new Dependency();
-				dependency.setArtifactId(artifactKey.getArtifactId());
-				dependency.setGroupId(artifactKey.getGroupId());
-				dependency.setVersion(artifactKey.getVersion());
-				dependency.setClassifier(artifactKey.getClassifier());
-			}
-		}
-		
-
-		if (dependency != null && (Task.ALL.equals(task) 
-			|| Task.RESOLUTION_ONLY.equals(task))) {
-			resolvable = checkResolution(dependency, monitor);
-		}
-		monitor.worked(1);
-		return Status.OK_STATUS;
-	}
-
-	private static boolean checkResolution(Dependency d, IProgressMonitor monitor) {
-		if (monitor.isCanceled()) {
-			return false;
-		}
-		String groupId = d.getGroupId();
-		String artifactId = d.getArtifactId();
-		String version = d.getVersion();
-		String type = d.getType();
-		String classifier = d.getClassifier();
-		IMaven maven = MavenPlugin.getMaven();
-		Artifact a =null;
-		try {
-			List<ArtifactRepository> artifactRepositories = maven.getArtifactRepositories();
-			a = maven.resolve(groupId , artifactId , version , type , classifier , artifactRepositories , monitor);
-		} catch(CoreException e) {
-			//ignore
-		}
-		boolean resolved = a != null && a.isResolved();
-		return resolved;
-	}
-
-	public Dependency getDependency() {
-		return dependency;
-	}
-
-	public void setDependency(Dependency dependency) {
-		this.dependency = dependency;
-	}
-
-	public Boolean isResolvable() {
-		return resolvable;
-	}
-
-	public void setRequestedProcess(Task requestedProcess) {
-		this.task = requestedProcess;
-	}
-	
-}

Added: trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/DependencyResolutionJob.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/DependencyResolutionJob.java	                        (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/DependencyResolutionJob.java	2012-09-25 09:52:00 UTC (rev 43984)
@@ -0,0 +1,27 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. 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:
+ *     JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.conversion.ui.internal.jobs;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class DependencyResolutionJob extends IdentificationJob {
+
+	public DependencyResolutionJob(String name) {
+		super(name);
+	}
+
+	@Override
+	protected void identifyDependency(IProgressMonitor monitor) throws CoreException {
+		//Ignore identification
+	}
+
+}

Added: trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentificationJob.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentificationJob.java	                        (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentificationJob.java	2012-09-25 09:52:00 UTC (rev 43984)
@@ -0,0 +1,110 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. 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:
+ *     JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.conversion.ui.internal.jobs;
+
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Dependency;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMaven;
+import org.jboss.tools.maven.conversion.ui.internal.MavenDependencyConversionActivator;
+
+public abstract class IdentificationJob extends Job {
+
+	public enum Task  {
+		ALL, IDENTIFICATION_ONLY, RESOLUTION_ONLY
+	}
+	
+	protected Boolean resolvable;
+
+	protected Task task;
+
+	protected Dependency dependency;
+	
+	public IdentificationJob(String name) {
+		super(name);
+	}
+
+	public Dependency getDependency() {
+		return dependency;
+	}
+
+	public void setDependency(Dependency dependency) {
+		this.dependency = dependency;
+	}
+
+	public Boolean isResolvable() {
+		return resolvable;
+	}
+
+	public void setRequestedProcess(Task requestedProcess) {
+		this.task = requestedProcess;
+	}
+	
+	@Override
+	protected IStatus run(IProgressMonitor monitor) {
+		if (monitor == null) {
+			monitor = new NullProgressMonitor();
+		}
+		
+		if (monitor.isCanceled()) {
+			return Status.OK_STATUS;
+		}
+		resolvable = null;
+		try {
+			if (Task.ALL.equals(task) 
+				|| Task.IDENTIFICATION_ONLY.equals(task)) {
+				dependency = null;
+				identifyDependency(monitor);
+			}
+		
+			if (dependency != null && (Task.ALL.equals(task) 
+				|| Task.RESOLUTION_ONLY.equals(task))) {
+				checkResolution(monitor);
+			}
+			
+		} catch (CoreException e) {
+			monitor.worked(1);
+			return new Status(IStatus.ERROR, MavenDependencyConversionActivator.PLUGIN_ID, e.getMessage(), e);
+		}
+
+		monitor.worked(1);
+		return Status.OK_STATUS;
+	}
+
+	protected abstract void identifyDependency(IProgressMonitor monitor) throws CoreException;
+
+	protected void checkResolution(IProgressMonitor monitor) throws CoreException {
+		if (monitor.isCanceled()) {
+			return;
+		}
+		String groupId = dependency.getGroupId();
+		String artifactId = dependency.getArtifactId();
+		String version = dependency.getVersion();
+		String type = dependency.getType();
+		String classifier = dependency.getClassifier();
+		IMaven maven = MavenPlugin.getMaven();
+		
+		List<ArtifactRepository> artifactRepositories = maven.getArtifactRepositories();
+		Artifact a = maven.resolve(groupId , artifactId , version , type , classifier , artifactRepositories , monitor);
+		resolvable = (a != null && a.isResolved());
+	}
+
+
+}

Copied: trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyJarJob.java (from rev 43947, trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/handlers/IdentifyJarJob.java)
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyJarJob.java	                        (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyJarJob.java	2012-09-25 09:52:00 UTC (rev 43984)
@@ -0,0 +1,46 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. 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:
+ *     JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.conversion.ui.internal.jobs;
+
+import java.io.File;
+
+import org.apache.maven.model.Dependency;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.jboss.tools.maven.core.identification.IFileIdentificationManager;
+
+public class IdentifyJarJob extends IdentificationJob {
+	
+	private File file;
+	
+	private IFileIdentificationManager fileIdentificationManager;
+
+	public IdentifyJarJob(String name, IFileIdentificationManager fileIdentificationManager, File file) {
+		super(name);
+		this.fileIdentificationManager = fileIdentificationManager;
+		this.file = file;
+		setRequestedProcess(Task.ALL);
+	}
+
+	@Override
+	protected void identifyDependency(IProgressMonitor monitor) throws CoreException {
+		monitor.subTask("Identifying "+ file);
+		ArtifactKey artifactKey = fileIdentificationManager.identify(file, monitor);
+		if (artifactKey != null) {
+			dependency = new Dependency();
+			dependency.setArtifactId(artifactKey.getArtifactId());
+			dependency.setGroupId(artifactKey.getGroupId());
+			dependency.setVersion(artifactKey.getVersion());
+			dependency.setClassifier(artifactKey.getClassifier());
+		}
+	}
+}

Added: trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyProjectJob.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyProjectJob.java	                        (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.conversion.ui/src/org/jboss/tools/maven/conversion/ui/internal/jobs/IdentifyProjectJob.java	2012-09-25 09:52:00 UTC (rev 43984)
@@ -0,0 +1,77 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. 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:
+ *     JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.conversion.ui.internal.jobs;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+public class IdentifyProjectJob extends IdentificationJob {
+
+	private IPath projectPath;
+
+	private IMavenProjectFacade facade; 
+	
+	public IdentifyProjectJob(String name, IPath projectPath) {
+		super(name);
+		this.projectPath = projectPath;
+	}
+
+	@Override
+	protected void identifyDependency(IProgressMonitor monitor) throws CoreException {
+		IProject project = getProject(projectPath);
+		if (project != null) {
+			facade = MavenPlugin.getMavenProjectRegistry().getProject(project );
+			if (facade != null &&
+				facade.getMavenProject() != null &&
+				facade.getMavenProject().getArtifact() != null) {
+				Artifact a = facade.getMavenProject().getArtifact();
+				dependency = new Dependency();
+				dependency.setArtifactId(a.getArtifactId());
+				dependency.setGroupId(a.getGroupId());
+				dependency.setVersion(a.getVersion());
+				if (a.getArtifactHandler() != null &&
+					a.getArtifactHandler().getPackaging() != null) {
+					String type  = a.getArtifactHandler().getPackaging();
+					//case where classpath dependency is a war : it usually corresponds to 
+					//a jar of the war classes, having the "classes" classifier. 
+					if ("war".equals(type)) {
+						type = "jar";
+						dependency.setClassifier("classes");
+					}
+					
+					dependency.setType(type);
+				}
+			}
+		}
+	}
+	
+	@Override
+	protected void checkResolution(IProgressMonitor monitor) throws CoreException {
+		resolvable = facade != null &&
+					 facade.getMavenProject() != null &&
+				     facade.getMavenProject().getArtifact() != null && 
+				     facade.getProject() != null &&
+				     facade.getProject().isAccessible();
+	}
+	
+	private IProject getProject(IPath projectPath) {
+		IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath.lastSegment());
+		return p;
+	}
+}
+



More information about the jbosstools-commits mailing list