User: vharcq
Date: 02/03/01 13:14:23
Modified: core/src/xdoclet TemplateSubTask.java
Log:
Better support for timestamp(TS) checks done to guess if a generation is needed or
not.
1. For class we compare generated class TS to the tagged class as well as all its
superclasses. Then we look for template file TS. Then we look for merge files inside
this template
2. For file (xml dd) we compare generated file TS to the template file TS. then we
look for merge files inside this template. Then we look for tagged bean in source
path TS. Then we look for their superclasses TS.
Hope this is enough now
Revision Changes Path
1.26 +87 -8 xdoclet/core/src/xdoclet/TemplateSubTask.java
Index: TemplateSubTask.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/TemplateSubTask.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -w -r1.25 -r1.26
--- TemplateSubTask.java 23 Feb 2002 20:12:59 -0000 1.25
+++ TemplateSubTask.java 1 Mar 2002 21:14:23 -0000 1.26
@@ -30,7 +30,7 @@
*
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Sep 25, 2001
- * @version $Revision: 1.25 $
+ * @version $Revision: 1.26 $
*/
public class TemplateSubTask extends SubTask
{
@@ -439,7 +439,7 @@
cat.debug( "File exists." );
// Check modification timestamps
- if( !isGenerationNeeded( clazz, file ) )
+ if( !isGenerationNeeded( clazz, file, true ) )
return;
}
@@ -556,13 +556,16 @@
}
/**
+ * Test if a Java source mmust be generated or not depending of timestamp of
+ * elements involved.
+ *
* @param clazz the Class from wich we generate
* @param file the File that will be generated
- * @return true if generation is needed because of
- * Timestamp
+ * @param withTemplate
+ * @return true if generation is needed
* @exception XDocletException
*/
- private boolean isGenerationNeeded( ClassDoc clazz, File file )
+ private boolean isGenerationNeeded( ClassDoc clazz, File file, boolean
withTemplate )
throws XDocletException
{
Category cat = Log.getCategory( TemplateSubTask.class, "generation" );
@@ -638,26 +641,103 @@
supers = supers.superclass();
}
+ // 4. Check the timestamp of template file and merge files
+ if( withTemplate )
+ {
+ if( isGenerationNeeded( file, getTemplateURL() ) )
+ return true;
+ }
+
return false;
}
+ /**
+ * Verify if the generation of a file to generate is needed because either the
+ * Template used to generate the file have a later timestamp, or because ALL
+ * the Java sources imported in this task have a sooner timestamp. This is used
+ * to test if xml files generation is needed.
+ *
+ * @param file The file to check
+ * @return true if the generation is needed
+ * @exception XDocletException
+ */
private boolean isGenerationNeeded( File file )
throws XDocletException
{
Category cat = Log.getCategory( TemplateSubTask.class, "generation" );
+ if( cat.isDebugEnabled() )
+ cat.debug( "Generation need check for " + file.getName() );
+
+ // 1. Check the classpath for timestamp on XDOCLET JAR
+ File xdocletJar = getXdocletJar();
+
+ if( file.lastModified() < xdocletJar.lastModified() )
+ {
+ if( cat.isDebugEnabled() )
+ cat.debug( "Generation needed because of timestamp of
" + xdocletJar.getName() );
+ return true;
+ }
+ if( cat.isDebugEnabled() )
+ cat.debug( "Reject file because of timestamp of " +
xdocletJar.getName() );
+
+ if( cat.isDebugEnabled() )
+ cat.debug( "Generation need check for " + file.getName() );
+
+ // 2. Check the timestamp of template file and merge files
+ if( isGenerationNeeded( file, getTemplateURL() ) )
+ return true;
+
+ if( cat.isDebugEnabled() )
+ cat.debug( "Generation need check for " + file.getName() );
+
+ // 3. Check Timestamp of all java sources in sourcepath
ClassDoc[] classes = AbstractProgramElementTagsHandler.getAllClasses();
for( int i = 0; i < classes.length; i++ )
{
- if( isGenerationNeeded( classes[i], file ) )
+ if( isGenerationNeeded( classes[i], file, false ) )
{
return true;
}
}
+ return false;
+ }
+
+ /**
+ * Verify if the generation of a file is needed because either the template
+ * file has a sooner timestamp, or because one of the merge files have a sooner
+ * timestamp
+ *
+ * @param file The file to generate
+ * @param templateURL the Template file to use
+ * @return true if generation is needed.
+ * @exception XDocletException
+ */
+ private boolean isGenerationNeeded( File file, URL templateURL )
+ throws XDocletException
+ {
+ Category cat = Log.getCategory( TemplateSubTask.class, "generation" );
+
+ if( cat.isDebugEnabled() )
+ cat.debug( "Generation need check for " + file.getName() );
+
+ // 1. Check Timestamp of Template file
+ if( cat.isDebugEnabled() )
+ cat.debug( file.getName() + " " + getTemplateURL() );
+ if( file.lastModified() < new File( getTemplateURL().getFile()
).lastModified() )
+ {
+ if( cat.isDebugEnabled() )
+ cat.debug( "Generation needed because of timestamp of
" + getTemplateURL() );
+ return true;
+ }
+ if( cat.isDebugEnabled() )
+ cat.debug( "Reject file because of timestamp of " +
getTemplateURL() );
+
+ // 2. Check timestamp of Merge files found inside Template
getParser().setOutput( file );
- getParser().setTemplateURL( getTemplateURL() );
+ getParser().setTemplateURL( templateURL );
try
{
@@ -686,7 +766,6 @@
cat.debug( "Reject file because of timestamp
of " + files[i].getName() );
}
}
-
return false;
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel