empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benni...@apache.org
Subject svn commit: r933334 - /incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
Date Mon, 12 Apr 2010 17:50:13 GMT
Author: benniven
Date: Mon Apr 12 17:50:13 2010
New Revision: 933334

URL: http://svn.apache.org/viewvc?rev=933334&view=rev
Log:
fix: in codegen, if no templateFolder is specified, it is set to "template", this is neccessary
as the "Database.vm" Template will use the config property "getTemplateFolder()" in order
to generate the nested classes.

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java?rev=933334&r1=933333&r2=933334&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
Mon Apr 12 17:50:13 2010
@@ -97,9 +97,10 @@ public class CodeGenWriter {
 		// http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#simpleexampleofacustomlogger
 		engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,
 				new CommonsLogLogChute());
-		if(useClasspathTemplates()){
+		if(config.getTemplateFolder() == null){
 			engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
 			engine.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName());
+			config.setTemplateFolder("templates");
 		}else{
 			File templateFolder = new File(config.getTemplateFolder());
 			if(!templateFolder.canRead()){
@@ -283,24 +284,10 @@ public class CodeGenWriter {
 		writeFile(file, RECORD_TEMPLATE, context);
 		return file;
 	}
-	
-	private boolean useClasspathTemplates(){
-		return config.getTemplateFolder() == null;
-	}
-	
-	private String templatePathFor(final String template){
-		String path;
-		if(useClasspathTemplates()){
-			path = "templates/" + template;
-		}else{
-			path = config.getTemplateFolder() + "/" + template;
-		}
-		return path;
-	}
 
 	private void writeFile(File file, String template,
 			VelocityContext context) {
-		String templatePath = templatePathFor(template);
+		String templatePath = config.getTemplateFolder()+ System.getProperty("file.separator")
+template;
 		Writer writer = null;
 		try {
 			log.info("Writing " + file);



Mime
View raw message