Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2014-05-23 10:51:01 -0400
committerFred Bricon2014-05-23 10:51:01 -0400
commit18b6c9e9d0da1ad872156180687b07334f5ac830 (patch)
tree7eb42e193ec05477000a6aa41a4965d7635c9fc8
parent42b52c6aa76f200dade97f63ec29d5652fd0620e (diff)
downloadm2e-core-18b6c9e9d0da1ad872156180687b07334f5ac830.tar.gz
m2e-core-18b6c9e9d0da1ad872156180687b07334f5ac830.tar.xz
m2e-core-18b6c9e9d0da1ad872156180687b07334f5ac830.zip
421688 : Provide better feedback about import issuesmilestones/1.5/1.5.0.20140524-0005
Change-Id: I4bcfc9c3b1ea1d17f208e5a74d2a16f4f75df416 Signed-off-by: Fred Bricon <fbricon@gmail.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties1
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java9
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java18
6 files changed, 27 insertions, 6 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
index d0c06bcb..c953a501 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
@@ -243,6 +243,8 @@ public class Messages extends NLS {
public static String MavenImportWizardPage_btnDeselectTree_text;
+ public static String MavenImportWizardPage_forbiddenImportFromRoot;
+
public static String MavenImportWizard_titleIncompleteMapping;
public static String MavenImportWizard_messageIncompleteMapping;
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
index 062231f9..424b9bf3 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
@@ -133,6 +133,7 @@ MavenImportWizardPage_btnDeselectTree_text=Deselect Tree
MavenImportWizardPage_btnSelectTree_text=Select Tree
MavenImportWizardPage_createWorkingSet=Add project(s) to working set
MavenImportWizardPage_desc=Select Maven projects
+MavenImportWizardPage_forbiddenImportFromRoot=Importing projects from the root directory is not permitted.
MavenImportWizardPage_inherited=[inherited]
MavenImportWizardPage_mntmDeselectTree_text=Deselect Tree
MavenImportWizardPage_mntmSelectTree_text=Select Tree
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
index 6ba7b898..e6d4bea3 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
@@ -33,7 +33,9 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
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.core.runtime.Path;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@@ -418,6 +420,12 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
protected boolean rootDirectoryChanged() {
String _rootDirectory = rootDirectory;
rootDirectory = rootDirectoryCombo.getText().trim();
+ IPath p = new Path(rootDirectory);
+ if(p.isRoot()) {
+ setErrorMessage(Messages.MavenImportWizardPage_forbiddenImportFromRoot);
+ return false;
+ }
+ setErrorMessage(null);
return _rootDirectory == null || !_rootDirectory.equals(rootDirectory);
}
@@ -426,6 +434,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
}
public void scanProjects() {
+
final AbstractProjectScanner<MavenProjectInfo> projectScanner = getProjectScanner();
try {
getWizard().getContainer().run(true, true, new IRunnableWithProgress() {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java
index d091b65c..a3b46368 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java
@@ -84,6 +84,8 @@ public class Messages extends NLS {
public static String ProjectConfigurationUpdateRequired;
+ public static String LocalProjectScanner_accessDeniedFromFolder;
+
public static String LocalProjectScanner_task_scanning;
public static String MavenExternalRuntime_error_cannot_parse;
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties
index b349539f..68f5f13e 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties
@@ -30,6 +30,7 @@ PluginExecutionMappingDuplicate=Conflicting lifecycle mapping (plugin execution
PluginExecutionMappingInvalid=Invalid plugin execution mapping (plugin execution "{0}"). To enable full functionality, correct the invalid mapping and run Maven->Update Project Configuration.
ProjectConfiguratorNotAvailable=Project configurator "{0}" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration.
ProjectConfigurationUpdateRequired=Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix.
+LocalProjectScanner_accessDeniedFromFolder=Can not access files from ''{0}''
LocalProjectScanner_task_scanning=Scanning folders
MavenExternalRuntime_error_cannot_parse=Can't parse m2.conf
MavenExternalRuntime_exc_unsupported=Unsupported m2.conf element
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java
index f17f6470..da30c18a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/LocalProjectScanner.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.osgi.util.NLS;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
@@ -67,7 +68,7 @@ public class LocalProjectScanner extends AbstractProjectScanner<MavenProjectInfo
for(String folderName : folders) {
try {
File folder = new File(folderName).getCanonicalFile();
- scanFolder(folder, "", new SubProgressMonitor(subMonitor, IProgressMonitor.UNKNOWN));
+ scanFolder(folder, "", new SubProgressMonitor(subMonitor, IProgressMonitor.UNKNOWN)); //$NON-NLS-1$
} catch(IOException ex) {
addError(ex);
}
@@ -89,6 +90,7 @@ public class LocalProjectScanner extends AbstractProjectScanner<MavenProjectInfo
if(!baseDir.exists() || !baseDir.isDirectory() || IMavenConstants.METADATA_FOLDER.equals(baseDir.getName())) {
return;
}
+
try {
if(scannedFolders.contains(baseDir.getCanonicalFile())) {
return;
@@ -105,12 +107,16 @@ public class LocalProjectScanner extends AbstractProjectScanner<MavenProjectInfo
}
File[] files = baseDir.listFiles();
+ if(files == null) {
+ addError(new Exception(NLS.bind(Messages.LocalProjectScanner_accessDeniedFromFolder, baseDir.getAbsolutePath())));
+ return;
+ }
for(int i = 0; i < files.length; i++ ) {
File file;
try {
file = files[i].getCanonicalFile();
if(file.isDirectory()) {
- scanFolder(file, rootRelPath + "/" + file.getName(), monitor);
+ scanFolder(file, rootRelPath + "/" + file.getName(), monitor); //$NON-NLS-1$
}
} catch(IOException ex) {
addError(ex);
@@ -144,16 +150,16 @@ public class LocalProjectScanner extends AbstractProjectScanner<MavenProjectInfo
Map<String, Set<String>> modules = new LinkedHashMap<String, Set<String>>();
for(String module : model.getModules()) {
- if(module.endsWith("/pom.xml")) {
- module = module.substring(0, module.length() - "/pom.xml".length());
+ if(module.endsWith("/pom.xml")) { //$NON-NLS-1$
+ module = module.substring(0, module.length() - "/pom.xml".length()); //$NON-NLS-1$
}
modules.put(module, new HashSet<String>());
}
for(Profile profile : model.getProfiles()) {
for(String module : profile.getModules()) {
- if(module.endsWith("/pom.xml")) {
- module = module.substring(0, module.length() - "/pom.xml".length());
+ if(module.endsWith("/pom.xml")) { //$NON-NLS-1$
+ module = module.substring(0, module.length() - "/pom.xml".length()); //$NON-NLS-1$
}
Set<String> profiles = modules.get(module);
if(profiles == null) {

Back to the top