thrift/lib/java/build.xml
Bryan Duxbury 1e79cb40f5 THRIFT-1469. java: Java isset space optimization
This patch gives the generated code some variable-sized options for the isset bit vector. The compiler will attempt to use byte, short, int and long types before reverting to a BitSet for structs with a LOT of optional fields. This should save a fair amount of memory in a lot of cases.

Patch: Brian Bloniarz

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1221828 13f79535-47bb-0310-9956-ffa450edef68
2011-12-21 18:13:29 +00:00

372 lines
16 KiB
XML

<?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.
-->
<project name="libthrift" default="dist" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<description>Thrift Build File</description>
<property name="thrift.root" location="../../"/>
<property name="thrift.artifactid" value="libthrift"/>
<!-- Include the base properties file -->
<property file="${basedir}/build.properties" />
<property environment="env"/>
<condition property="version" value="${thrift.version}">
<isset property="release"/>
</condition>
<property name="version" value="${thrift.version}-snapshot"/>
<property name="final.name" value="${thrift.artifactid}-${version}"/>
<property name="src" location="${basedir}/src"/>
<property name="build.dir" location="${basedir}/build"/>
<property name="build.lib.dir" location="${build.dir}/lib"/>
<property name="build.tools.dir" location="${build.dir}/tools"/>
<property name="src.test" location="test"/>
<property name="javadoc.dir" location="${build.dir}/javadoc"/>
<property name="build.test.dir" location="${build.dir}/test"/>
<property name="test.thrift.home" location="${thrift.root}/test"/>
<property name="gen" location="gen-java"/>
<property name="genbean" location="gen-javabean"/>
<property name="jar.file" location="${build.dir}/${final.name}.jar"/>
<property name="test.jar.file" location="${build.dir}/${final.name}-test.jar"/>
<property name="javadoc.jar.file" location="${build.dir}/${final.name}-javadoc.jar"/>
<property name="source.tar.gz" location="${build.dir}/${final.name}-src.tar.gz"/>
<!-- Junit properties -->
<property name="test.junit.output.format" value="plain"/>
<property name="test.timeout" value="2000000"/>
<property name="test.src.dir" location="${basedir}/test"/>
<property name="test.log.dir" value="${build.test.dir}/log"/>
<property name="test.port" value="9090"/>
<!-- maven properties -->
<property name="pom.xml" location="${build.dir}/${final.name}.pom"/>
<path id="compile.classpath">
<fileset dir="${build.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="test.classpath">
<path refid="compile.classpath"/>
<pathelement path="${env.CLASSPATH}"/>
<pathelement location="${build.test.dir}"/>
<pathelement location="${jar.file}"/>
<pathelement location="${test.jar.file}"/>
</path>
<!-- Tasks -->
<target name="init" depends="setup.init,mvn.init" unless="init.finished">
<property name="init.finished" value="true"/>
</target>
<target name="setup.init">
<tstamp/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.lib.dir}"/>
<mkdir dir="${build.tools.dir}"/>
<mkdir dir="${build.test.dir}"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build.dir}" source="1.5" target="1.5"
debug="true" classpathref="compile.classpath" includeantruntime="false">
<compilerarg value="-Xlint:deprecation"/>
</javac>
</target>
<target name="javadoc" depends="init">
<javadoc sourcepath="${src}" destdir="${javadoc.dir}"
version="true" windowtitle="Thrift Java API" doctitle="Thrift Java API"
classpathref="test.classpath">
</javadoc>
<jar jarfile="${javadoc.jar.file}" basedir="${javadoc.dir}">
<manifest>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
</jar>
</target>
<target name="dist" depends="compile">
<mkdir dir="${build.dir}/META-INF"/>
<copy file="${thrift.root}/LICENSE" tofile="${build.dir}/META-INF/LICENSE.txt"/>
<copy file="${thrift.root}/NOTICE" tofile="${build.dir}/META-INF/NOTICE.txt"/>
<jar jarfile="${jar.file}">
<manifest>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-SymbolicName" value="${thrift.groupid}"/>
<attribute name="Bundle-Name" value="Apache Thrift"/>
<attribute name="Bundle-Version" value="${version}"/>
<attribute name="Bundle-Description" value="Apache Thrift library"/>
<attribute name="Bundle-License" value="${license}"/>
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
<attribute name="Export-Package" value="${thrift.groupid};version=${version}"/>
</manifest>
<fileset dir="${build.dir}">
<include name="org/apache/thrift/**/*.class"/>
<include name="META-INF/*.txt"/>
</fileset>
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
</jar>
</target>
<target name="pack.src">
<tar destfile="${source.tar.gz}" basedir="${src}" compression="gzip"/>
</target>
<target name="install" depends="dist,javadoc">
<copy todir="${install.path}">
<fileset dir="${build.dir}" includes="*.jar"/>
<fileset dir="${build.lib.dir}" includes="*.jar"/>
</copy>
<copy todir="${install.javadoc.path}">
<fileset dir="${javadoc.dir}" includes="**/*"/>
</copy>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${gen}"/>
<delete dir="${genbean}"/>
</target>
<target name="compile-test" description="Build the test suite classes" depends="generate,dist">
<javac debug="true" srcdir="${gen}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false">
<compilerarg value="-Xlint:deprecation"/>
</javac>
<javac debug="true" srcdir="${genbean}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false">
<compilerarg value="-Xlint:deprecation"/>
</javac>
<javac debug="true" srcdir="${src.test}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false">
<compilerarg value="-Xlint:deprecation"/>
</javac>
<copy todir="${build.test.dir}">
<fileset dir="${src.test}" includes="log4j.properties"/>
</copy>
<jar jarfile="${test.jar.file}" basedir="${build.test.dir}"/>
</target>
<target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
<mkdir dir="${test.log.dir}"/>
<junit printsummary="true" showoutput="${test.output}" timeout="${test.timeout}"
haltonfailure="true" errorProperty="tests.failed" failureProperty="tests.failed"
fork="true" forkmode="perTest" maxmemory="512m"
>
<sysproperty key="build.test" value="${build.test.dir}"/>
<sysproperty key="test.port" value="${test.port}"/>
<sysproperty key="javax.net.ssl.trustStore" value="${src.test}/.truststore"/>
<sysproperty key="javax.net.ssl.trustStorePassword" value="thrift"/>
<sysproperty key="javax.net.ssl.keyStore" value="${src.test}/.keystore"/>
<sysproperty key="javax.net.ssl.keyStorePassword" value="thrift"/>
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}"/>
<batchtest todir="${test.log.dir}" unless="testcase">
<fileset dir="${test.src.dir}">
<include name="**/Test*.java"/>
<exclude name="**/TestClient.java"/>
<exclude name="**/TestServer.java"/>
<exclude name="**/TestNonblockingServer.java"/>
</fileset>
</batchtest>
<batchtest todir="${test.log.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
<java classname="org.apache.thrift.test.EqualityTest" classpathref="test.classpath" failonerror="true"/>
<java classname="org.apache.thrift.test.JavaBeansTest" classpathref="test.classpath" failonerror="true"/>
</target>
<target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
<target name="testclient" description="Run a test client" depends="compile-test">
<java classname="org.apache.thrift.test.TestClient"
classpathref="test.classpath" failonerror="true">
<arg line="${testargs}"/>
</java>
</target>
<target name="testserver" description="Run a test server" depends="compile-test">
<java classname="org.apache.thrift.test.TestServer"
classpathref="test.classpath" failonerror="true">
<arg line="${testargs}"/>
</java>
</target>
<target name="testnonblockingserver" description="Run a test nonblocking server" depends="compile-test">
<java classname="org.apache.thrift.test.TestNonblockingServer"
classpathref="test.classpath" failonerror="true">
<arg line="${testargs}"/>
</java>
</target>
<target name="generate">
<!-- Generate the thrift gen-java source -->
<exec executable="../../compiler/cpp/thrift" failonerror="true">
<arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift"/>
</exec>
<exec executable="../../compiler/cpp/thrift" failonerror="true">
<arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift"/>
</exec>
<exec executable="../../compiler/cpp/thrift" failonerror="true">
<arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift"/>
</exec>
<exec executable="../../compiler/cpp/thrift" failonerror="true">
<arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift"/>
</exec>
<exec executable="../../compiler/cpp/thrift" failonerror="true">
<arg line="--gen java:hashcode ${test.thrift.home}/ManyOptionals.thrift"/>
</exec>
</target>
<target name="proxy" if="proxy.enabled">
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
proxyuser="${proxy.user}" proxypassword="${proxy.pass}"/>
</target>
<target name="mvn.ant.tasks.download" depends="setup.init,mvn.ant.tasks.check,proxy" unless="mvn.ant.tasks.found">
<get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
</target>
<target name="mvn.ant.tasks.check">
<condition property="mvn.ant.tasks.found">
<typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
</condition>
</target>
<target name="mvn.init" depends="mvn.ant.tasks.download" unless="mvn.finished">
<!-- Download mvn ant tasks, download dependencies, and setup pom file -->
<typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${build.tools.dir}/${mvn.ant.task.jar}"/>
<!-- remote repositories used to download dependencies from -->
<artifact:remoteRepository id="central" url="${mvn.repo}"/>
<artifact:remoteRepository id="apache" url="${apache.repo}"/>
<!-- Pom file information -->
<artifact:pom id="pom"
groupId="${thrift.groupid}"
artifactId="${thrift.artifactid}"
version="${version}"
url="http://thrift.apache.org"
name="Apache Thrift"
description="Thrift is a software framework for scalable cross-language services development."
packaging="pom"
>
<remoteRepository refid="central"/>
<remoteRepository refid="apache"/>
<license name="The Apache Software License, Version 2.0" url="${license}"/>
<scm connection="scm:svn:http://svn.apache.org/repos/asf/thrift/trunk/"
developerConnection="scm:svn:http://svn.apache.org/repos/asf/thrift/trunk/"
url="http://svn.apache.org/viewcvs.cgi/thrift"
/>
<!-- Thrift Developers -->
<developer id="mcslee" name="Mark Slee"/>
<developer id="dreiss" name="David Reiss"/>
<developer id="aditya" name="Aditya Agarwal"/>
<developer id="marck" name="Marc Kwiatkowski"/>
<developer id="jwang" name="James Wang"/>
<developer id="cpiro" name="Chris Piro"/>
<developer id="bmaurer" name="Ben Maurer"/>
<developer id="kclark" name="Kevin Clark"/>
<developer id="jake" name="Jake Luciani"/>
<developer id="bryanduxbury" name="Bryan Duxbury"/>
<developer id="esteve" name="Esteve Fernandez"/>
<developer id="todd" name="Todd Lipcon"/>
<developer id="geechorama" name="Andrew McGeachie"/>
<developer id="molinaro" name="Anthony Molinaro"/>
<developer id="roger" name="Roger Meier"/>
<developer id="jfarrell" name="Jake Farrell"/>
<!-- Thrift dependencies list -->
<dependency groupId="org.slf4j" artifactId="slf4j-api" version="1.5.8"/>
<dependency groupId="commons-lang" artifactId="commons-lang" version="2.5"/>
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.5" scope="provided"/>
<dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.1.2"/>
<dependency groupId="org.apache.httpcomponents" artifactId="httpcore" version="4.1.3"/>
</artifact:pom>
<!-- Generate the pom file -->
<artifact:writepom pomRefId="pom" file="${pom.xml}"/>
<!-- Download the dependencies -->
<artifact:dependencies filesetId="build-dependency-jars" pomRefId="pom"/>
<!-- Copy the dependencies to the build/lib dir -->
<copy todir="${build.dir}/lib">
<fileset refid="build-dependency-jars"/>
<mapper type="flatten"/>
</copy>
<!-- Dependencies needed for testing -->
<artifact:dependencies filesetId="test-dependency-jars" useScope="runtime">
<dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.5.8"/>
<dependency groupId="junit" artifactId="junit" version="4.4"/>
</artifact:dependencies>
<!-- Copy the test dependencies to the build/lib dir -->
<copy todir="${build.dir}/lib">
<fileset refid="test-dependency-jars"/>
<mapper type="flatten"/>
</copy>
<property name="mvn.finished" value="true"/>
</target>
<macrodef name="signAndDeploy">
<!-- Sign and deploy jars to apache repo -->
<attribute name="file"/>
<attribute name="classifier" default=""/>
<attribute name="packaging" default="jar"/>
<attribute name="pom" default=""/>
<sequential>
<artifact:mvn fork="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file"/>
<arg value="-DrepositoryId=${maven-repository-id}"/>
<arg value="-Durl=${maven-repository-url}"/>
<arg value="-DpomFile=@{pom}"/>
<arg value="-Dfile=@{file}"/>
<arg value="-Dclassifier=@{classifier}"/>
<arg value="-Dpackaging=@{packaging}"/>
<arg value="-Pgpg"/>
</artifact:mvn>
</sequential>
</macrodef>
<target name="publish" depends="clean,init,test,dist,javadoc,pack.src">
<!-- Compile, package, test and then send release to apache maven repo -->
<!-- run with: ant -Drelease=true publish-->
<signAndDeploy file="${pom.xml}" packaging="pom" classifier="" pom="${pom.xml}"/>
<signAndDeploy file="${jar.file}" packaging="jar" classifier="" pom="${pom.xml}"/>
<signAndDeploy file="${javadoc.jar.file}" packaging="jar" classifier="javadoc" pom="${pom.xml}"/>
<signAndDeploy file="${source.tar.gz}" packaging="src" classifier="tar.gz" pom="${pom.xml}"/>
</target>
</project>