|
| 1 | + |
| 2 | +<project name="streamsx.slack" default="all"> |
| 3 | + <description>Build file for streamsx.slack project, built the toolkit, doc, release, test</description> |
| 4 | + |
| 5 | + <!-- check streams install and exit if there is a bad value in streams.install --> |
| 6 | + <property environment="env" /> |
| 7 | + <fail unless="env.STREAMS_INSTALL" message="No streams installation found. Exiting!"/> |
| 8 | + |
| 9 | + <!-- set global properties for this build --> |
| 10 | + <property name="toolkit.dir" value="com.ibm.streamsx.slack"/> |
| 11 | + <property name="doc.string" value="doc"/> |
| 12 | + <property name="doc.dir" value="${doc.string}/spldoc"/> |
| 13 | + <property name="samples.dir" value="samples"/> |
| 14 | + <property name="test.dir" value="tests"/> |
| 15 | + <property name="release.dir" value="release"/> |
| 16 | + <property name="release.info.file" value="${toolkit.dir}/build.info"/> |
| 17 | + |
| 18 | + <property name="tktitle" value="IBMStreams ${ant.project.name} Toolkit" /> |
| 19 | + <property name="tkauthor" value="IBMStreams Open Source Community at GitHub - https://github.com/IBMStreams/${ant.project.name}" /> |
| 20 | + |
| 21 | + <property name="spl-md" value="${env.STREAMS_INSTALL}/bin/spl-make-doc"/> |
| 22 | + <property name="spl-st" value="${env.STREAMS_INSTALL}/bin/streamtool"/> |
| 23 | + |
| 24 | + <!-- Create the time stamp --> |
| 25 | + <tstamp/> |
| 26 | + |
| 27 | + <!-- Extract the git commit hash --> |
| 28 | + <exec executable="git" outputproperty="commithash"> |
| 29 | + <arg value="rev-parse" /> |
| 30 | + <arg value="--short" /> |
| 31 | + <arg value="HEAD" /> |
| 32 | + </exec> |
| 33 | + |
| 34 | + <target name="all" depends="toolkit,spldoc" |
| 35 | + description="Main target: Build all toolkit artifacts, toolkit documentation - incremental build"/> |
| 36 | + |
| 37 | + <target name="clean" depends="spldoc-clean,toolkit-clean,releaseinfo-clean" |
| 38 | + description="Main target: Clean all generated and downloaded toolkit files and clean the documentation"/> |
| 39 | + |
| 40 | + <target name="toolkit" |
| 41 | + description="Main target: Build toolkit code and index the toolkit - incremental build."> |
| 42 | + <ant dir="${toolkit.dir}" target="all" /> |
| 43 | + </target> |
| 44 | + |
| 45 | + <target name="toolkit-clean" |
| 46 | + description="Main target: Clean all generated and downloaded toolkit files"> |
| 47 | + <ant dir="${toolkit.dir}" target="clean" /> |
| 48 | + </target> |
| 49 | + |
| 50 | + <target name="spldoc" depends="toolkit" |
| 51 | + description="Generate the toolkit documentation"> |
| 52 | + <echo message="Tookit spldoc to: ${doc.dir}"/> |
| 53 | + <exec executable="${spl-md}" failonerror="true"> |
| 54 | + <arg value="--include-composite-operator-diagram" /> |
| 55 | + <arg value="--author" /> |
| 56 | + <arg value="${tkauthor}" /> |
| 57 | + <arg value="--doc-title" /> |
| 58 | + <arg value="${tktitle}" /> |
| 59 | + <arg value="--directory" /> |
| 60 | + <arg value="${toolkit.dir}" /> |
| 61 | + <arg value="--warn-no-comments"/> |
| 62 | + <arg value="--copy-image-files" /> |
| 63 | + <arg value="--output-directory" /> |
| 64 | + <arg value="${doc.dir}" /> |
| 65 | + </exec> |
| 66 | + </target> |
| 67 | + |
| 68 | + <target name="spldoc-clean" |
| 69 | + description="Clean the toolkit documentation"> |
| 70 | + <delete dir="${doc.string}"/> |
| 71 | + </target> |
| 72 | + |
| 73 | + <!-- Targets to build releases --> |
| 74 | + <target name="release" depends="clean,spldoc-clean" |
| 75 | + description="Main target: Make a toolkit release archive - purge workspace and build toolkit from scratch"> |
| 76 | + <antcall target="release-target" inheritAll="true"/> |
| 77 | + </target> |
| 78 | + |
| 79 | + <target name="release-target" depends="releaseinfo"> |
| 80 | + <antcall target="spldoc"/> |
| 81 | + <mkdir dir="${release.dir}"/> |
| 82 | + <xmlproperty file="${toolkit.dir}/info.xml" prefix="tkinfo" keepRoot="no"/> |
| 83 | + <echo message="Make releasefile Toolkit Version: ${tkinfo.info:identity.info:version}"/> |
| 84 | + <property name="releasefilename" value="${release.dir}/${ant.project.name}-${tkinfo.info:identity.info:version}-${commithash}-${DSTAMP}-${TSTAMP}.tgz"/> |
| 85 | + <tar compression="gzip" longfile="gnu" |
| 86 | + destfile="${releasefilename}" |
| 87 | + basedir="${basedir}" |
| 88 | + includes="${toolkit.dir}/** ${samples.dir}/** ${doc.string}/** README.md LICENSE" |
| 89 | + excludes="**/.toolkitList **/.gitignore ${toolkit.dir}/.settings/ ${toolkit.dir}/.project ${toolkit.dir}/.classpath ${toolkit.dir}/build.xml ${toolkit.dir}/pom.xml ${toolkit.dir}/icons/ ${toolkit.dir}/impl/java/" |
| 90 | + /> |
| 91 | + <checksum file="${releasefilename}"/> |
| 92 | + <checksum algorithm="sha1" file="${releasefilename}"/> |
| 93 | + </target> |
| 94 | + |
| 95 | + <!-- Extract the git commit hash and make release info --> |
| 96 | + <target name="releaseinfo" depends="clean-ignored" |
| 97 | + description="Make the release information file"> |
| 98 | + <exec executable="git" outputproperty="commithash.long" failonerror="true"> |
| 99 | + <arg value="rev-parse" /> |
| 100 | + <arg value="HEAD" /> |
| 101 | + </exec> |
| 102 | + <exec executable="bash" outputproperty="streamsversion" failonerror="true"> |
| 103 | + <arg value="-c"/> |
| 104 | + <arg value="${spl-st} version | grep Version="/> |
| 105 | + </exec> |
| 106 | + <exec executable="bash" failonerror="true"> |
| 107 | + <arg value="-c" /> |
| 108 | + <arg value="echo -e "commit_hash=${commithash.long}\nos=${os.version}\nStreams_${streamsversion}" > ${release.info.file}"/> |
| 109 | + </exec> |
| 110 | + <echo message="Generated release info file ${release.info.file}"/> |
| 111 | + <exec executable="bash" failonerror="true"> |
| 112 | + <arg value="-c" /> |
| 113 | + <arg value="cat ${release.info.file}" /> |
| 114 | + </exec> |
| 115 | + </target> |
| 116 | + |
| 117 | + <target name="releaseinfo-clean" |
| 118 | + description="Remove the release information file"> |
| 119 | + <delete file="${release.info.file}"/> |
| 120 | + </target> |
| 121 | + |
| 122 | + <!--- Targets to purge the workspace before a release archive is ptroduced --> |
| 123 | + <target name="clean-ignored" depends="warn-unclean" |
| 124 | + description="Remove all git-ignored files and warn if workspace has uncommited changes"> |
| 125 | + </target> |
| 126 | + |
| 127 | + <target name="warn-unclean" depends="check-unclean" if="has.uncommited"> |
| 128 | + <echo>!Your workspace is not clean!</echo> |
| 129 | + <echo>Commit all changes before you produce a release</echo> |
| 130 | + <echo>commitstatus:</echo> |
| 131 | + <echo>${commitstatus}</echo> |
| 132 | + <input>Press Return key to continue or ^C to exit...</input> |
| 133 | + </target> |
| 134 | + |
| 135 | + <target name="check-unclean" depends="warn-untracked"> |
| 136 | + <exec executable="git" outputproperty="commitstatus"> |
| 137 | + <arg value="status" /> |
| 138 | + <arg value="--porcelain" /> |
| 139 | + </exec> |
| 140 | + <!-- set condition true if there are any non-whitespaces --> |
| 141 | + <condition property="has.uncommited"> |
| 142 | + <matches string="${commitstatus}" pattern="\S" multiline="true"/> |
| 143 | + </condition> |
| 144 | + <echo message="has.uncommited=${has.uncommited}"/> |
| 145 | + </target> |
| 146 | + |
| 147 | + <target name="warn-untracked" depends="check-untracked" if="has.untracked"> |
| 148 | + <echo>!!! DANGER: Git-ignored or untracked files to be removed from your workspace:</echo> |
| 149 | + <echo>${untracked}</echo> |
| 150 | + <input>Press Return key to continue or ^C to exit...</input> |
| 151 | + <exec executable="git" failonerror="true"> |
| 152 | + <arg value="clean"/> |
| 153 | + <arg value="--force"/> |
| 154 | + <arg value="-d"/> |
| 155 | + <arg value="-x"/> |
| 156 | + <arg value="--"/> |
| 157 | + <arg value="${toolkit.dir}"/> |
| 158 | + <arg value="${samples.dir}"/> |
| 159 | + <arg value="${doc.string}"/> <!-- use a value here because git clean fails is this is an location and is empty --> |
| 160 | + </exec> |
| 161 | + </target> |
| 162 | + |
| 163 | + <target name="check-untracked"> |
| 164 | + <exec executable="git" outputproperty="untracked" failonerror="true"> |
| 165 | + <arg value="clean"/> |
| 166 | + <arg value="--dry-run"/> |
| 167 | + <arg value="-d"/> |
| 168 | + <arg value="-x"/> |
| 169 | + <arg value="--"/> |
| 170 | + <arg value="${toolkit.dir}"/> |
| 171 | + <arg value="${samples.dir}"/> |
| 172 | + <arg value="${doc.string}"/> <!-- use a value here because git clean fails is this is an location and is empty --> |
| 173 | + </exec> |
| 174 | + <!-- set condition true if there are any non-whitespaces --> |
| 175 | + <condition property="has.untracked"> |
| 176 | + <matches string="${untracked}" pattern="\S" multiline="true"/> |
| 177 | + </condition> |
| 178 | + <echo message="has.untracked=${has.untracked}"/> |
| 179 | + </target> |
| 180 | +</project> |
0 commit comments