build.gradle

208 lines | 5.498 kB Blame History Raw Download
apply plugin: 'java'
apply plugin: 'eclipse'

def getVersionName = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'describe', '--tags', '--abbrev=0'
        standardOutput = stdout
    }
    
    def out = stdout.toString().trim()
    println out
    return stdout.toString().trim()
}
version = getVersionName()
archivesBaseName = 'azkaban'
check.dependsOn.remove(test)

repositories {
  mavenCentral()
  mavenLocal()
}

configurations {
    all {
        // We don't want the kitchen sink for dependencies. Only the ones we know we need for
        // compile and ones we need to package.
        transitive = false
    }
    compile {
        description = 'compile classpath'
    }
    test {
        extendsFrom compile
    }
}
configurations.compile {
    description = 'compile classpath'
}

dependencies {
  compile (
    [group: 'commons-collections', name:'commons-collections', version: '3.2.1'],
    [group: 'commons-configuration', name:'commons-configuration', version: '1.8'],
    [group: 'commons-dbcp', name:'commons-dbcp', version: '1.4'],
    [group: 'commons-dbutils', name:'commons-dbutils', version: '1.5'],
    [group: 'org.apache.commons', name:'commons-email', version: '1.2'],
    [group: 'commons-fileupload', name:'commons-fileupload', version: '1.2.1'],
    [group: 'commons-io', name:'commons-io', version: '2.4'],
    [group: 'org.apache.commons', name:'commons-jexl', version: '2.1.1'],
    [group: 'commons-lang', name:'commons-lang', version: '2.6'],
    [group: 'commons-logging', name:'commons-logging', version: '1.1.1'],
    [group: 'commons-pool', name:'commons-pool', version: '1.6'],
    [group: 'com.google.guava', name:'guava', version: '13.0.1'],
    [group: 'com.h2database', name:'h2', version: '1.3.170'],
    [group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.2.1'],
    [group: 'org.apache.httpcomponents', name:'httpcore', version: '4.2.1'],
    [group: 'org.codehaus.jackson', name:'jackson-core-asl', version: '1.9.5'],
    [group: 'org.codehaus.jackson', name:'jackson-mapper-asl',version: '1.9.5'],
    [group: 'org.codehaus.jackson', name:'jackson-core-asl', version: '1.9.5'],
    [group: 'org.mortbay.jetty', name:'jetty', version: '6.1.26'],
    [group: 'org.mortbay.jetty', name:'jetty-util', version: '6.1.26'],
    [group: 'joda-time', name:'joda-time', version: '2.0'],
    [group: 'net.sf.jopt-simple', name:'jopt-simple', version: '4.3'],
    [group: 'log4j', name:'log4j', version: '1.2.16'],
    [group: 'javax.mail', name:'mail', version: '1.4.5'],
    [group: 'mysql', name:'mysql-connector-java', version: '5.1.28'],
    [group: 'javax.servlet', name:'servlet-api', version: '2.5'],
    [group: 'org.slf4j', name:'slf4j-api', version: '1.6.1'],
    [group: 'org.apache.velocity', name:'velocity', version: '1.7'],
    [group: 'org.apache.velocity', name:'velocity-tools', version: '2.0']
  )
  
  testCompile (
    [group: 'junit', name:'junit', version: '4.11']
  )
}

jar {
    baseName =  'azkaban'
    manifest {
      attributes(
        'Implementation-Title': 'Azkaban', 
        'Implementation-Version': version
      )
    }
}

eclipse.classpath.file {
    // Erase the whole classpath
    beforeMerged {
        classpath -> classpath.entries.removeAll { entry -> true }
    }
    
    // We want to make sure that if there is an entry for src, that it doesn't have any
    // include parameters
    whenMerged { classpath -> 
        classpath.entries.findAll { entry -> entry.kind == 'src' }*.includes = []
    }
}

sourceSets {
  main {
    java {
      srcDir 'src/java'
    }
    resources {
      // Used to include all vm's and property files in the src code
      srcDir 'src/java'
      include '**/*.vm'
      include '**/*.properties'
    }
  }
  test {
    java {
      srcDir 'unit/java'
    }
  }
}

/**
 * Invokes a makefile target that will compile less files
 */
task compileLess(type:Exec) {
    workingDir 'src/less'
    commandLine 'make', '-e'
    environment (
      OBJ_DIR : file(new File(buildDir,'/less'))
   )
}

/**
 * Invokes a makefile target that will compile dust files
 */
task compileDust(type:Exec) {
    workingDir 'src/tl'
    commandLine 'make', '-e'
    environment (
      OBJ_DIR : file(new File(buildDir,'/dust'))
   )
}

/**
 * Copies web files to a build directory
 */
task web(dependsOn: ['compileLess', 'compileDust']) << {
    println 'Copying web files'
    copy {
        from('src/web')
        into('build/web') 
    }

    copy {
        from('build/dust')
        into('build/web/js')
    }
    copy {
        from('build/less')
        into('build/web/css')
    }
}

/*
 * Gets the version name from the latest Git tag
 */
task createVersionFile() << {

}

task packageSolo(dependsOn: [jar, 'web', 'createVersionFile']) << {
    String packageDir = 'build/package/azkaban-solo-server'
 
    println 'Creating Azkaban Solo Server Package into ' + packageDir
    mkdir packageDir
    mkdir packageDir + '/extlib'
    mkdir packageDir + '/plugins'
    
    println 'Copying Soloserver bin & conf'
    copy {
        from('src/package/soloserver')
        into(packageDir)
    }
    
    println 'Copying Azkaban lib'
    copy {
        from('$buildDir/libs')
        into(packageDir + '/lib')
    }
    
    println 'Copying web'
    copy {
        from('$buildDir/web')
        into(packageDir + '/web')
    }

    println 'Copying sql'
    copy {
        from('src/sql')
        into(packageDir + '/sql')
    }

    println 'Copying dependency jars'
    copy {
        into packageDir + '/lib'
        from configurations.compile
    }
}