Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 1 | import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome |
| 2 | |
| 3 | setProperty("projectHome", guessHome(this as Script)) |
| 4 | setProperty("home", projectHome) |
| 5 | |
| 6 | includeTargets << new File("${projectHome}/build/scripts/utils.gant") |
| 7 | |
| 8 | setProperty("outDir", "${projectHome}/out/python") |
| 9 | setProperty("ideaDir", "${outDir}/ideaCE") |
| 10 | requireProperty("ideaPath", ideaDir) |
| 11 | |
| 12 | setProperty("pluginHelp", "${outDir}/help") |
| 13 | |
| 14 | setProperty("buildNumber", requireProperty("build.number", snapshot)) |
| 15 | setProperty("ideaBuildNumber", requireProperty("idea.build.number")) |
| 16 | |
| 17 | setProperty("ideaHomePacked", "${ideaDir}/jdk16") //compiled idea |
| 18 | setProperty("ideaHome", "${ideaDir}/jdk16/idea-IC-${ideaBuildNumber}") //compiled idea |
| 19 | |
| 20 | setProperty("pluginHome", "${projectHome}/python") |
| 21 | setProperty("pluginRevision", "${buildNumber}") |
| 22 | |
| 23 | setProperty("ideaLib", "${ideaHome}/lib") |
| 24 | setProperty("ideaPlugins", "${ideaHome}/plugins") //compiled plugins |
| 25 | |
| 26 | |
| 27 | setProperty("output", "${projectHome}/python/distCE") |
| 28 | |
| 29 | setProperty("zipdir", "${output}/zip") |
| 30 | setProperty("plugindir", "${zipdir}/python") |
| 31 | setProperty("zipname", "python-community-${pluginRevision}.zip") |
| 32 | |
| 33 | setProperty("srcDir", "${pluginHome}/src") |
| 34 | |
| 35 | setProperty("resourcesDir", "${pluginHome}/resources") |
| 36 | |
| 37 | setProperty("classesRootDir", "${outDir}/classes") |
| 38 | setProperty("classesDir", "${classesRootDir}/python") |
| 39 | |
| 40 | //Compiler options |
| 41 | setProperty("compilerDebug", "on") |
| 42 | setProperty("compilerGenerateNoWarnings", "off") |
| 43 | setProperty("compilerArgs", "") |
| 44 | setProperty("compilerMaxMemory", "256m") |
| 45 | |
| 46 | ant.patternset(id: "resources.pt") { |
| 47 | include(name: "**/?*.properties") |
| 48 | include(name: "**/?*.template") |
| 49 | include(name: "**/?*.xml") |
| 50 | include(name: "**/?*.gif") |
| 51 | include(name: "**/?*.png") |
| 52 | include(name: "**/?*.txt") |
| 53 | include(name: "**/?*.jpeg") |
| 54 | include(name: "**/?*.jpg") |
| 55 | include(name: "**/?*.html") |
| 56 | include(name: "**/?*.dtd") |
| 57 | include(name: "**/?*.tld") |
| 58 | include(name: "**/?*.py") |
| 59 | include(name: "**/?*.ft") |
| 60 | include(name: "**/?*.dic") |
| 61 | exclude(name: "**/plugin.xml") |
| 62 | } |
| 63 | |
| 64 | target(name: "clean", description: "Cleanup output") { |
| 65 | ant.echo("Cleaning ${output}") |
| 66 | ant.delete(dir: "${output}", failonerror: "false") |
| 67 | ant.echo("Cleaning ${classesRootDir}") |
| 68 | ant.delete(dir: "${classesRootDir}", failonerror: "false") |
| 69 | ant.echo("Cleaning ${ideaHome}") |
| 70 | ant.delete(dir: "${ideaHome}", failonerror: "false") // out/python/idea/ |
| 71 | } |
| 72 | |
| 73 | target(name: "unzip") { |
| 74 | ant.mkdir(dir: "${ideaHomePacked}") |
| 75 | ant.gunzip(src: "${ideaPath}/ideaIC-${ideaBuildNumber}.tar.gz") |
| 76 | ant.untar(src: "${ideaPath}/ideaIC-${ideaBuildNumber}.tar", dest: "${ideaHomePacked}") |
| 77 | } |
| 78 | |
| 79 | target(name: "compile", description: "Compile module python") { |
| 80 | depends("unzip") |
| 81 | |
| 82 | ant.path(id: "classpath.lib") { |
| 83 | fileset(dir: "${ideaLib}") { |
| 84 | include(name: "?*.jar") |
| 85 | } |
| 86 | fileset(dir: "${ideaPlugins}/terminal/lib") { |
| 87 | include(name: "*.jar") |
| 88 | } |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 89 | fileset(dir: "${ideaPlugins}/IntelliLang/lib") { |
| 90 | include(name: "*.jar") |
| 91 | } |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | ant.path(id: "sourcepath") { |
| 95 | dirset(dir: "${pluginHome}") { |
| 96 | include(name: "resources") |
| 97 | include(name: "src") |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 98 | include(name: "gen") |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 99 | include(name: "pluginSrc") |
| 100 | include(name: "pydevSrc") |
| 101 | include(name: "openapi/src") |
| 102 | include(name: "psi-api/src") |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 103 | include(name: "IntelliLang-python/src") |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | //The task requires the following libraries from IntelliJ IDEA distribution: |
| 107 | //javac2.jar; jdom.jar; asm.jar; asm-commons.jar |
| 108 | ant.taskdef(name: "javac2", classname: "com.intellij.ant.Javac2") { |
| 109 | classpath { |
| 110 | fileset(dir: "${ideaLib}") { |
| 111 | include(name: "?*.jar") |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | ant.mkdir(dir: "${classesDir}") |
| 117 | |
| 118 | //compile |
| 119 | ant.javac2(destdir: "${classesDir}", |
| 120 | debug: "${compilerDebug}", |
| 121 | nowarn: "${compilerGenerateNoWarnings}", |
| 122 | memorymaximumsize: "${compilerMaxMemory}", |
| 123 | fork: "true") { |
| 124 | compilerarg(line: "${compilerArgs}") |
| 125 | classpath(refid: "classpath.lib") |
| 126 | src(refid: "sourcepath") |
| 127 | } |
| 128 | |
| 129 | //copy resources |
| 130 | ant.copy(todir: "${classesDir}") { |
| 131 | fileset(dir: "${resourcesDir}") { |
| 132 | patternset(refid: "resources.pt") |
| 133 | type(type: "file") |
| 134 | } |
| 135 | fileset(dir: "${pluginHome}/src") { |
| 136 | patternset(refid: "resources.pt") |
| 137 | type(type: "file") |
| 138 | } |
| 139 | fileset(dir: "${pluginHome}/psi-api/resources") { |
| 140 | patternset(refid: "resources.pt") |
| 141 | type(type: "file") |
| 142 | } |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 143 | fileset(dir: "${pluginHome}/IntelliLang-python/src") { |
| 144 | patternset(refid: "resources.pt") |
| 145 | type(type: "file") |
| 146 | } |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 147 | fileset(dir: "${pluginHome}/resources") { |
| 148 | patternset(refid: "resources.pt") |
| 149 | type(type: "file") |
| 150 | } |
| 151 | fileset(dir: "${home}/colorSchemes/src") |
| 152 | } |
| 153 | |
| 154 | //copy plugin.xml |
| 155 | ant.mkdir(dir: "${classesDir}/META-INF") |
| 156 | ant.copy(todir: "${classesDir}/META-INF") { |
| 157 | fileset(file: "${pluginHome}/pluginSrc/META-INF/*.xml") |
| 158 | fileset(file: "${pluginHome}/pluginResources/META-INF/*.xml") |
| 159 | } |
| 160 | |
Tor Norbye | 0ecdb50 | 2014-02-19 09:43:01 -0800 | [diff] [blame] | 161 | ant.replace(file: "${classesDir}/META-INF/plugin.xml") { |
| 162 | replacefilter(token: "@@BUILD_NUMBER@@", value: "${buildNumber}") |
| 163 | } |
| 164 | |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 165 | ant.replaceregexp(file: "${classesDir}/META-INF/plugin.xml", |
| 166 | match: "since-build=\"\\d+\\.\\d+\"", |
| 167 | replace: "since-build=\"${ideaBuildNumber}\"") |
| 168 | } |
| 169 | |
| 170 | target(name: "jar", description: "Generate jar file") { |
| 171 | depends("compile") |
| 172 | ant.mkdir(dir: "${output}") |
| 173 | ant.jar(destfile: "${output}/python-community.jar", basedir: "${classesDir}") { |
| 174 | manifest() { |
| 175 | attribute(name: "Revision", value: "${pluginRevision}") |
| 176 | //<!--<attribute name="Build" value="${plugin.version}"/>--> |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | target(name: "zip", description: "Generate zip plugin file") { |
| 182 | depends("jar") |
| 183 | |
| 184 | ant.mkdir(dir: "${zipdir}") |
| 185 | |
| 186 | // copy plugin jar |
| 187 | ant.mkdir(dir: "${plugindir}/lib") |
| 188 | ant.move(file: "${output}/python-community.jar", todir: "${plugindir}/lib") |
| 189 | |
| 190 | ant.mkdir(dir: "${plugindir}/helpers") |
| 191 | ant.copy(todir: "${plugindir}/helpers") { |
| 192 | fileset(dir: "${pluginHome}/helpers") { |
| 193 | include(name: "**/*") |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | ant.mkdir(dir: "${plugindir}/help") |
| 198 | ant.copy(file: "${pluginHelp}/pytonpluginhelp.jar", tofile: "${plugindir}/help/pythonpluginhelp.jar", failonerror: false) |
| 199 | ant.copy(file: "${pluginHelp}/pytonpluginhelp_mac.jar", tofile: "${plugindir}/help/pythonpluginhelp_mac.jar", failonerror: false) |
| 200 | |
| 201 | ant.zip(basedir: "${zipdir}", destfile: "${output}/${zipname}") |
| 202 | } |
| 203 | |
| 204 | target(name: "build") { |
| 205 | depends("unzip") |
| 206 | depends("compile") |
| 207 | } |
| 208 | |
| 209 | target(name: "dist", description: "main target") { |
| 210 | depends("clean") |
| 211 | depends("build") |
| 212 | depends("zip") |
| 213 | } |
| 214 | |
| 215 | target('default': "Build artifacts") { |
| 216 | depends("dist") |
| 217 | } |