<copy tofile="${deployments.root}/WEB-INF/reference.properties" \r
file="${basedir}/distrib/gitblit.properties"/>\r
\r
+ <!-- Copy the supported Groovy hook scripts -->\r
+ <mkdir dir="${deployments.root}/WEB-INF/groovy" />\r
+ <copy todir="${deployments.root}/WEB-INF/groovy">\r
+ <fileset dir="${basedir}/groovy">\r
+ <include name="sendmail.groovy" />\r
+ <include name="jenkins.groovy" />\r
+ </fileset>\r
+ </copy>\r
+ \r
<!-- Build the WAR web.xml from the prototype web.xml and gitblit.properties -->\r
<!-- THIS FILE IS NOT OVERRIDDEN ONCE IT IS BUILT!!! -->\r
<java classpath="${project.build.dir}" classname="com.gitblit.build.BuildWebXml">\r
List<String> names = new ArrayList<String>(userService.getAllUsernames());\r
return names;\r
}\r
- \r
+\r
/**\r
* Returns the list of all users available to the login service.\r
* \r
List<String> teams = new ArrayList<String>(userService.getAllTeamNames());\r
return teams;\r
}\r
- \r
+\r
/**\r
* Returns the list of available teams that a user or repository may be\r
* assigned to.\r
webxmlSettings.applyOverrides(overrideFile);\r
}\r
configureContext(webxmlSettings, true);\r
+\r
+ // Copy the included scripts to the configured groovy folder\r
+ File localScripts = getFileOrFolder(Keys.groovy.scriptsFolder, "groovy");\r
+ if (!localScripts.exists()) {\r
+ File includedScripts = new File(context.getRealPath("/WEB-INF/groovy"));\r
+ if (!includedScripts.equals(localScripts)) {\r
+ try {\r
+ com.gitblit.utils.FileUtils.copy(localScripts, includedScripts.listFiles());\r
+ } catch (IOException e) {\r
+ logger.error(MessageFormat.format(\r
+ "Failed to copy included Groovy scripts from {0} to {1}",\r
+ includedScripts, localScripts));\r
+ }\r
+ }\r
+ }\r
}\r
\r
serverStatus.servletContainer = servletContext.getServerInfo();\r
*/\r
package com.gitblit.utils;\r
\r
+import java.io.BufferedInputStream;\r
import java.io.BufferedReader;\r
import java.io.BufferedWriter;\r
import java.io.File;\r
import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
import java.io.FileOutputStream;\r
+import java.io.IOException;\r
import java.io.InputStreamReader;\r
import java.io.OutputStreamWriter;\r
import java.nio.charset.Charset;\r
}\r
return length;\r
}\r
+\r
+ /**\r
+ * Copies a file or folder (recursively) to a destination folder.\r
+ * \r
+ * @param destinationFolder\r
+ * @param filesOrFolders\r
+ * @return\r
+ * @throws FileNotFoundException\r
+ * @throws IOException\r
+ */\r
+ public static void copy(File destinationFolder, File... filesOrFolders)\r
+ throws FileNotFoundException, IOException {\r
+ destinationFolder.mkdirs();\r
+ for (File file : filesOrFolders) {\r
+ if (file.isDirectory()) {\r
+ copy(new File(destinationFolder, file.getName()), file.listFiles());\r
+ } else {\r
+ File dFile = new File(destinationFolder, file.getName());\r
+ BufferedInputStream bufin = null;\r
+ FileOutputStream fos = null;\r
+ try {\r
+ bufin = new BufferedInputStream(new FileInputStream(file));\r
+ fos = new FileOutputStream(dFile);\r
+ int len = 8196;\r
+ byte[] buff = new byte[len];\r
+ int n = 0;\r
+ while ((n = bufin.read(buff, 0, len)) != -1) {\r
+ fos.write(buff, 0, n);\r
+ }\r
+ } finally {\r
+ try {\r
+ bufin.close();\r
+ } catch (Throwable t) {\r
+ }\r
+ try {\r
+ fos.close();\r
+ } catch (Throwable t) {\r
+ }\r
+ }\r
+ dFile.setLastModified(file.lastModified());\r
+ }\r
+ }\r
+ }\r
}\r