Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-02-10 18:06:15 -0500
committervladt2011-02-10 18:06:15 -0500
commitd8a4a3e181fe1b241d7e7785312a5e2c4a8bbce5 (patch)
tree8dae073380652d49577e6ac914930a5c2de3fc96 /org.eclipse.m2e.scm
parenta1639bf8aa6a6a8ba1575b1a4d183e6815128f6b (diff)
downloadm2e-core-d8a4a3e181fe1b241d7e7785312a5e2c4a8bbce5.tar.gz
m2e-core-d8a4a3e181fe1b241d7e7785312a5e2c4a8bbce5.tar.xz
m2e-core-d8a4a3e181fe1b241d7e7785312a5e2c4a8bbce5.zip
335872: Replaced direct calls to maven console logMessage/logError with slf4j log calls
Diffstat (limited to 'org.eclipse.m2e.scm')
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenCheckoutOperation.java13
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenProjectPomScanner.java37
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenMaterializePomWizard.java9
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java13
4 files changed, 31 insertions, 41 deletions
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenCheckoutOperation.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenCheckoutOperation.java
index 3da9102e..26af0f5e 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenCheckoutOperation.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenCheckoutOperation.java
@@ -19,11 +19,12 @@ import java.util.List;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.m2e.core.core.MavenConsole;
import org.eclipse.m2e.scm.internal.Messages;
import org.eclipse.m2e.scm.internal.ScmHandlerFactory;
import org.eclipse.m2e.scm.spi.ScmHandler;
import org.eclipse.osgi.util.NLS;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -32,19 +33,17 @@ import org.eclipse.osgi.util.NLS;
* @author Eugene Kuleshov
*/
public class MavenCheckoutOperation {
+ private static final Logger log = LoggerFactory.getLogger(MavenCheckoutOperation.class);
- private final MavenConsole console;
-
private final File location;
private final Collection<MavenProjectScmInfo> mavenProjects;
private final List<String> locations = new ArrayList<String>();
- public MavenCheckoutOperation(File location, Collection<MavenProjectScmInfo> mavenProjects, MavenConsole console) {
+ public MavenCheckoutOperation(File location, Collection<MavenProjectScmInfo> mavenProjects) {
this.location = location;
this.mavenProjects = mavenProjects;
- this.console = console;
}
public void run(IProgressMonitor monitor) throws InterruptedException, CoreException {
@@ -90,14 +89,12 @@ public class MavenCheckoutOperation {
ScmHandler handler = ScmHandlerFactory.getHandler(info.getFolderUrl());
if(handler == null) {
String msg = "SCM provider is not available for " + info.getFolderUrl();
- console.logError(msg);
+ log.error(msg);
} else {
handler.checkoutProject(info, location, monitor);
locations.add(location.getAbsolutePath());
}
-
}
-
}
protected File getUniqueDir(File baseDir) {
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenProjectPomScanner.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenProjectPomScanner.java
index d8508e28..a1785a42 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenProjectPomScanner.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/MavenProjectPomScanner.java
@@ -31,7 +31,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
-import org.eclipse.m2e.core.core.MavenConsole;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.embedder.MavenModelManager;
import org.eclipse.m2e.core.internal.Messages;
@@ -51,16 +50,13 @@ public class MavenProjectPomScanner<T> extends AbstractProjectScanner<MavenProje
private final boolean developer;
private final Dependency[] dependencies;
-
- private MavenConsole console;
private IMaven maven;
public MavenProjectPomScanner(boolean developer, Dependency[] dependencies, //
- MavenModelManager modelManager, MavenConsole console) {
+ MavenModelManager modelManager) {
this.developer = developer;
this.dependencies = dependencies;
- this.console = console;
this.maven = MavenPlugin.getDefault().getMaven();
}
@@ -84,42 +80,46 @@ public class MavenProjectPomScanner<T> extends AbstractProjectScanner<MavenProje
Model model = resolveModel(d.getGroupId(), d.getArtifactId(), d.getVersion(), monitor);
if(model==null) {
String msg = "Can't resolve " + d.getArtifactId();
- console.logError(msg);
- addError(new Exception(msg));
+ Exception error = new Exception(msg);
+ log.error(msg, error);
+ addError(error);
continue;
}
Scm scm = resolveScm(model, monitor);
if(scm==null) {
String msg = "No SCM info for " + d.getArtifactId();
- console.logError(msg);
- addError(new Exception(msg));
+ Exception error = new Exception(msg);
+ log.error(msg, error);
+ addError(error);
continue;
}
String tag = scm.getTag();
- console.logMessage(d.getArtifactId());
- console.logMessage("Connection: " + scm.getConnection());
- console.logMessage(" dev: " + scm.getDeveloperConnection());
- console.logMessage(" url: " + scm.getUrl());
- console.logMessage(" tag: " + tag);
+ log.info(d.getArtifactId());
+ log.info("Connection: " + scm.getConnection());
+ log.info(" dev: " + scm.getDeveloperConnection());
+ log.info(" url: " + scm.getUrl());
+ log.info(" tag: " + tag);
String connection;
if(developer) {
connection = scm.getDeveloperConnection();
if(connection==null) {
String msg = d.getArtifactId() + " doesn't specify developer SCM connection";
- console.logError(msg);
- addError(new Exception(msg));
+ Exception error = new Exception(msg);
+ log.error(msg, error);
+ addError(error);
continue;
}
} else {
connection = scm.getConnection();
if(connection==null) {
String msg = d.getArtifactId() + " doesn't specify SCM connection";
- console.logError(msg);
- addError(new Exception(msg));
+ Exception error = new Exception(msg);
+ log.error(msg, error);
+ addError(error);
continue;
}
}
@@ -143,7 +143,6 @@ public class MavenProjectPomScanner<T> extends AbstractProjectScanner<MavenProje
} catch(Exception ex) {
addError(ex);
String msg = "Error reading " + d.getArtifactId();
- console.logError(msg);
log.error(msg, ex);
}
}
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenMaterializePomWizard.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenMaterializePomWizard.java
index ddfd234f..dfbc9986 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenMaterializePomWizard.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenMaterializePomWizard.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
-import org.eclipse.m2e.scm.internal.Messages;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
import org.eclipse.m2e.core.ui.internal.wizards.AbstractMavenProjectWizard;
@@ -28,6 +27,7 @@ import org.eclipse.m2e.core.ui.internal.wizards.MavenDependenciesWizardPage;
import org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardLocationPage;
import org.eclipse.m2e.scm.MavenProjectPomScanner;
import org.eclipse.m2e.scm.MavenProjectScmInfo;
+import org.eclipse.m2e.scm.internal.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
@@ -134,9 +134,9 @@ public class MavenMaterializePomWizard extends AbstractMavenProjectWizard implem
MavenProjectCheckoutJob job = new MavenProjectCheckoutJob(importConfiguration, checkoutAllProjects, workingSets) {
protected List<MavenProjectScmInfo> getProjects(IProgressMonitor monitor) throws InterruptedException {
MavenPlugin plugin = MavenPlugin.getDefault();
- MavenProjectPomScanner<MavenProjectScmInfo> scanner = new MavenProjectPomScanner<MavenProjectScmInfo>(developer, dependencies, //
- plugin.getMavenModelManager(), //
- plugin.getConsole());
+ MavenProjectPomScanner<MavenProjectScmInfo> scanner = new MavenProjectPomScanner<MavenProjectScmInfo>(
+ developer, dependencies, //
+ plugin.getMavenModelManager());
scanner.run(monitor);
// XXX handle errors/warnings
@@ -152,5 +152,4 @@ public class MavenMaterializePomWizard extends AbstractMavenProjectWizard implem
return true;
}
-
}
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
index 6be6cccd..ea9a745d 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
@@ -37,7 +37,6 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.core.MavenConsole;
import org.eclipse.m2e.core.embedder.MavenModelManager;
import org.eclipse.m2e.core.project.IMavenProjectImportResult;
import org.eclipse.m2e.core.project.LocalProjectScanner;
@@ -104,15 +103,13 @@ public abstract class MavenProjectCheckoutJob extends WorkspaceJob {
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
- MavenPlugin plugin = MavenPlugin.getDefault();
- MavenConsole console = plugin.getConsole();
-
- MavenCheckoutOperation operation = new MavenCheckoutOperation(location, getProjects(monitor), console);
+ MavenCheckoutOperation operation = new MavenCheckoutOperation(location, getProjects(monitor));
operation.run(monitor);
collectedLocations.addAll(operation.getLocations());
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
+ MavenPlugin plugin = MavenPlugin.getDefault();
MavenModelManager modelManager = plugin.getMavenModelManager();
LocalProjectScanner scanner = new LocalProjectScanner(workspace.getLocation().toFile(), operation.getLocations(),
@@ -161,7 +158,7 @@ public abstract class MavenProjectCheckoutJob extends WorkspaceJob {
}
if(projects.isEmpty()) {
- MavenPlugin.getDefault().getConsole().logMessage("No Maven projects to import");
+ log.info("No Maven projects to import");
if(collectedLocations.size()==1) {
final String location = collectedLocations.get(0);
@@ -245,13 +242,11 @@ public abstract class MavenProjectCheckoutJob extends WorkspaceJob {
}
protected void cleanup(List<String> locations) {
- MavenConsole console = MavenPlugin.getDefault().getConsole();
for(String location : locations) {
try {
FileUtils.deleteDirectory(location);
} catch(IOException ex) {
- String msg = "Can't delete " + location;
- console.logError(msg + "; " + (ex.getMessage()==null ? ex.toString() : ex.getMessage())); //$NON-NLS-1$
+ String msg = "Can't delete " + location + "; " + (ex.getMessage() == null ? ex.toString() : ex.getMessage()); //$NON-NLS-1$
log.error(msg, ex);
}
}

Back to the top