| <project name="Plugin Publisher" default="verifyAndPublish"> |
| <!-- |
| External params: |
| eap - for getting idea from eap page |
| release - for getting idea from download site |
| version - idea version |
| expected.branch - "verifyAndPublish" target will work only if expected branches is equal to teamcity current branch |
| --> |
| |
| <property name="version" value="undefined-version"/> |
| <property name="expected.branch" value="master"/> |
| <property name="teamcity.build.branch" value="master"/> |
| |
| <property name="verify.dir" value="${basedir}/verify"/> |
| |
| <property name="kotlin.plugin.dir" value="${basedir}"/> |
| |
| <property name="kotlin.plugin.build.number" value="snapshot"/> |
| <property name="kotlin.plugin.url" value="http://localhost/"/> |
| |
| <condition property="download.eap"> |
| <isset property="eap"/> |
| </condition> |
| |
| <condition property="download.release"> |
| <or> |
| <isset property="release"/> |
| <not> |
| <isset property="download.eap"/> |
| </not> |
| </or> |
| </condition> |
| |
| <condition property="is.expected.branch"> |
| <equals arg1="${teamcity.build.branch}" arg2="${expected.branch}" /> |
| </condition> |
| |
| <property name="idea.eap.download.page.url" value="http://confluence.jetbrains.com/display/IDEADEV/IDEA+${version}+EAP"/> |
| <property name="idea.release.download.page.url" value="http://download.jetbrains.com/idea/ideaIC-${version}.tar.gz"/> |
| |
| <property name="plugin.repository.url" value="http://www.jetbrains.com/kotlin/eap-plugin-repository"/> |
| |
| <property name="updatePlugins.xml" value="updatePlugins.xml"/> |
| <property name="jdk16.home" value="${java.home}"/> |
| |
| <macrodef name="verifyPlugin"> |
| <attribute name="verify.plugin.path" /> |
| <attribute name="verify.against.idea.dir" /> |
| <attribute name="verifier.jar" /> |
| |
| <sequential> |
| <!-- Run plugin verifier --> |
| <java fork="true" failonerror="true" jar="@{verifier.jar}"> |
| <arg value="-r"/> |
| <arg value="${jdk16.home}"/> |
| <arg value="@{verify.plugin.path}"/> |
| <arg value="@{verify.against.idea.dir}"/> |
| </java> |
| </sequential> |
| </macrodef> |
| |
| <target name="setEapDownload" if="download.eap"> |
| <loadresource property="download.url"> |
| <url url="${idea.eap.download.page.url}"/> |
| <filterchain> |
| <tokenfilter> |
| <filetokenizer/> |
| <replaceregex pattern="^(.*)(https+://download\.jetbrains\.com/idea/ideaIC\-[\w\-\.]+tar\.gz)(.*)$" replace="\2" flags="s"/> |
| </tokenfilter> |
| </filterchain> |
| </loadresource> |
| </target> |
| |
| <target name="setReleasedDownload" if="download.release"> |
| <property name="download.url" value="${idea.release.download.page.url}" /> |
| </target> |
| |
| <target name="ideaDownload" depends="setEapDownload, setReleasedDownload" if="is.expected.branch"> |
| <echo message="From external parameters: ${download.eap} Release ${download.release} Version ${version}" /> |
| |
| <delete dir="${verify.dir}" /> |
| <mkdir dir="${verify.dir}" /> |
| |
| <!-- Download and extract IDEA --> |
| <echo message="Downloading IDEA from ${download.url}"/> |
| <get src="${download.url}" dest="${verify.dir}/ideaIC.tar.gz" usetimestamp="true"/> |
| |
| <!-- Ant 1.9.4+ may automatically un-gzip file when downloading it via "get" task. |
| It is out of our control. We need to know if we need to un-gzip downloaded file or not. --> |
| <condition property="compression.of.downloaded.tar.gz" value="gzip"> |
| <not><antversion atleast="1.9.4" /></not> |
| </condition> |
| <condition property="compression.of.downloaded.tar.gz" value="none"> |
| <antversion atleast="1.9.4" /> |
| </condition> |
| |
| <untar src="${verify.dir}/ideaIC.tar.gz" dest="${verify.dir}" overwrite="on" compression="${compression.of.downloaded.tar.gz}"/> |
| |
| <!-- Get extracted IDEA directory --> |
| <pathconvert property="idea.dir"> |
| <dirset dir="${verify.dir}"> |
| <include name="idea-IC-*"/> |
| </dirset> |
| </pathconvert> |
| |
| <!--suppress AntResolveInspection --> |
| <loadfile property="idea.version" srcfile="${idea.dir}/build.txt" /> |
| </target> |
| |
| <target name="verifyAndPublish" depends="ideaDownload" if="is.expected.branch"> |
| <mkdir dir="${verify.dir}" /> |
| |
| <!-- Get plugin verifier --> |
| <delete file="plugin-verifier.jar" failonerror="false"/> |
| <get src="${verifier.url}" dest="${verify.dir}/plugin-verifier.jar"/> |
| |
| <!-- Get kotlin plugin --> |
| <pathconvert property="kotlin.plugin.path"> |
| <fileset dir="${kotlin.plugin.dir}"> |
| <include name="kotlin-plugin-*"/> |
| </fileset> |
| </pathconvert> |
| <basename property="kotlin.plugin.filename" file="${kotlin.plugin.path}"/> |
| |
| <loadresource property="kotlin.plugin.version"> |
| <string value="${kotlin.plugin.filename}"/> |
| <filterchain> |
| <tokenfilter> |
| <filetokenizer/> |
| <replaceregex pattern="^kotlin-plugin-(\d+\.\d+\.\d+).zip$" replace="\1" flags="s"/> |
| </tokenfilter> |
| </filterchain> |
| </loadresource> |
| |
| <!--suppress AntResolveInspection --> |
| <echo message="Kotlin Plugin version is ${kotlin.plugin.version} located ${kotlin.plugin.path}"/> |
| |
| <!-- Verify both plugins --> |
| <verifyPlugin verifier.jar="${verify.dir}/plugin-verifier.jar" verify.against.idea.dir="${idea.dir}" verify.plugin.path="${kotlin.plugin.path}" /> |
| |
| <!-- Everything is ok, publish plugin and xml descriptor --> |
| <!--suppress AntResolveInspection --> |
| <echo message="##teamcity[buildStatus text='kotlin-${kotlin.plugin.version} has been verified against ${idea.version}']"/> |
| <echo message="##teamcity[publishArtifacts '${kotlin.plugin.path}']"/> |
| </target> |
| |
| <target name="generateUpdateXml"> |
| <echoxml file="updatePlugins.xml"> |
| <plugins> |
| <plugin id="org.jetbrains.kotlin" |
| url="${kotlin.plugin.url}" |
| version="${kotlin.plugin.build.number}" /> |
| </plugins> |
| </echoxml> |
| |
| <echo message="##teamcity[publishArtifacts 'updatePlugins.xml']" /> |
| </target> |
| </project> |