Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Created October 24, 2009 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kiy0taka/217486 to your computer and use it in GitHub Desktop.
Save kiy0taka/217486 to your computer and use it in GitHub Desktop.
[Groovy] Generate new Gaelyk project for Eclipse
import java.util.zip.*
import org.tmatesoft.svn.core.internal.io.dav.*
import org.tmatesoft.svn.core.wc.*
import org.tmatesoft.svn.core.*
/*
Generate new Gaelyk project for Eclipse.
Usage: groovy GaelykSetup.groovy projectName [gaelykTemplateVersion]
*/
final DEFAULT_TEMPLATE_VERSION = 0.2
@Grab(group='com.svnkit', module='svnkit', version='1.1.0')
def setup(projectName, templateVersion) {
File.metaClass.plus = { String c -> new File(delegate, c) }
DAVRepositoryFactory.setup();
def dest = new File("./$projectName");
println "Downloading Gaelyk Eclipse addon."
def svnUrl = SVNURL.parseURIEncoded('http://gcrnagoya.googlecode.com/svn/trunk/gaelyk-eclipse-addon')
def client = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(true), null, null).updateClient
client.doExport(svnUrl, dest, SVNRevision.HEAD, SVNRevision.HEAD, null, false, true)
println "Downloading Gaelyk template project."
def zip = new ZipInputStream("http://cloud.github.com/downloads/glaforge/gaelyk/gaelyk-template-project-${templateVersion}.zip".toURL().openStream())
def entry
while (entry = zip.nextEntry) {
if (entry.directory) (dest + entry.name).mkdirs()
else dest + entry.name << zip
}
def replaceToProjectName = { file, word -> file.text = file.text.replaceAll(word, projectName) }
replaceToProjectName(dest + '.project', 'gaelyk-project')
replaceToProjectName(dest + 'war/WEB-INF/appengine-web.xml', 'myappid')
(dest + '.project-e').delete()
(dest + 'war/WEB-INF/appengine-web.xml-e').delete()
println "Complete!"
}
assert args.length > 0, "Project name is required."
setup(args[0], args.length > 2 ? args[1] : DEFAULT_TEMPLATE_VERSION)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment