Andrey Hihlovskiy
Professional blog on groovy, gradle, Java, Javascript and other stuff.
Tag Archives: script
groovy script for running jetty server
October 28, 2013
Posted by on The following script starts jetty server and opens the folder, specified on command line, for http access (read-only):
#!/usr/bin/env groovy @Grab('javax.servlet:javax.servlet-api:3.0.1') @Grab(group='org.eclipse.jetty', module='jetty-webapp', version='8.1.8.v20121106') @Grab(group='org.eclipse.jetty', module='jetty-server', version='8.1.8.v20121106', transitive=false) @Grab(group='org.eclipse.jetty', module='jetty-servlet', version='8.1.8.v20121106', transitive=false) @GrabExclude('org.eclipse.jetty.orbit:javax.servlet') import org.eclipse.jetty.server.Server import org.eclipse.jetty.servlet.* import groovy.servlet.* def publishedFolder = args ? args[0] : '.' def server = new Server(8080) def context = new ServletContextHandler(server, '/', ServletContextHandler.SESSIONS) def webappContext = new org.eclipse.jetty.webapp.WebAppContext(publishedFolder, '/jetty') context.setHandler(webappContext) server.start() println 'Jetty server started. Press Ctrl+C to stop.'
Usage:
- Save this script to file “jetty.groovy”
- Invoke on command-line:
groovy jetty.groovy /path/to/some/folder"
- Enter address in web-browser:
http://localhost:8080/jetty
Expected result: you see the content of the folder “/path/to/some/folder” in the web-browser.
Gradle script: multiproject git-gradle management
June 7, 2013
Posted by on Suppose you build your software project from many open-source components, most of which are already available via git. How to automate clone/pull/build/install cycle, especially across projects from different git-repositories? How to establish high-level inter-project dependencies?
For that I wrote gradle script, which implements multiproject git-gradle management. It works as follows: you write configuration file, name it “config.gradle”, put it to the same folder as “build.gradle” (of multiproject git-gradle) and then run “gradle build”.
Full documentation and sources are available at:
Script for mass checksum (MD5 and SHA1) calculation in the file system.
June 5, 2013
Posted by on I developed little gradle script, that delivers mass checksum (MD5 and SHA1) calculation for files in the specified folder (recursive to subfolders):
https://github.com/akhikhl/checksums
At the beginning that was more like exercise in using gradle for non-compilation tasks and in integrating apache-commons into gradle script.
Now, I think, I will do more gradle than bash, because gradle scripts are: a) portable b) have access to limitless power of all java libraries.
Recent Comments