Author: rich Date: Wed Jul 6 15:03:39 2005 New Revision: 209527 URL: http://svn.apache.org/viewcvs?rev=209527&view=rev Log: Changes to address http://issues.apache.org/jira/browse/BEEHIVE-845 : Need to be able to specify multiple content roots for Page Flow build
tests: bvt in netui (WinXP) BB: self (linux) Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java?rev=209527&r1=209526&r2=209527&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java Wed Jul 6 15:03:39 2005 @@ -1232,13 +1232,19 @@ // Look for the file out in the web-addressable portion of the webapp. // assert webappRelativePath.startsWith( "/" ) : webappRelativePath; - String webContentRoot = getWebContentRoot( env ); - File retVal = new File( webContentRoot + webappRelativePath ); + String[] webContentRoots = getWebContentRoots( env ); + + for ( int i = 0; i < webContentRoots.length; i++ ) + { + String webContentRoot = webContentRoots[i]; + File retVal = new File( webContentRoot + webappRelativePath ); + if ( retVal.exists() ) return retVal; + } // // If appropriate, look for the file under all the source roots. // - if ( ! retVal.exists() && lookInSourceRoots ) + if ( lookInSourceRoots ) { String[] webSourceRoots = getWebSourceRoots( env ); @@ -1250,7 +1256,7 @@ } } - return retVal; + return null; } public static String[] getWebSourceRoots( AnnotationProcessorEnvironment env ) @@ -1259,10 +1265,10 @@ return ( String[] ) getOption( "web.source.roots", true, env ); } - public static String getWebContentRoot( AnnotationProcessorEnvironment env ) + public static String[] getWebContentRoots( AnnotationProcessorEnvironment env ) throws FatalCompileTimeException { - return ( String ) getOption( "web.content.root", false, env ); + return ( String[] ) getOption( "web.content.root", true, env ); } public static String getWebBuildRoot( AnnotationProcessorEnvironment env ) Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java?rev=209527&r1=209526&r2=209527&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java Wed Jul 6 15:03:39 2005 @@ -480,12 +480,26 @@ private String getAlternateLocation( File strutsConfigFile ) throws XmlException, IOException, FatalCompileTimeException { - String webappContentRoot = CompilerUtils.getWebContentRoot( getEnv() ); - File webXmlFile = new File( webappContentRoot + '/' + StrutsApp.WEBINF_DIR_NAME + "/web.xml" ); + boolean canRead = false; + File webXmlFile = null; - if ( ! webXmlFile.canRead() ) + String[] webContentRoots = CompilerUtils.getWebContentRoots( getEnv() ); + for ( int i = 0; i < webContentRoots.length; i++ ) { - _diagnostics.addWarning( _jclass, "warning.could-not-read-web-xml", webappContentRoot ); + String webContentRoot = webContentRoots[i]; + webXmlFile = new File( webContentRoot + '/' + StrutsApp.WEBINF_DIR_NAME + "/web.xml" ); + + if ( webXmlFile.canRead() ) + { + canRead = true; + break; + } + } + + + if ( ! canRead ) + { + _diagnostics.addWarning( _jclass, "warning.could-not-read-web-xml" ); return null; } @@ -643,11 +657,15 @@ // // Look in the web content root. // - String webContentRoot = CompilerUtils.getWebContentRoot( getEnv() ); - - if ( filePath.startsWith( webContentRoot ) ) + String[] webContentRoots = CompilerUtils.getWebContentRoots( getEnv() ); + for ( int i = 0; i < webContentRoots.length; i++ ) { - return file.toString().substring( webContentRoot.length() ).replace( '\\', '/' ); + String webContentRoot = webContentRoots[i]; + + if ( filePath.startsWith( webContentRoot ) ) + { + return file.toString().substring( webContentRoot.length() ).replace( '\\', '/' ); + } } assert false : "could not calculate webapp-relative file from " + file; Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java?rev=209527&r1=209526&r2=209527&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java Wed Jul 6 15:03:39 2005 @@ -218,15 +218,21 @@ else { // Use the package name to infer the relative path (from web content root) to the page flow directory. - String webContentRoot = CompilerUtils.getWebContentRoot( env ); + String[] webContentRoots = CompilerUtils.getWebContentRoots( env ); String jpfParentRelativePath = ""; PackageDeclaration jpfPackage = outerClass.getPackage(); if ( jpfPackage != null ) jpfParentRelativePath = jpfPackage.getQualifiedName().replace( '.', '/' ); - File desiredParentDir = new File( webContentRoot, jpfParentRelativePath ); - fileToCheck = new File( desiredParentDir, filePath ); + + for ( int i = 0; i < webContentRoots.length; i++ ) + { + String webContentRoot = webContentRoots[i]; + File desiredParentDir = new File( webContentRoot, jpfParentRelativePath ); + fileToCheck = new File( desiredParentDir, filePath ); + if ( fileToCheck.exists() ) break; + } } - if ( ! fileToCheck.exists() && ! ( ignoreDirectories && fileToCheck.isDirectory() ) ) + if ( fileToCheck != null && ! fileToCheck.exists() && ! ( ignoreDirectories && fileToCheck.isDirectory() ) ) { fileExists = false; }