GAQ SourceForge
An Open Source Process Automation tool.

Groovy               Ant            Quartz            License



GAQ is a lightweight framework for developing, scheduling, running and reviewing automated tasks. It combines the scripting ease of Groovy, the power of Ant, and the cross platform scheduling of Quartz. Since all of these tools are based on Java, GAQ highly portable.

So what is it really? It's an open source tool that makes it easy to schedule and run Groovy scripts. These scripts need to implement an execute() method which gets called based on a simple schedule definition. This method can call any Ant task, thus all the power of Ant is at hand. This includes calling Ant tasks (e.g. mkdir) directly, calling existing Ant build scripts or calling batch files (e.g., exec). The results are logged using log4j which defaults to saving output to the console and a log file. This log file can easily be imported into Excel or Open Office to be viewed, filtered, saved, etc.

Once GAQ (and Groovy, Ant, Quartz, and JDK 1.5) are installed, you just need to write a Groovy script, define a schedule in a GAQ xml configuration file, and then call the GAQ Main class passing in a reference to the configuration file.

Multiple copies of GAQ can be run at the same time on the same or different computers with the output going to a common log file. (Each GAQ instance that is writing to the same log file shold have it's own name. This name is included in the logged output.

In the GAQ configuration file you can specify for each task a list of emails that will get notified if the task is successful, and another list if there is a failure. (NOTE: The email feature has not been implemented yet.) In addition, you can specify a properties file that will be read in at task run-time and passed to the execute() method.

Here's an example of a GAQ Groovy script:

 
    import groovy.util.AntBuilder
    import java.util.Properties
    import org.apache.log4j.Logger
    
    class BuildProjectX {
        
        public void execute(AntBuilder ant,
                            Properties properties,
                            Logger     logger) {

            String myBuildDir  = "C:/projectx/build"
            String mySourceDir = "C:/projectx/src"
            String myDistDir   = "C:/projectx/dist"
            String myDocDir    = "C:/documentation/projectx"
             
            ant.mkdir(dir: myBuildDir)

            ant.delete()
                {fileset (dir: myBuildDir, includes: "**/**/*.*")}
        
            ant.javac(srcdir: mySourceDir,
                      destdir: myBuildDir,
                      includes: "**/*.java,examples/Simple.java")

            ant.copy(todir: myBuildDir) 
                  {fileset(dir: myDocDir, 
                           includes: "**/License.txt,**/*.bat,**/HowToRunProjectX.html")
                  }
               
            ant.jar(destfile: myDistDir + "projectx.jar",
                    basedir: myBuildDir,
                    excludes: "**/Test.class") 
        }
    }

Note how the ant commands are now like method calls as opposed to XML tags. The braces used with the ant commands (e.g., with the 'fileset' command) are placed similar to the "<" and ">" XML characters.

Below is an example of the GAQ configuration file to run this script. The log4j configuration file comes with GAQ. The taskSchedule is based on Quartz syntax. The schedule for task BuildProjectX says it will be run every day at 2 AM. The schedule for PeriodicTask says it should be run immediately and then every 1 hour, 20 minutes and 15 seconds. This periodic type of schedule (i.e., ss mm hh) is not standard Quartz schedule.

 <org.gaq.GaqConfiguration>
<gaqName>GAQ1</gaqName>

<log4jConfigurationFile>
C:/gaq/configuration/log4j-configuration-file.txt
</log4jConfigurationFile>

<schedules>
<org.gaq.Schedule>
<taskName>BuildProjectX</taskName>
<taskEnabled>true</taskEnabled>
<taskFileName>C:/ProjectX/Groovy/scripts/BuildProjectX.groovy</taskFileName>
<taskSchedule>* * 2 * * ?</taskSchedule>
<onSuccessEmail>myboss@gmail.com;hisboss@gmail.com</onSuccessEmail>
<onFailureEmail>justme@gmail.com</onFailureEmail>
</org.gaq.Schedule>

<org.gaq.Schedule>
<taskName>PeriodicTask</taskName>
<taskEnabled>true</taskEnabled>
<taskFileName>C:/Periodic/Groovy/scripts/Periodic.groovy</taskFileName>
<taskSchedule>15 20 1</taskSchedule>
<taskPropertiesFile>C:/Periodic/Groovy/scripts/periodic_properties.txt</taskPropertiesFile>
</org.gaq.Schedule>
</schedules>
</org.gaq.GaqConfiguration> Quartz provides lots of flexibility in defining schedules. See their documentation for more information.


Credits
   GAQ was developed by Jeff Grimshaw
   The GAQ icon and this webpage were developed by Andy Liles