You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ky...@apache.org on 2004/08/30 17:27:07 UTC
svn commit: rev 37209 - in incubator/beehive/trunk/controls: drt drt/controls/org/apache/beehive/controls/test/composition src/runtime/org/apache/beehive/controls/runtime/generator
Author: kylem
Date: Mon Aug 30 08:27:06 2004
New Revision: 37209
Modified:
incubator/beehive/trunk/controls/drt/build.xml
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/composition/ComposerImpl.jcs
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptTask.java
Log:
Added now 'compileByExtension' option to the <apt> task that will run apt processing/compilation
sequentially on each of the input source extensions (the srcExtensions option value). This is
useful in scenarios where building one type of component might depend upon the output of others.
A common example of this is trying to compile a control implementation that references control
JavaBean types that are the result of processing other control types in the same project.
Updated the control DRT composition tests to exercise this option.
Modified: incubator/beehive/trunk/controls/drt/build.xml
==============================================================================
--- incubator/beehive/trunk/controls/drt/build.xml (original)
+++ incubator/beehive/trunk/controls/drt/build.xml Mon Aug 30 08:27:06 2004
@@ -88,7 +88,7 @@
<include name="**/checker/*.java"/>
</apt>
<apt srcdir="${controls.src}" destdir="${build.beans}" gendir="${build.beansrc}"
- classpathref="drt.classpath"
+ classpathref="drt.classpath" compileByExtension="true"
srcExtensions="*.java,*.jcx,*.jcs" >
</apt>
<!-- Do control assembly. -->
Modified: incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/composition/ComposerImpl.jcs
==============================================================================
--- incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/composition/ComposerImpl.jcs (original)
+++ incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/composition/ComposerImpl.jcs Mon Aug 30 08:27:06 2004
@@ -12,7 +12,9 @@
import org.apache.beehive.controls.api.properties.PropertySet;
import org.apache.beehive.controls.test.properties.Props;
+import org.apache.beehive.controls.test.properties.PropsBean;
import org.apache.beehive.controls.test.properties.PropsExtension;
+import org.apache.beehive.controls.test.properties.PropsExtensionBean;
@ControlImplementation
public class ComposerImpl implements Composer
@@ -21,23 +23,23 @@
@Control
@Props.SimpleProps(simpleString="A field annotation value")
- Props propControl;
+ PropsBean propControl;
@Control
@PropsExtension.SimpleProps(simpleString="A different field annotation value")
- private PropsExtension propExtControl;
+ private PropsExtensionBean propExtControl;
@Nested.Index(1)
- private @Control Nested nested1;
+ private @Control NestedBean nested1;
@Nested.Index(2)
- /* package */@Control Nested nested2;
+ /* package */@Control NestedBean nested2;
@Nested.Index(3)
- protected @Control Nested nested3;
+ protected @Control NestedBean nested3;
@Nested.Index(4)
- public @Control Nested nested4;
+ public @Control NestedBean nested4;
/**
* Provides a simple test API to externally query the PropertySet values on a
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptTask.java
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptTask.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptTask.java Mon Aug 30 08:27:06 2004
@@ -83,10 +83,20 @@
}
/**
+ * The compileByExtension attribute causes each input source extension to be compiled
+ * independently (and sequentially). This is useful when one type of extensio can
+ * possibly depend upon the generation output from another. The default value 'false'.
+ */
+ public void setCompileByExtension(boolean compileByExt)
+ {
+ _compileByExt = compileByExt;
+ }
+
+ /**
* Override the implementation of scanDir, to look for additional files based upon any
* specified source extensions
*/
- protected void scanDir(File srcDir, File destDir, String[] files)
+ protected void scanDir(File srcDir, File destDir, String[] files, String ext)
{
// If no source path was specified, we effectively created one by adding the generation
// path. Because of this, we need to be sure and add all source dirs to the path too.
@@ -97,63 +107,51 @@
setSourcepath(srcPath);
}
- if (_srcExts.size() == 0)
+ GlobPatternMapper m = new GlobPatternMapper();
+ m.setFrom(ext);
+ m.setTo("*.class");
+ SourceFileScanner sfs = new SourceFileScanner(this);
+ if (ext.equals("*.java"))
{
- super.scanDir(srcDir, destDir, files);
- return;
- }
-
- //for (String ext : _srcExts)
- //{
- for (int i = 0; i < _srcExts.size(); i++)
- {
- String ext = (String)_srcExts.get(i);
- GlobPatternMapper m = new GlobPatternMapper();
- m.setFrom(ext);
- m.setTo("*.class");
- SourceFileScanner sfs = new SourceFileScanner(this);
- if (ext.equals("*.java"))
+ File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
+ if (newFiles.length > 0)
{
- File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
- if (newFiles.length > 0)
- {
- File[] newCompileList = new File[compileList.length + newFiles.length];
- System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
- System.arraycopy(newFiles, 0, newCompileList, compileList.length,
- newFiles.length);
- compileList = newCompileList;
- }
+ File[] newCompileList = new File[compileList.length + newFiles.length];
+ System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
+ System.arraycopy(newFiles, 0, newCompileList, compileList.length,
+ newFiles.length);
+ compileList = newCompileList;
}
- else
+ }
+ else
+ {
+ String [] newSources = sfs.restrict(files, srcDir, destDir, m);
+ int extLen = ext.length() - 1; // strip wildcard
+ if (newSources.length > 0)
{
- String [] newSources = sfs.restrict(files, srcDir, destDir, m);
- int extLen = ext.length() - 1; // strip wildcard
- if (newSources.length > 0)
+ File[] newCompileList = new File[compileList.length + newSources.length];
+ System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
+ try
{
- File[] newCompileList = new File[compileList.length + newSources.length];
- System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
- try
- {
- FileUtils fileUtils = FileUtils.newFileUtils();
- for (int j = 0; j < newSources.length; j++)
- {
- String toName =
- newSources[j].substring(0, newSources[j].length() - extLen) +
- ".java";
-
- File srcFile = new File(srcDir, newSources[j]);
- File dstFile = new File(_genDir, toName);
- fileUtils.copyFile(srcFile, dstFile, null, true, true);
- newCompileList[compileList.length + j] = dstFile;
- }
- }
- catch (IOException ioe)
+ FileUtils fileUtils = FileUtils.newFileUtils();
+ for (int j = 0; j < newSources.length; j++)
{
- throw new BuildException("Unable to copy " + ext + " file", ioe,
- getLocation());
+ String toName =
+ newSources[j].substring(0, newSources[j].length() - extLen) +
+ ".java";
+
+ File srcFile = new File(srcDir, newSources[j]);
+ File dstFile = new File(_genDir, toName);
+ fileUtils.copyFile(srcFile, dstFile, null, true, true);
+ newCompileList[compileList.length + j] = dstFile;
}
- compileList = newCompileList;
}
+ catch (IOException ioe)
+ {
+ throw new BuildException("Unable to copy " + ext + " file", ioe,
+ getLocation());
+ }
+ compileList = newCompileList;
}
}
}
@@ -165,6 +163,10 @@
throw new BuildException("Missing genDir attribute: must be set to codegen output directory", getLocation());
+ // If no source extension specified, then just process .java files
+ if (_srcExts.size() == 0)
+ _srcExts.add("*.java");
+
// Save whether a user sourcepath was provided
_hasSourcepath = getSourcepath() != null;
@@ -190,36 +192,44 @@
checkParameters();
resetFileLists();
- // scan source directories and dest directory to build up
- // compile lists
- String[] list = getSrcdir().list();
- File destDir = getDestdir();
- for (int i = 0; i < list.length; i++)
+ // Iterate through the list of input extensions, matching/dependency checking based
+ // upon the input list.
+ for (int j = 0; j < _srcExts.size(); j++)
{
- File srcDir = getProject().resolveFile(list[i]);
- if (!srcDir.exists()) {
- throw new BuildException("srcdir \""
- + srcDir.getPath()
- + "\" does not exist!", getLocation());
- }
-
- //
- // The base <javac> algorithm is tweaked here, to allow <src> elements
- // to contain a list of files _or_ a list of directories to scan.
- //
+ String ext = (String)_srcExts.get(j);
Vector<File> inputFiles = new Vector<File>();
- if (srcDir.isDirectory())
- {
- DirectoryScanner ds = this.getDirectoryScanner(srcDir);
- String[] files = ds.getIncludedFiles();
- scanDir(srcDir, destDir != null ? destDir : srcDir, files);
- }
- else
+
+ // scan source directories and dest directory to build up
+ // compile lists
+ String[] list = getSrcdir().list();
+ File destDir = getDestdir();
+ for (int i = 0; i < list.length; i++)
{
+ File srcFile = getProject().resolveFile(list[i]);
+ if (!srcFile.exists()) {
+ throw new BuildException("srcdir \""
+ + srcFile.getPath()
+ + "\" does not exist!", getLocation());
+ }
+
//
- // BUGBUG: Because these bypass scanning, they also bypass dependency chks :(
+ // The base <javac> algorithm is tweaked here, to allow <src> elements
+ // to contain a list of files _or_ a list of directories to scan.
//
- inputFiles.add(srcDir);
+ if (srcFile.isDirectory())
+ {
+ DirectoryScanner ds = this.getDirectoryScanner(srcFile);
+ String[] files = ds.getIncludedFiles();
+ scanDir(srcFile, destDir != null ? destDir : srcFile, files, ext);
+ }
+ else
+ {
+ //
+ // BUGBUG: Because these bypass scanning, they also bypass dependency chks :(
+ //
+ if (srcFile.getPath().endsWith(ext.substring(1)))
+ inputFiles.add(srcFile);
+ }
}
if (inputFiles.size() != 0)
@@ -227,14 +237,30 @@
File[] newCompileList = new File[compileList.length + inputFiles.size()];
inputFiles.toArray(newCompileList);
System.arraycopy(compileList, 0, newCompileList, inputFiles.size(),
- compileList.length);
+ compileList.length);
compileList = newCompileList;
}
+
+ //
+ // If processing/compiling on a per-extension basis, then handle the current list,
+ // then reset the list fo files to compile before moving to the next extension
+ //
+ if (_compileByExt)
+ {
+ compile();
+ resetFileLists();
+ }
}
- compile();
+
+ //
+ // If not processing on a per-extension basis, then compile the entire aggregated list
+ //
+ if (!_compileByExt)
+ compile();
}
protected boolean _nocompile = false;
+ protected boolean _compileByExt = false;
protected boolean _hasSourcepath;
protected File _genDir;
protected Vector/*<String>*/ _srcExts = new Vector/*<String>*/();