[jboss-cvs] JBossAS SVN: r106013 - in projects/jboss-jca/trunk/codegenerator/src/main: resources and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Jun 12 23:17:35 EDT 2010
Author: jeff.zhang
Date: 2010-06-12 23:17:35 -0400 (Sat, 12 Jun 2010)
New Revision: 106013
Modified:
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java
projects/jboss-jca/trunk/codegenerator/src/main/resources/build.xml.template
Log:
[JBJCA-355] copy all jars into generation lib directory and use this
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-06-13 03:16:47 UTC (rev 106012)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-06-13 03:17:35 UTC (rev 106013)
@@ -308,6 +308,8 @@
}
profile.generate(def);
+ copyAllJars(outputDir);
+
System.out.println(dbconf.getString("code.wrote"));
}
catch (IOException e)
@@ -317,6 +319,21 @@
}
/**
+ * copy all jars
+ * @param outputDir output directory
+ * @throws IOException ioException
+ */
+ private static void copyAllJars(String outputDir) throws IOException
+ {
+ File out = new File(outputDir);
+ String path = out.getAbsolutePath();
+ String sourcePath = path + File.separatorChar + ".." + File.separatorChar + ".." + File.separatorChar +
+ ".." + File.separatorChar + "lib";
+ String targetPath = path + File.separatorChar + "lib";
+ Utils.copyFolder(sourcePath, targetPath, "jar");
+ }
+
+ /**
* Input Properties
* @param classname belong to which java class
* @param dbconf ResourceBundle
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java 2010-06-13 03:16:47 UTC (rev 106012)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java 2010-06-13 03:17:35 UTC (rev 106013)
@@ -22,7 +22,10 @@
package org.jboss.jca.codegenerator;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FileWriter;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -178,4 +181,74 @@
throw new IOException("Could not delete " + f);
}
}
+
+ /**
+ * copy folders
+ *
+ * @param sourcePath source folder
+ * @param targetPath target folder
+ * @param filterName filter name
+ * @exception IOException Thrown if an error occurs
+ */
+ public static void copyFolder(String sourcePath, String targetPath, final String filterName) throws IOException
+ {
+ new File(targetPath).mkdirs();
+ File a = new File(sourcePath);
+ String[] file = a.list(new FilenameFilter()
+ {
+ public boolean accept(File dir, String fname)
+ {
+ if (dir.isDirectory())
+ return true;
+ return fname.endsWith(filterName);
+ }
+
+ });
+ File jarFile = null;
+ for (int i = 0; i < file.length; i++)
+ {
+ jarFile = new File(sourcePath + File.separator + file[i]);
+
+ if (jarFile.isFile())
+ {
+ FileInputStream from = null;
+ FileOutputStream to = null;
+ try
+ {
+ from = new FileInputStream(jarFile);
+ to = new FileOutputStream(targetPath + File.separator + jarFile.getName());
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+
+ while ((bytesRead = from.read(buffer)) != -1)
+ to.write(buffer, 0, bytesRead);
+ }
+ finally
+ {
+ if (from != null)
+ try
+ {
+ from.close();
+ }
+ catch (IOException e)
+ {
+ ;
+ }
+ if (to != null)
+ try
+ {
+ to.close();
+ }
+ catch (IOException e)
+ {
+ ;
+ }
+ }
+ }
+ if (jarFile.isDirectory())
+ {
+ copyFolder(sourcePath + File.separator + file[i], targetPath + File.separator + file[i], filterName);
+ }
+ }
+ }
}
Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/build.xml.template
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/build.xml.template 2010-06-13 03:16:47 UTC (rev 106012)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/build.xml.template 2010-06-13 03:17:35 UTC (rev 106013)
@@ -5,7 +5,7 @@
================================= -->
<property name="build.dir" value="${basedir}/build" />
<property name="target.dir" value="${basedir}/target" />
- <property name="lib.dir" value="${basedir}/../../../lib" />
+ <property name="lib.dir" value="${basedir}/lib" />
<path id="lib.path.id">
<fileset dir="${lib.dir}">
More information about the jboss-cvs-commits
mailing list