Author: tfischer
Date: Mon Sep 16 21:02:07 2013
New Revision: 1523806
URL: http://svn.apache.org/r1523806
Log:
TORQUE-292 create extra cache dir to store checksum files
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/CustomProjectPaths.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/Maven2ProjectPaths.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/ProjectPaths.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ClasspathConfigurationProviderTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/DirectoryConfigurationProviderTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/JarConfigurationProviderTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java
Mon Sep 16 21:02:07 2013
@@ -67,9 +67,19 @@ public class UnitConfiguration
*/
private final Map<String, File> outputDirectoryMap = new HashMap<String,
File>();
- /** A directory where the Torque generator can store internal files. */
+ /**
+ * A work directory where the Torque generator can store internal files.
+ * These files should remain intact between generation runs.
+ */
private File workDirectory;
+ /**
+ * A cache directory where the Torque generator can store internal files.
+ * These files can be removed between generation runs, however removal
+ * may lead to a longer generation.
+ */
+ private File cacheDirectory;
+
/** The Loglevel for generation. */
private Loglevel loglevel = Loglevel.INFO;
@@ -236,7 +246,7 @@ public class UnitConfiguration
}
/**
- * Returns the directory where the generator can store internal files.
+ * Returns the work directory where the generator can store internal files.
*
* @return the directory where the generator can store internal files,
* not null.
@@ -254,7 +264,7 @@ public class UnitConfiguration
}
/**
- * Sets the directory where the generator can store internal files.
+ * Sets the work directory where the generator can store internal files.
*
* @param workDirectory the work directory, not null.
*
@@ -270,6 +280,40 @@ public class UnitConfiguration
}
/**
+ * Returns the cache directory where the generator can store internal
files.
+ *
+ * @return the directory where the generator can store internal files,
+ * not null.
+ *
+ * @throws IllegalStateException if the target directory was not yet set.
+ */
+ public File getCacheDirectory()
+ {
+ if (cacheDirectory == null)
+ {
+ throw new IllegalStateException(
+ "cacheDirectory is not initialized");
+ }
+ return cacheDirectory;
+ }
+
+ /**
+ * Sets the cache directory where the generator can store internal files.
+ *
+ * @param cacheDirectory the work directory, not null.
+ *
+ * @throws NullPointerException if workDirectory is null.
+ */
+ public void setCacheDirectory(final File cacheDirectory)
+ {
+ if (cacheDirectory == null)
+ {
+ throw new NullPointerException("cacheDirectory cannot be null");
+ }
+ this.cacheDirectory = cacheDirectory;
+ }
+
+ /**
* Sets the output activities of the associated configuration unit.
*
* @param outputList the output activities, not null.
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
Mon Sep 16 21:02:07 2013
@@ -93,6 +93,8 @@ class UnitConfigurationReader
unitDescriptor.getProjectPaths().getOutputDirectoryMap());
unitConfiguration.setWorkDirectory(
unitDescriptor.getProjectPaths().getWorkDirectory());
+ unitConfiguration.setCacheDirectory(
+ unitDescriptor.getProjectPaths().getCacheDirectory());
unitConfiguration.setOverrideSourceProvider(
unitDescriptor.getOverrideSourceProvider());
unitConfiguration.setClassLoader(unitDescriptor.getClassLoader());
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/CustomProjectPaths.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/CustomProjectPaths.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/CustomProjectPaths.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/CustomProjectPaths.java
Mon Sep 16 21:02:07 2013
@@ -49,11 +49,16 @@ public class CustomProjectPaths implemen
private Map<String, File> outputDirectoryMap = new HashMap<String,
File>();
/**
- * The directory where the torque generator can store internal files.
+ * The work directory where the torque generator can store internal files.
*/
private File workDir;
/**
+ * The cache directory where the torque generator can store internal files.
+ */
+ private File cacheDir;
+
+ /**
* Copy-constructor.
* @param toCopy the default project paths to copy, not null.
*
@@ -67,6 +72,7 @@ public class CustomProjectPaths implemen
this.outputDirectoryMap = new HashMap<String, File>(
toCopy.getOutputDirectoryMap());
this.workDir = toCopy.getWorkDirectory();
+ this.cacheDir = toCopy.getCacheDirectory();
}
/**
@@ -81,7 +87,9 @@ public class CustomProjectPaths implemen
* @param outputDirectoryMap The output directories for the files,
* keyed by the output directory key. The directory with the key
* null is the default output directory.
- * @param workDir directory where the torque generator can store
+ * @param workDir work directory where the torque generator can store
+ * internal files.
+ * @param cacheDir cache directory where the torque generator can store
* internal files.
*/
public CustomProjectPaths(
@@ -89,13 +97,15 @@ public class CustomProjectPaths implemen
String configurationPackage,
File sourceDir,
Map<String, File> outputDirectoryMap,
- File workDir)
+ File workDir,
+ File cacheDir)
{
this.configurationDir = configurationDir;
this.configurationPackage = configurationPackage;
this.sourceDir = sourceDir;
this.outputDirectoryMap = new HashMap<String,
File>(outputDirectoryMap);
this.workDir = workDir;
+ this.cacheDir = cacheDir;
}
/**
@@ -164,10 +174,10 @@ public class CustomProjectPaths implemen
}
/**
- * Sets the directory where the torque generator can store internal files,
- * relative to the current directory, or absolute.
+ * Sets the work directory where the torque generator can store
+ * internal files, relative to the current directory, or absolute.
*
- * @param workDir the directory for internal files,
+ * @param workDir the work directory for internal files,
* null to invalidate the current setting.
*/
public void setWorkDir(File workDir)
@@ -176,6 +186,18 @@ public class CustomProjectPaths implemen
}
/**
+ * Sets the cache directory where the torque generator can store
+ * internal files, relative to the current directory, or absolute.
+ *
+ * @param cacheDir the cache directory for internal files,
+ * null to invalidate the current setting.
+ */
+ public void setCacheDir(File cacheDir)
+ {
+ this.cacheDir = cacheDir;
+ }
+
+ /**
* Returns the root directory for the Torque generator files,
* relative to the project root.
*
@@ -260,10 +282,10 @@ public class CustomProjectPaths implemen
}
/**
- * Returns the directory where the torque generator can store
+ * Returns the work directory where the torque generator can store
* internal files, relative to the project root.
*
- * @return the directory where the torque generator can store
+ * @return the work directory where the torque generator can store
* internal files, not null.
* @throws IllegalStateException if one of the required parameters
* is not set.
@@ -275,6 +297,21 @@ public class CustomProjectPaths implemen
}
/**
+ * Returns the cache directory where the torque generator can store
+ * internal files, relative to the project root.
+ *
+ * @return the cache directory where the torque generator can store
+ * internal files, not null.
+ * @throws IllegalStateException if one of the required parameters
+ * is not set.
+ */
+ public File getCacheDirectory()
+ {
+ checkInit();
+ return cacheDir;
+ }
+
+ /**
* Checks whether the current settings are valid.
* It is checked whether all necessary informations are set.
* If not, an IllegalStateException is thrown.
@@ -303,6 +340,11 @@ public class CustomProjectPaths implemen
throw new IllegalStateException(
"workDir must not be null.");
}
+ if (cacheDir == null)
+ {
+ throw new IllegalStateException(
+ "cacheDir must not be null.");
+ }
}
@Override
@@ -313,6 +355,7 @@ public class CustomProjectPaths implemen
+ ", sourceDir=" + sourceDir
+ ", outputDirectoryMap=" + outputDirectoryMap
+ ", workDir=" + workDir
+ + ", cacheDir=" + cacheDir
+ ")";
}
}
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/Maven2ProjectPaths.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/Maven2ProjectPaths.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/Maven2ProjectPaths.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/Maven2ProjectPaths.java
Mon Sep 16 21:02:07 2013
@@ -77,6 +77,12 @@ public abstract class Maven2ProjectPaths
= "src/main/torque-gen/work";
/**
+ * Default cache directory.
+ */
+ protected static final String CACHE_DIR
+ = "target/torque/cache";
+
+ /**
* The root directory of the whole maven2 project.
*/
private File projectRoot;
@@ -162,8 +168,8 @@ public abstract class Maven2ProjectPaths
}
/**
- * Returns the default subdirectory where the torque generator can store
- * internal files.
+ * Returns the default work subdirectory
+ * where the torque generator can store internal files.
*
* @return the work subdirectory, not null.
*/
@@ -173,6 +179,17 @@ public abstract class Maven2ProjectPaths
}
/**
+ * Returns the default cache subdirectory
+ * where the torque generator can store internal files.
+ *
+ * @return the work subdirectory, not null.
+ */
+ public File getCacheDirectory()
+ {
+ return new File(projectRoot, CACHE_DIR);
+ }
+
+ /**
* returns the root directory of the whole maven 2 project.
*
* @return the root directory of the whole project, not null.
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/ProjectPaths.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/ProjectPaths.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/ProjectPaths.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/paths/ProjectPaths.java
Mon Sep 16 21:02:07 2013
@@ -109,6 +109,7 @@ public interface ProjectPaths
/**
* Returns the work directory where the torque generator can store
* internal files.
+ * These files should remain intact between runs of generation.
*
* @return the work directory, not null.
*
@@ -116,4 +117,18 @@ public interface ProjectPaths
* is not valid.
*/
File getWorkDirectory();
+
+ /**
+ * Returns the cache directory where the torque generator can store
+ * internal files.
+ * These files can in principle be removed after each generation,
+ * however, removal of these files may result in a longer work
+ * of the generator.
+ *
+ * @return the cache directory, not null.
+ *
+ * @throws IllegalStateException if the current state of the object
+ * is not valid.
+ */
+ File getCacheDirectory();
}
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java
Mon Sep 16 21:02:07 2013
@@ -74,7 +74,7 @@ public class Controller
* The subdirectory in the work directory where last source changes
* are stored.
*/
- public static final String LAST_SOURCE_CHANGE_WORK_SUBDIR
+ public static final String LAST_SOURCE_CHANGE_CACHE_SUBDIR
= "last-source-changes";
/** The suffix for written checksum files. */
@@ -652,8 +652,8 @@ public class Controller
return true;
}
File lastChangesDir = new File(
- unitConfiguration.getWorkDirectory(),
- LAST_SOURCE_CHANGE_WORK_SUBDIR);
+ unitConfiguration.getCacheDirectory(),
+ LAST_SOURCE_CHANGE_CACHE_SUBDIR);
File lastChangesFile = new File(
lastChangesDir,
sourceFile.getName() + CHECKSUM_SUFFIX);
@@ -721,8 +721,8 @@ public class Controller
return;
}
File lastChangesDir = new File(
- unitConfiguration.getWorkDirectory(),
- LAST_SOURCE_CHANGE_WORK_SUBDIR);
+ unitConfiguration.getCacheDirectory(),
+ LAST_SOURCE_CHANGE_CACHE_SUBDIR);
if (!lastChangesDir.exists())
{
boolean dirCreationSuccessfull = lastChangesDir.mkdirs();
Modified:
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ClasspathConfigurationProviderTest.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ClasspathConfigurationProviderTest.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ClasspathConfigurationProviderTest.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ClasspathConfigurationProviderTest.java
Mon Sep 16 21:02:07 2013
@@ -56,7 +56,8 @@ public class ClasspathConfigurationProvi
"org.apache.torque.generator.test.readfromclasspath",
new File("src"),
outputDirMap,
- new File("work"));
+ new File("work"),
+ new File("cache"));
UnitDescriptor unitDescriptor = new UnitDescriptor(
UnitDescriptor.Packaging.CLASSPATH,
projectPaths,
Modified:
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/DirectoryConfigurationProviderTest.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/DirectoryConfigurationProviderTest.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/DirectoryConfigurationProviderTest.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/DirectoryConfigurationProviderTest.java
Mon Sep 16 21:02:07 2013
@@ -56,7 +56,8 @@ public class DirectoryConfigurationProvi
null,
new File("src"),
outputDirMap,
- new File("work"));
+ new File("work"),
+ new File("cache"));
directoryConfigurationProvider = new DirectoryConfigurationProvider(
projectPaths,
Modified:
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/JarConfigurationProviderTest.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/JarConfigurationProviderTest.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/JarConfigurationProviderTest.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/JarConfigurationProviderTest.java
Mon Sep 16 21:02:07 2013
@@ -56,7 +56,8 @@ public class JarConfigurationProviderTes
null,
new File("src"),
outputDirMap,
- new File("work"));
+ new File("work"),
+ new File("cache"));
jarConfigurationProvider = new JarConfigurationProvider(
projectPaths,
Modified:
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
Mon Sep 16 21:02:07 2013
@@ -476,7 +476,8 @@ public class ReadConfigurationTest exten
"org.apache.torque.generator.test.readfromclasspath",
new File("src"),
outputDirMap,
- new File("work"));
+ new File("work"),
+ new File("cache"));
UnitDescriptor unitDescriptor = new UnitDescriptor(
UnitDescriptor.Packaging.CLASSPATH,
projectPaths,
Modified:
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java?rev=1523806&r1=1523805&r2=1523806&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
(original)
+++
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
Mon Sep 16 21:02:07 2013
@@ -147,10 +147,10 @@ public class PropertyToJavaGenerationTes
{
// prepare
File targetDir = new File("target/test/propertyToJava");
- File workDir = new File("target/work/propertyToJava");
+ File cacheDir = new File("target/cache/propertyToJava");
File sourceDir = new File("target/source/propertyToJava");
FileUtils.deleteDirectory(targetDir);
- FileUtils.deleteDirectory(workDir);
+ FileUtils.deleteDirectory(cacheDir);
FileUtils.deleteDirectory(sourceDir);
FileUtils.copyDirectory(
new File("src/test/propertyToJava/src/main/torque-gen/src"),
@@ -161,7 +161,7 @@ public class PropertyToJavaGenerationTes
new Maven2DirectoryProjectPaths(
new File("src/test/propertyToJava")));
projectPaths.setOutputDirectory(null, targetDir);
- projectPaths.setWorkDir(workDir);
+ projectPaths.setCacheDir(cacheDir);
projectPaths.setSourceDir(sourceDir);
UnitDescriptor unitDescriptor = new UnitDescriptor(
UnitDescriptor.Packaging.DIRECTORY,
@@ -175,7 +175,6 @@ public class PropertyToJavaGenerationTes
File propertiesResultFile
= new File(targetDir, "Properties.properties");
assertTrue(propertiesResultFile.exists());
- long firstLastModified = propertiesResultFile.lastModified();
// delete target so we can see if generation does not run again
assertTrue(propertiesResultFile.delete());
@@ -199,10 +198,10 @@ public class PropertyToJavaGenerationTes
{
// prepare
File targetDir = new File("target/test/propertyToJava");
- File workDir = new File("target/work/propertyToJava");
+ File cacheDir = new File("target/cache/propertyToJava");
File sourceDir = new File("target/source/propertyToJava");
FileUtils.deleteDirectory(targetDir);
- FileUtils.deleteDirectory(workDir);
+ FileUtils.deleteDirectory(cacheDir);
FileUtils.deleteDirectory(sourceDir);
FileUtils.copyDirectory(
new File("src/test/propertyToJava/src/main/torque-gen/src"),
@@ -213,7 +212,7 @@ public class PropertyToJavaGenerationTes
new Maven2DirectoryProjectPaths(
new File("src/test/propertyToJava")));
projectPaths.setOutputDirectory(null, targetDir);
- projectPaths.setWorkDir(workDir);
+ projectPaths.setCacheDir(cacheDir);
projectPaths.setSourceDir(sourceDir);
UnitDescriptor unitDescriptor = new UnitDescriptor(
UnitDescriptor.Packaging.DIRECTORY,
@@ -230,7 +229,7 @@ public class PropertyToJavaGenerationTes
// change checksum file
File checksumFile = new File(
- workDir,
+ cacheDir,
"last-source-changes/propertiesData.properties.checksum");
long checksumFileLastModified = checksumFile.lastModified();
FileUtils.writeStringToFile(checksumFile, "abc", "ISO-8859-1");
@@ -258,10 +257,10 @@ public class PropertyToJavaGenerationTes
{
// prepare
File targetDir = new File("target/test/propertyToJava");
- File workDir = new File("target/work/propertyToJava");
+ File cacheDir = new File("target/cache/propertyToJava");
File sourceDir = new File("target/source/propertyToJava");
FileUtils.deleteDirectory(targetDir);
- FileUtils.deleteDirectory(workDir);
+ FileUtils.deleteDirectory(cacheDir);
FileUtils.deleteDirectory(sourceDir);
FileUtils.copyDirectory(
new File("src/test/propertyToJava/src/main/torque-gen/src"),
@@ -272,7 +271,7 @@ public class PropertyToJavaGenerationTes
new Maven2DirectoryProjectPaths(
new File("src/test/propertyToJava")));
projectPaths.setOutputDirectory(null, targetDir);
- projectPaths.setWorkDir(workDir);
+ projectPaths.setCacheDir(cacheDir);
projectPaths.setSourceDir(sourceDir);
UnitDescriptor unitDescriptor = new UnitDescriptor(
UnitDescriptor.Packaging.DIRECTORY,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]