[hibernate-commits] Hibernate SVN: r10822 - in branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool: . hbm2x hbm2x/doc

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Nov 16 12:32:18 EST 2006


Author: max.andersen at jboss.com
Date: 2006-11-16 12:32:12 -0500 (Thu, 16 Nov 2006)
New Revision: 10822

Modified:
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
Log:
don't use copy for text files to avoid user overriding the templates by having an old hibernate-tools.jar in their eclipse classpath

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java	2006-11-16 16:56:49 UTC (rev 10821)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java	2006-11-16 17:32:12 UTC (rev 10822)
@@ -5,7 +5,7 @@
 
 final public class Version {
 
-	public static final String VERSION = "3.2.0.beta8";
+	public static final String VERSION = "3.2.0.snapshotb9";
 	
 	private static final Version instance = new Version();
 	

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java	2006-11-16 16:56:49 UTC (rev 10821)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java	2006-11-16 17:32:12 UTC (rev 10822)
@@ -5,6 +5,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -287,20 +288,20 @@
         try {
             DocFile cssStylesDocFile = docFileManager.getCssStylesDocFile();
 
-            DocFileManager.copy(FILE_CSS_DEFINITION, cssStylesDocFile.getFile() );
+            processTemplate(Collections.EMPTY_MAP, FILE_CSS_DEFINITION, cssStylesDocFile.getFile());
 
             DocFile hibernateLogoDocFile = docFileManager.getHibernateImageDocFile();
 
-            DocFileManager.copy(FILE_HIBERNATE_IMAGE,
+            DocFileManager.copy(this.getClass().getClassLoader(), FILE_HIBERNATE_IMAGE,
                     hibernateLogoDocFile.getFile() );
 
             DocFile extendsImageDocFile = docFileManager.getExtendsImageDocFile();
                         
-            DocFileManager.copy(FILE_EXTENDS_IMAGE, extendsImageDocFile.getFile());
+            DocFileManager.copy(this.getClass().getClassLoader(), FILE_EXTENDS_IMAGE, extendsImageDocFile.getFile());
             
             DocFile mainIndexDocFile = docFileManager.getMainIndexDocFile();
 
-            DocFileManager.copy(FILE_INDEX, mainIndexDocFile.getFile() );
+            processTemplate(Collections.EMPTY_MAP, FILE_INDEX, mainIndexDocFile.getFile() );
         } 
         catch (IOException ioe) {
             throw new RuntimeException("Error while copying files.", ioe);

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java	2006-11-16 16:56:49 UTC (rev 10821)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java	2006-11-16 17:32:12 UTC (rev 10822)
@@ -7,6 +7,7 @@
 
 import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Reader;
@@ -85,6 +86,7 @@
         
     }
     
+    
     public class Templates {
     	    	
     	/*public String get(String name) {
@@ -287,5 +289,6 @@
 		catch (IOException e) {
 			throw new ExporterException("templateExists for " + templateName + " failed", e);
 		}
-    }  
+    }
+
 }

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java	2006-11-16 16:56:49 UTC (rev 10821)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java	2006-11-16 17:32:12 UTC (rev 10822)
@@ -475,27 +475,30 @@
     /**
      * Copy a File.
      * 
-     * TODO: this method ignores custom provided templatepath. Want to call velocity to get the resourceloaders but they are hidden, so we need another way.
-     *  
+     * TODO: this method ignores custom provided templatepath. Want to call freemarker to get the resourceloaders but they are hidden, so we need another way.
+     * ..and if we use currentthread classloader you might conflict with the projects tools.jar
+     * 
      * @param fileName the name of the file to copy.
      * @param to the target file.
      * 
      * @throws IOException in case of error.
      */
-    public static void copy(String fileName, File to) throws IOException {
+    public static void copy(ClassLoader loader, String fileName, File to) throws IOException {
         InputStream is = null;
         FileOutputStream out = null;
         try {
-            ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 
+            /*ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 
             if (classLoader == null) {
                 classLoader = DocFileManager.class.getClassLoader();			
             }
 			
-			is = classLoader.getResourceAsStream(fileName);
-            if (is == null && classLoader!=DocFileManager.class.getClassLoader() ) {
+			is = classLoader.getResourceAsStream(fileName);*/
+        	
+            /*if (is == null && classLoader!=DocFileManager.class.getClassLoader() ) {
 				is = DocFileManager.class.getClassLoader().getResourceAsStream(fileName); // HACK: workaround since eclipse for some reason doesnt provide the right classloader;
 				
-            } 
+            } */
+        	is = loader.getResourceAsStream( fileName );
 			
 			if(is==null) {
                 throw new IllegalArgumentException("File not found: "




More information about the hibernate-commits mailing list