1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
This file was modified from the Apache Cayenne project's build system
to suit the needs of the Jython project's build system.
-->
<!-- ================================================= -->
<!-- Maven Bundle Buildfile -->
<!-- ================================================= -->
<project name="jython-maven" default="bundle-all" basedir="..">
<property file="${user.home}/ant.properties" />
<property file="${basedir}/default.properties" />
<!-- Artefacts for publication. -->
<property name="pubs.dir" value="${basedir}/publications" />
<property name="m2.repo" value="${user.home}/.m2/repository" />
<property name="m2.groupDir" value="org/python" />
<property name="gradle.base" value="${basedir}/build2" />
<property name="gradle.repo" value="${gradle.base}/stagingRepo" />
<property name="build.base" value="${basedir}/build" />
<property name="build.maven" value="${build.base}/maven" />
<property name="version.properties" value="${build.base}/classes/org/python/version.properties" />
<property name="dist.dir" value="${basedir}/dist" />
<property name="src.dir" value="${basedir}/src" />
<property name="bundle.dir" value="${basedir}/bundle" />
<condition property="do.build">
<not>
<and>
<available file="${version.properties}" />
<available file="${dist.dir}/jython.jar" />
<available file="${dist.dir}/jython-standalone.jar" />
</and>
</not>
</condition>
<target name="version">
<property file="${version.properties}" />
</target>
<target name="install" depends="prepare">
<m2-install artifactId="jython" version="${jython.version}" />
</target>
<target name="install-standalone" depends="prepare">
<m2-install artifactId="jython-standalone" version="${jython.version}" />
</target>
<target name="bundle" depends="prepare">
<m2-bundle artifactId="jython" version="${jython.version}" />
</target>
<target name="bundle-standalone" depends="prepare">
<m2-bundle artifactId="jython-standalone" version="${jython.version}" />
</target>
<target name="bundle-installer" depends="prepare">
<m2-bundle artifactId="jython-installer" version="${jython.version}" />
</target>
<target name="bundle-slim" depends="prepare" if="gradle.published">
<m2-bundle-gradle artifactId="jython-slim" version="${jython.version}" />
</target>
<target name="install-all" depends="install, install-standalone" />
<target name="bundle-all" depends="version, bundle, bundle-standalone, bundle-installer, bundle-slim" />
<target name="clean">
<delete dir="${build.maven}" />
<delete>
<fileset dir="${bundle.dir}" includes="*-bundle.jar" />
</delete>
</target>
<!-- Install an artifact to the local repo specified by ${m2.repo}. -->
<macrodef name="m2-install">
<attribute name="artifactId" />
<attribute name="version" />
<attribute name="install.dir" default="${m2.repo}/${m2.groupDir}/@{artifactId}/@{version}" />
<attribute name="install.name" default="@{artifactId}-@{version}" />
<sequential>
<stage artifactId="@{artifactId}" version="@{version}" />
<mkdir dir="@{install.dir}" />
<copy file="maven/pom-template.xml" tofile="@{install.dir}/@{install.name}.pom">
<filterset>
<filter token="PROJECT-VERSION" value="@{version}" />
<filter token="ARTIFACT-ID" value="@{artifactId}" />
</filterset>
</copy>
<move file="${build.maven}/@{install.name}.jar" tofile="@{install.dir}/@{install.name}.jar" />
<move file="${build.maven}/@{install.name}-sources.jar" tofile="@{install.dir}/@{install.name}-sources.jar" />
<checksum algorithm="SHA1" fileext=".sha1">
<fileset dir="@{install.dir}" excludes="*.sha1,*.md5,*.tmp" />
</checksum>
<checksum algorithm="MD5" fileext=".md5">
<fileset dir="@{install.dir}" excludes="*.sha1,*.md5,*.tmp" />
</checksum>
</sequential>
</macrodef>
<!-- Stage (in @{stageDir}), creating a POM, and adding the version to names used.
Then create a bundle in ${pubs.dir} for release. -->
<macrodef name="m2-bundle">
<attribute name="artifactId" />
<attribute name="version" />
<attribute name="fromDir" default="${dist.dir}" />
<attribute name="stageDir" default="${build.maven}" />
<attribute name="basename" default="@{artifactId}-@{version}" />
<sequential>
<!-- Clean the staging directory. -->
<delete dir="@{stageDir}" />
<mkdir dir="@{stageDir}" />
<!-- Copy over the primary artifact from @{fromDir} to the staging area. -->
<copy file="@{fromDir}/@{artifactId}.jar" tofile="@{stageDir}/@{basename}.jar" />
<!-- The source and Javadoc are already prepared (but add the version to the name). -->
<copy file="@{fromDir}/sources.jar" tofile="@{stageDir}/@{basename}-sources.jar" />
<copy file="@{fromDir}/javadoc.jar" tofile="@{stageDir}/@{basename}-javadoc.jar" />
<!-- Create the POM from the given template with placeholders replaced. -->
<copy file="maven/pom-template.xml" tofile="@{stageDir}/@{basename}.pom">
<filterset>
<filter token="PROJECT-VERSION" value="@{version}" />
<filter token="ARTIFACT-ID" value="@{artifactId}" />
</filterset>
</copy>
<!-- Sign everything. -->
<sign-all stageDir="@{stageDir}" artifactId="@{artifactId}" version="@{version}" />
<!-- JAR-up the entire contents of the staging directory. -->
<jar jarfile="${pubs.dir}/@{basename}-bundle.jar">
<fileset dir="@{stageDir}" />
</jar>
</sequential>
</macrodef>
<!-- Stage (in @{stageDir}), a gradle-built artifact in which Gradle has created a POM,
and the secondary artifacts (source, javadoc) with the version in the file names.
Then create a bundle in ${pubs.dir} for release. -->
<macrodef name="m2-bundle-gradle">
<attribute name="artifactId" />
<attribute name="version" />
<attribute name="fromDir" default="${gradle.repo}/${m2.groupDir}/@{artifactId}/@{version}" />
<attribute name="stageDir" default="${build.maven}" />
<attribute name="basename" default="@{artifactId}-@{version}" />
<sequential>
<!-- Validate the POM -->
<validate-pom file="@{fromdir}/@{basename}.pom" />
<!-- Clean the staging directory. -->
<delete dir="@{stageDir}" />
<mkdir dir="@{stageDir}" />
<!-- Copy over all the artifacts from @{fromDir} to the staging area. -->
<copy todir="@{stageDir}">
<fileset dir="@{fromDir}">
<include name="*.jar" />
<include name="*.pom" />
</fileset>
</copy>
<!-- Sign everything. -->
<sign-all stageDir="@{stageDir}" artifactId="@{artifactId}" version="@{version}" />
<!-- JAR-up the entire contents of the staging directory. -->
<jar jarfile="${pubs.dir}/@{basename}-bundle.jar">
<fileset dir="@{stageDir}" />
</jar>
</sequential>
</macrodef>
<!-- Add detached signature for single artifact in staging directory. -->
<macrodef name="sign-detached">
<attribute name="file" />
<attribute name="stageDir" />
<sequential>
<!-- Generate a detached signature for each artifact in the bundle. -->
<exec executable="gpg" dir="@{stageDir}">
<arg value="-ab" />
<arg value="@{file}" />
</exec>
</sequential>
</macrodef>
<!-- Add detached signatures for group of artifacts in staging directory. -->
<macrodef name="sign-all">
<attribute name="artifactId" />
<attribute name="version" />
<attribute name="stageDir" />
<attribute name="basename" default="@{artifactId}-@{version}" />
<sequential>
<sign-detached stageDir="@{stageDir}" file="@{basename}.pom" />
<sign-detached stageDir="@{stageDir}" file="@{basename}.jar" />
<sign-detached stageDir="@{stageDir}" file="@{basename}-sources.jar" />
<sign-detached stageDir="@{stageDir}" file="@{basename}-javadoc.jar" />
</sequential>
</macrodef>
<!-- Validate a Maven POM . -->
<macrodef name="validate-pom">
<attribute name="file" />
<sequential>
<xmlvalidate failonerror="true" file="@{file}">
<attribute name="http://xml.org/sax/features/validation" value="true" />
<attribute name="http://apache.org/xml/features/validation/schema" value="true" />
<attribute name="http://xml.org/sax/features/namespaces" value="true" />
<property name="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" value="maven/maven-v4_0_0.xsd" />
</xmlvalidate>
</sequential>
</macrodef>
<!-- Validate the POM template. -->
<target name="validate-template-pom">
<validate-pom file="maven/pom-template.xml"/>
</target>
<!-- Validate the base POM produced by Gradle task generatePomFileForMainPublication. -->
<target name="validate-gradle-pom" depends="version">
<validate-pom file="${gradle.base}/publications/main/pom-default.xml"/>
</target>
<target name="build-jython" if="do.build">
<ant antfile="build.xml" target="all-jars" />
</target>
<target name="prepare" depends="build-jython, validate-template-pom, version">
<local name="artifacts" />
<property name="artifacts" value="${gradle.repo}/${m2.groupDir}/jython-slim/${jython.version}" />
<condition property="gradle.published">
<available file="${artifacts}" type="dir" />
</condition>
</target>
</project>
|