Index: codegen/src/main/java/org/exolab/castor/builder/SourceGenerator.java =================================================================== --- codegen/src/main/java/org/exolab/castor/builder/SourceGenerator.java (revision 8386) +++ codegen/src/main/java/org/exolab/castor/builder/SourceGenerator.java (working copy) @@ -413,6 +413,15 @@ } /** + * Sets the destination directory for resources, e.g. '.castor.cdr' files. + * + * @param destDir the destination directory for resources. + */ + public final void setResourceDestinationDirectory(final String destinationDirectory) { + _singleClassGenerator.setResourceDestinationDirectory(destinationDirectory); + } + + /** * Sets whether or not to create the XML marshaling framework specific * methods (marshal, unmarshal, validate) in the generated classes. By * default, these methods are generated. Index: codegen/src/main/java/org/exolab/castor/builder/SingleClassGenerator.java =================================================================== --- codegen/src/main/java/org/exolab/castor/builder/SingleClassGenerator.java (revision 8386) +++ codegen/src/main/java/org/exolab/castor/builder/SingleClassGenerator.java (working copy) @@ -95,7 +95,11 @@ /** True if the user should be prompted to overwrite when a file already exists. */ private boolean _promptForOverwrite = true; /** Destination directory where all our output goes. */ - private String _destDir = null; + private String _destDir; + /** + * Destination directory for all resource files (e.g. .castor.cdr files). + */ + private String _resourceDestinationDirectory; /** The line separator to use for output. */ private String _lineSeparator = null; /** A flag indicating whether or not to create descriptors for the generated classes. */ @@ -196,9 +200,21 @@ */ public void setDestDir(final String destDir) { _destDir = destDir; + if (_resourceDestinationDirectory == null) { + _resourceDestinationDirectory = destDir; + } } /** + * Sets the destination directory for generated resources. + * + * @param destDir the destination directory. + */ + public void setResourceDestinationDirectory(final String destinationDirectory) { + _resourceDestinationDirectory = destinationDirectory; + } + + /** * Sets the line separator to use when printing the source code. * * @param lineSeparator @@ -534,7 +550,7 @@ */ private void updateCDRFile(final JClass jClass, final JClass jDesc, final SGStateInfo sInfo, final String cdrFileName) throws IOException { - String entityFilename = jClass.getFilename(_destDir); + String entityFilename = jClass.getFilename(_resourceDestinationDirectory); File file = new File(entityFilename); File parentDirectory = file.getParentFile(); File cdrFile = new File(parentDirectory, cdrFileName);