1 import org.jetbrains.jps.Jps
2 import org.jetbrains.jps.idea.IdeaProjectLoader
6 binding.setVariable("p", {String key ->
7 return getProperty(key) as String
10 binding.setVariable("guessJdk", {
11 String javaHome = p("java.home")
13 if (new File(javaHome).getName() == "jre") {
14 javaHome = new File(javaHome).getParent()
20 binding.setVariable("isMac", {
21 return System.getProperty("os.name").toLowerCase().startsWith("mac")
24 binding.setVariable("isDefined", {String key ->
29 catch (MissingPropertyException mpe) {
34 private String require(String key) {
38 catch (MissingPropertyException mpe) {
39 project.error("Property $key is required")
43 private String require(String key, String defaultValue) {
47 catch (MissingPropertyException mpe) {
48 project.info("$key is not defined. Defaulting to $defaultValue")
49 this[key] = defaultValue
53 binding.setVariable("requireProperty", {String key, String defaultValue = null ->
54 if (defaultValue == null) {
58 require(key, defaultValue)
62 binding.setVariable("guessHome", {
63 // Current file is supposed to be at build/scripts/release.gant path
64 new File(requireProperty("gant.file").substring("file:".length())).getParentFile().getParentFile().getParent()
67 binding.setVariable("loadProject", {
68 requireProperty("jdk", requireProperty("jdk15.home", guessJdk()))
69 new IdeaProjectLoader().loadFromPath(project, "${home}")
71 binding.ant.patternset(id: "idea.compiler.resources") {
72 exclude(name: "**/*.java")
73 exclude(name: "**/*.form")
74 exclude(name: "**/*.class")
75 exclude(name: "**/*.scala")
76 exclude(name: "**/*.groovy")
79 project["compiler.resources.id"] = "idea.compiler.resources"
82 project.modules.values().each {
83 it.classpath << project.resolve("$jdk/lib/tools.jar")
88 requireProperty("home", guessHome())
90 project.stagePrinter = { String message ->
91 println "##teamcity[progressMessage '$message']"