Author: fbricon
Date: 2012-01-22 08:12:35 -0500 (Sun, 22 Jan 2012)
New Revision: 38018
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/ModuleDirectoryScannerPathFilter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/PublishFilterDirectoryScanner.java
Log:
JBIDE-10642 : fixed platform dependent path comparisons that didn't work on Windows.
Also don't scan anything if no patterns are set.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java 2012-01-22
11:57:42 UTC (rev 38017)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java 2012-01-22
13:12:35 UTC (rev 38018)
@@ -144,16 +144,21 @@
if( ServerModelUtilities.isBinaryModule(module) )
return null;
String[] incExc = getProjectIncludesExcludes(module);
- if( incExc != null ) {
- try {
- ModuleDirectoryScannerPathFilter filter =
- new ModuleDirectoryScannerPathFilter(getMembers(module),
- incExc[0], incExc[1]);
- return filter;
- } catch( CoreException ce ) {
- JBossServerCorePlugin.getDefault().getLog().log(ce.getStatus());
- }
+ String inclusionPatterns = incExc[0];
+ String exclusionPatterns = incExc[1];
+ if (exclusionPatterns == null
+ && (inclusionPatterns == null ||
ALL_RESOURCES_PATTERN.equals(inclusionPatterns))) {
+ //No filtering necessary, everything is included. That way we avoid unnecessary
scans
+ return null;
}
+ try {
+ ModuleDirectoryScannerPathFilter filter =
+ new ModuleDirectoryScannerPathFilter(getMembers(module),
+ inclusionPatterns, exclusionPatterns);
+ return filter;
+ } catch( CoreException ce ) {
+ JBossServerCorePlugin.getDefault().getLog().log(ce.getStatus());
+ }
return null;
}
@@ -172,6 +177,7 @@
*/
public static final String COMPONENT_EXCLUSIONS_PATTERN =
"component.exclusion.patterns"; //$NON-NLS-1$
+ private static final String ALL_RESOURCES_PATTERN = "**"; //$NON-NLS-1$
/**
* Does this project have the proper settings that call for
* include and exclude patterns in the virtual component metadata?
@@ -186,9 +192,26 @@
IProject p = module.getProject();
IVirtualComponent vc = ComponentCore.createComponent(p);
Properties props = vc.getMetaProperties();
+ String exclusionPatterns = getPatternValue(props, COMPONENT_EXCLUSIONS_PATTERN);
+ String inclusionPatterns = getPatternValue(props, COMPONENT_INCLUSIONS_PATTERN);
+
return new String[]{
- (String) props.get(COMPONENT_INCLUSIONS_PATTERN),
- (String) props.get(COMPONENT_EXCLUSIONS_PATTERN)
+ inclusionPatterns,
+ exclusionPatterns
};
}
+
+ /**
+ * Returns the trimmed property value if it exists and is not empty, or null otherwise
+ */
+ private static String getPatternValue(Properties props, String propertyName) {
+ String value = props.getProperty(propertyName);
+ if (value != null) {
+ value = value.trim();
+ if (value.length() == 0) {
+ value = null;
+ }
+ }
+ return value;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/ModuleDirectoryScannerPathFilter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/ModuleDirectoryScannerPathFilter.java 2012-01-22
11:57:42 UTC (rev 38017)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/ModuleDirectoryScannerPathFilter.java 2012-01-22
13:12:35 UTC (rev 38018)
@@ -17,15 +17,10 @@
*/
public class ModuleDirectoryScannerPathFilter implements IModulePathFilter {
- private IModuleResource[] members;
- private String includes, excludes;
private PublishFilterDirectoryScanner scanner;
private boolean scanned = false;
public ModuleDirectoryScannerPathFilter(IModuleResource[] members,
String includes, String excludes) {
- this.members = members;
- this.includes = includes;
- this.excludes = excludes;
scanner = new PublishFilterDirectoryScanner(members);
scanner.setIncludes(includes);
scanner.setExcludes(excludes);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/PublishFilterDirectoryScanner.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/PublishFilterDirectoryScanner.java 2012-01-22
11:57:42 UTC (rev 38017)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/patterns/PublishFilterDirectoryScanner.java 2012-01-22
13:12:35 UTC (rev 38018)
@@ -886,12 +886,16 @@
: al.toArray(new String[al.size()]);
}
+ /**
+ * Returns the platform-dependent resource path.
+ */
+ private String getResourcePath(IModuleResource resource) {
+ return
resource.getModuleRelativePath().append(resource.getName()).makeRelative().toOSString();
+ }
+
/*
* Public accessors
*/
- private String getResourcePath(IModuleResource resource) {
- return
resource.getModuleRelativePath().append(resource.getName()).makeRelative().toString();
- }
public boolean isIncludedFile(IModuleFile resource) {
return isIncludedFile(getResourcePath(resource));
}
@@ -902,13 +906,15 @@
return isNotIncludedButRequired(getResourcePath(resource));
}
public boolean isIncludedMember(IModuleResource resource) {
- return isIncludedFile(getResourcePath(resource))
- || isIncludedDir(getResourcePath(resource));
+ String path = getResourcePath(resource);
+ return isIncludedFile(path)
+ || isIncludedDir(path);
}
public boolean isRequiredMember(IModuleResource resource) {
- return isIncludedFile(getResourcePath(resource))
- || isIncludedDir(getResourcePath(resource))
- || isNotIncludedButRequired(getResourcePath(resource));
+ String path = getResourcePath(resource);
+ return isIncludedFile(path)
+ || isIncludedDir(path)
+ || isNotIncludedButRequired(path);
}
public boolean isIncludedFile(String vpath) {
return filesIncluded.contains(vpath);