Logo
SDN | SAP Help | Sourceforge

Copy / paste the following block to a file called build.xml. Customize the properties to fit your environment and lastly remember to create a folder named "lib" and place all dependant jar files in it (also the ones provided by Developer Studio).

<project name="Standard SAP EP buildscript" basedir="." default="jar">

        <!-- 
                Standard SAP Enterprise Portal project buildscript.
                
                This script is meant to work with a standard par project
                layout of Developer Studio. You're required to make dependant
                jar files available either by adding them to the ant classpath
                or by placing them in a folder called "lib" in the project root.
        -->
        
        <!-- These properties should be maintained before use -->
        <property name="appname" value="test"/>
        <property name="par.filename" value="${appname}.par"/>
        <property name="theVersion" value="1.0"/>
        <property name="company" value="Name of company"/>
        <property name="deploy.host" value="localhost"/>
        <property name="deploy.port" value="50000"/>
        <property name="deploy.username" value="adminstrator"/>
        <property name="deploy.password" value="password"/>
        <!-- End of usermaintained properties -->
        
        <!-- WARNING: You should only change the script beyond this point
                 if you really know what you're doing -->
        
        <path id="classpath.public">
                <fileset dir="${basedir}/lib" includes="**/*.jar" />
                <fileset dir="${basedir}/build/par/PORTAL-INF/lib" includes="**/*.jar" />
        </path>
        
        <path id="classpath.private">
                <path refid="classpath.public"/>
                <fileset dir="${basedir}/build/par/PORTAL-INF/private/lib" includes="**/*.jar" />
        </path>
        
        <taskdef classname="net.sf.dynpageplus.ant.Deploytask" 
                 name="deployer">
                <classpath>
                        <fileset dir="${extra.lib}" includes="**/*.jar" />
                </classpath>
        </taskdef>
        
        <target name="init">
                <mkdir dir="${basedir}/build/par"/>
                <copy todir="${basedir}/build/par">
                        <fileset dir="${basedir}/dist"/>
                </copy>
                <mkdir dir="${basedir}/build/par/lib"/>
                <copy todir="${basedir}/build/par/lib" failonerror="false">
                        <fileset dir="${basedir}/lib"/>
                </copy>
                <mkdir dir="${basedir}/build/par/PORTAL-INF/classes"/>
                <mkdir dir="${basedir}/build/par/PORTAL-INF/lib"/>
                <mkdir dir="${basedir}/build/par/PORTAL-INF/private/classes"/>
                <mkdir dir="${basedir}/build/par/PORTAL-INF/private/lib"/>
        </target>

        <target name="compile" depends="init">
                <echo>Compiling API</echo>
                <javac srcdir="${basedir}/src.api"
                           destdir="${basedir}/build/par/PORTAL-INF/classes">
                        <classpath refid="classpath.public"/>
                </javac>
                <echo>Compiling CORE</echo>
                <javac srcdir="${basedir}/src.core"
                           destdir="${basedir}/build/par/PORTAL-INF/private/classes">
                        <classpath refid="classpath.private"/>
                </javac>
        </target>
        
        <target name="test">
                <mkdir dir="${basedir}/build/testdata"/>
                <junit printsummary="yes" haltonfailure="yes">
                        <classpath>
                                <path refid="classpath.private"/>
                                <dirset dir="${basedir}/build/par/PORTAL-INF">
                                        <include name="**/classes"/>
                                </dirset>
                        </classpath>

                        <formatter type="xml"/>

                        <batchtest fork="yes" todir="${basedir}/build/testdata">
                        <fileset dir="${src.tests}">
                                <include name="**/*Test.java"/>
                                <exclude name="**/*J2eeTest.java"/>
                        </fileset>
                        </batchtest>
                </junit>
        
                <junitreport todir="./reports">
                        <fileset dir="./reports">
                        <include name="TEST-*.xml"/>
                        </fileset>
                        <report format="frames" todir="./report/html"/>
                </junitreport>
        
        </target>
        
        
        <target name="jar" depends="compile">
        <jar destfile="${basedir}/build/${par.filename}">
                        <manifest>
                            <attribute name="Built-By" value="${user.name}"/>
                            <attribute name="Specification-Title" value="NetWeaver Enterprise Portal"/>
                            <attribute name="Specification-Version" value="6.0"/>
                            <attribute name="Specification-Vendor" value="SAP AG"/>
                            <attribute name="Implementation-Title" value="${appname}"/>
                            <attribute name="Implementation-Version" value="${theVersion}"/> 
                            <attribute name="Implementation-Vendor" value="${company}"/>
                        </manifest>
                <fileset dir="${basedir}/build/par"/>
        </jar>
        </target>
        
        <target name="deploy" depends="jar">
                <echo>Deploying ${basedir}/build/${par.filename}</echo>
                <deployer
                        host="${deploy.host}"
                        port="${deploy.port}"
                        username="${deploy.username}"
                        password="${deploy.password}"
                        parfile="${basedir}/build/${par.filename}"/>

        </target>

        <target name="clean">
                <delete dir="${basedir}/build"/>
        </target>

</project>