diff --git a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java
index e6167cb8..2614ccab 100644
--- a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java
+++ b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java
@@ -180,7 +180,7 @@ private static final class IsUnix implements Callable {
IsUnix() {
}
- @Override
+
public Boolean call() throws IOException {
return File.pathSeparatorChar == ':';
}
@@ -203,6 +203,7 @@ public Boolean call() throws IOException {
private boolean filteringOutDestroySubBranchEvent;
private boolean freezeCode;
private String loadRules;
+ private String[] loadRulesForModuleRoot = {};
private String loadRulesForPolling;
private String mkviewOptionalParam;
private int multiSitePollBuffer;
@@ -284,7 +285,7 @@ public AbstractClearCaseScm(final String viewName, final String mkviewOptionalPa
*/
@Override
public void buildEnvVars(AbstractBuild, ?> build, Map env) {
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
VariableResolver.Union variableResolver = new VariableResolver.Union(new BuildVariableResolver(build, true),
new VariableResolver.ByMap(env));
String normalizedViewName = getViewName(variableResolver);
@@ -300,7 +301,11 @@ public void buildEnvVars(AbstractBuild, ?> build, Map env) {
} else {
String workspace = env.get("WORKSPACE");
if (workspace != null) {
- env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath);
+ if ( loadRulesForModuleRoot.length == 0 ) {
+ env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath);
+ } else {
+ env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath + PathUtil.fileSepForOS(isUnix) + loadRulesForModuleRoot[0]);
+ }
}
}
}
@@ -408,6 +413,7 @@ public Filter configureFilters(VariableResolver variableResolver, Abstra
String filterRegexp = "";
String[] viewPaths = getViewPaths(variableResolver, build, launcher, false);
+ loadRulesForModuleRoot = viewPaths;
if (viewPaths != null) {
filterRegexp = getViewPathsRegexp(viewPaths, launcher.isUnix());
}
@@ -554,21 +560,37 @@ public String getLoadRulesForPolling() {
public String getMkviewOptionalParam() {
return mkviewOptionalParam;
}
-
+
@Override
public FilePath getModuleRoot(FilePath workspace) {
- return getModuleRoot(workspace, null);
+ return getModuleRoot(workspace, null);
}
@Override
public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) {
+ if (loadRulesForModuleRoot.length == 0) {
+ return getModuleRoot(workspace, build, null);
+ } else {
+ return getModuleRoot(workspace, build, loadRulesForModuleRoot);
+ }
+ }
+ public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] loadRulesForModuleRoot) {
if (useDynamicView) {
- String normViewName = getNormalizedViewName();
- return new FilePath(workspace.getChannel(), viewDrive).child(normViewName);
+ String normViewName = getNormalizedViewName();
+ if (loadRulesForModuleRoot == null){
+ return new FilePath(workspace.getChannel(), viewDrive).child(normViewName);
+ }
+ else {
+ return new FilePath(workspace.getChannel(), viewDrive).child(normViewName).child(loadRulesForModuleRoot[0]);
+ }
}
String normViewPath = getNormalizedViewPath();
if (normViewPath != null) {
- return workspace.child(normViewPath);
+ if (loadRulesForModuleRoot == null){
+ return workspace.child(normViewPath);
+ } else {
+ return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]);
+ }
}
if (build == null) {
normViewPath = getViewPath();
@@ -576,12 +598,16 @@ public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) {
normViewPath = getViewPath(new BuildVariableResolver(build));
}
if (normViewPath != null) {
- return workspace.child(normViewPath);
+ if (loadRulesForModuleRoot == null){
+ return workspace.child(normViewPath);
+ } else {
+ return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]);
+ }
}
// Should never happen, because viewName must not be null, and if viewpath is null, then it is made equal to viewName
throw new IllegalStateException("View path name cannot be null. There is a bug inside AbstractClearCaseScm.");
}
-
+
public int getMultiSitePollBuffer() {
return multiSitePollBuffer;
@@ -618,8 +644,7 @@ public String getViewPath(VariableResolver variableResolver) {
}
return normalized;
}
-
- /**
+ /**
* Return string array containing the paths in the view that should be used when polling for changes.
*
* @param variableResolver
diff --git a/src/main/webapp/loadrules.html b/src/main/webapp/loadrules.html
index 3564d07b..7f70c270 100644
--- a/src/main/webapp/loadrules.html
+++ b/src/main/webapp/loadrules.html
@@ -34,8 +34,9 @@
An individual load rule can specify a file or a directory. A load rule that specifies a directory
loads the directory and all its contents (files and subdirectories). A load rule that
specifies a file loads only the specified file. To load all resources in a VOB or a component,
- create a load rule that specifies the root directory of the
- VOB or component.
+ create a load rule that specifies the root directory of the VOB or component.
+ The load rule placed in the first line is to determine this checked-out root directory
+ (usually where pom.xml, build.xml and so on exists).
For dynamic views, the load rules will be used to determine the