Source

hg4idea / build.gradle

Full commit
apply plugin: 'java'
apply plugin: 'code-quality'

defaultTasks "clean", "dist"

version = new XmlParser().parse(file('META-INF/plugin.xml')).version.text()

final ideaHome = "$rootDir/idea-dev"
final testSandBoxDir = "$buildDir/idea-sandbox"
final explodedDistDir = "$buildDir/exploded"
final ideLibDir = "$rootDir/lib"

manifest.mainAttributes(
  "Build-By":System.getenv("USER"),
  "Bundle-Name":project.name,
  "Bundle-Version":version,
  "Bundle-License":"http://www.apache.org/licenses/LICENSE-2.0.txt"
)

repositories {
  mavenCentral()
}

dependencies {
  compile fileTree(dir: "$ideaHome/lib", includes: ['*.jar'])
  compile 'commons-io:commons-io:1.4'
  testCompile 'org.testng:testng:5.10:jdk15'
  testRuntime files("${System.getProperty("java.home")}/lib/tools.jar")
  testRuntime fileTree(dir: "$ideaHome/plugins", includes: ['**/*.jar'])
}

check {
  ant.properties['checkstyleHome'] = "$rootDir/config/checkstyle"
}

jar {
  metaInf {
    from "META-INF"
  }
}

test {
  useTestNG()
  jvmArgs = [
    "-Xbootclasspath/a:$ideaHome/lib/boot.jar",
    "-Didea.platform.prefix=Idea",
    "-Didea.config.path=$testSandBoxDir/config",
    "-Didea.system.path=$testSandBoxDir/system",
    "-Didea.plugins.path=$testSandBoxDir/plugins"
  ]
  dependsOn 'dist'
}

test.doFirst {
  ant.mkdir(dir: testSandBoxDir)
  ant.copy(todir: testSandBoxDir) {
    fileset(dir: "$rootDir/config/idea-sandbox")
  }
  ant.copy(todir: "$testSandBoxDir/plugins") {
    fileset(dir: explodedDistDir, includes: "${project.name}/lib/*.jar")
  }
}

task dist(dependsOn: jar) << {
  ant.mkdir(dir:"$explodedDistDir/${project.name}/lib")
  copy {
    from libsDir
    into "$explodedDistDir/${project.name}/lib"
    include '*.jar'
  }
  copy {
    from configurations.runtime.copyRecursive(DependencySpecs.type(Type.EXTERNAL)).files
    into "$explodedDistDir/${project.name}/lib"
  }
  ant.zip(
    destfile: "${buildDir}/${project.name}-${version}.zip",
    basedir: explodedDistDir
  )
}

task ide << {
  ant.delete(dir: ideLibDir)
  copy {
    from configurations.testRuntime.copyRecursive(DependencySpecs.type(Type.EXTERNAL)).files
    into ideLibDir
  }
}