blob: 06b3a19cf9dd0871945419091189d28ab76ac269 [file] [log] [blame]
<?xml version="1.0"?>
<!--
/***********************************************************************************************************************
* Copyright (c) 2008 empolis GmbH and brox IT Solutions GmbH. All rights reserved. This program and the accompanying
* materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Ralf Rausch (brox IT Solutions GmbH) - initial creator
**********************************************************************************************************************/
-->
<project name="pdebuild" default="all" basedir="." xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors" xmlns:jacoco="antlib:org.jacoco.ant">
<description>simple pde driver ant script. Identical to the build.sh file. </description>
<property name="reports" location="${buildDirectory}/reports" />
<property name="reports_errors_txt" location="${buildDirectory}/reports_errors_txt" />
<property name="junit.dir" location="${reports}/junit" />
<property name="jacoco.dir" location="${reports}/jacoco" />
<property name="pmd.dir" location="${reports}/pmd" />
<property name="checkstyle.dir" location="${reports}/checkstyle" />
<property name="eclipse.test.dir" location="${buildDirectory}/eclipse-test" />
<property name="eclipse.test.zip" location="${basedir}/eclipse-test.zip" />
<property name="lib.dir" location="${basedir}/../lib" />
<property name="eclipse.tmp.dir" location="${buildDirectory}/tmp" />
<property name="eclipse.application.dir" location="${buildDirectory}/Application" />
<property name="javadoc.dir" location="${buildDirectory}/javadoc" />
<import file="properties.xml" />
<import file="macros.build.xml" />
<target name="versions">
<property name="smila.release" value="1.2" />
<exec executable="svnversion" dir="${workspace}" failonerror="false" failifexecutionfails="false" outputproperty="svnrev" />
<property name="svnrev" value="n/a" />
<property name="smila.version" value="${smila.release}.${svnrev}" />
<echo message="SMILA version=${smila.version}" />
</target>
<!-- REPORTS -->
<!-- JACOCO - set JACOCO.REPORT-property in macros.build.xml to true, if you use the JACOCO plugin.
Please set also the property "JACOCO.CLASSPATH" in macros.build.xml -->
<if>
<equals arg1="${JACOCO.REPORT}" arg2="true" />
<then>
<property name="jacoco.dir" location="${reports}/jacoco" />
<jacoco:agent destfile="${jacoco.dir}/coverage.exec" append="true" property="jacoco.agentvmparam" />
</then>
<else>
<echo>JACOCO-property is off, so no JACOCO-report will be created</echo>
<property name="jacoco.agentvmparam" value="" />
</else>
</if>
<!-- CHECKSTYLE set CHECKSTYLE.REPORT-property in macros.build.xml to true, if you use the CHECKSTYLE plugin.
Please set also the property "CHECKSTYLE.CLASSPATH" in macros.build.xml -->
<if>
<equals arg1="${CHECKSTYLE.REPORT}" arg2="true" />
<then>
<property name="checkstyle.config.file.smila" value="smila_checkstyle-5.xml" />
<property name="checkstyle.config.file.smila.test" value="smila-test_checkstyle-5.xml" />
<property name="checkstyle.fail.on.violation" value="false" />
<property name="checkstyle.data.file" location="${checkstyle.dir}/checkstyle_report.xml" />
<property name="checkstyle.data.file.test" location="${checkstyle.dir}/checkstyle_report_test.xml" />
<property name="checkstyle.report.file" location="${checkstyle.dir}/checkstyle_report.html" />
<property name="checkstyle.report.file.test" location="${checkstyle.dir}/checkstyle_report_test.html" />
<property name="checkstyle.config.path" location="${basedir}/checkstyle" />
<property name="checkstyle.xsl.file" location="${checkstyle.config.path}/checkstyle-noframes-brox.xsl" />
</then>
<else>
<echo>Checkstyle-property is off, so no checkstyle-report will be created</echo>
</else>
</if>
<!-- PMD - set PMD.REPORT-property in macros.build.xml to true, if you use the PMD plugin.
Please set also the property "PMD.CLASSPATH" in macros.build.xml -->
<if>
<equals arg1="${PMD.REPORT}" arg2="true" />
<then>
<property name="pmd.config.path" location="${basedir}/pmd" />
<property name="cpd.xsl.file" location="${pmd.config.path}/cpdhtml.xslt" />
<property name="cpd.data.file" location="${pmd.dir}/cpd_report.xml" />
<property name="cpd.report.file" location="${pmd.dir}/cpd_report.html" />
</then>
<else>
<echo>PMD-property is off, so no pmd-report will be created</echo>
</else>
</if>
<!-- selects all java files which is used for PMD and checkstyle -->
<fileset dir="${buildDirectory}/plugins" id="plugin-java-files">
<include name="org.eclipse.smila.*/code/**/*.java" />
<exclude name="**/code/gen/**" />
<exclude name="**/AllTests.java" />
<exclude name="*.test/**" />
</fileset>
<!-- selects all java test files which are used for checkstyle -->
<fileset dir="${buildDirectory}/plugins" id="plugin-java-test-files">
<include name="*.test/code/**/*.java" />
<exclude name="**/code/gen/**" />
<exclude name="**/AllTests.java" />
</fileset>
<property name="feature-names" value='
org.eclipse.smila.extension.feature
org.eclipse.smila.feature
org.eclipse.smila.product.core.feature
org.eclipse.smila.test.feature
'>
</property>
<patternset id='patterns.bundle.all'>
<include name="de.*" />
<include name="com.*" />
<include name="javax.*" />
<include name="net.*" />
<include name="oracle.*" />
<include name="org.*" />
<include name="rome.*" />
</patternset>
<!-- the follwoing projects are excluded from build -->
<patternset id='patterns.bundle.excludes'>
<exclude name="*.feature" />
</patternset>
<patternset id='patterns.bundle.smila'>
<include name="org.eccenca.smila.*" />
<include name="org.eclipse.smila.*" />
</patternset>
<!-- dirsets for bundle.dirs.(all|smila|3rd)[.test] -->
<dirset id='bundle.dirs.all' dir='${workspace}'>
<patternset refid="patterns.bundle.all" />
<patternset refid="patterns.bundle.excludes" />
</dirset>
<dirset id="bundle.dirs.smila" dir='${workspace}'>
<patternset refid="patterns.bundle.smila" />
<patternset refid="patterns.bundle.excludes" />
</dirset>
<dirset id="bundle.dirs.3rd" dir='${workspace}'>
<patternset refid="patterns.bundle.all" />
<patternset refid="patterns.bundle.excludes" />
<exclude name="org.eccenca.smila.*" />
<exclude name="org.eclipse.smila.*" />
</dirset>
<restrict id="bundle.dirs.all.test">
<dirset refid="bundle.dirs.all" />
<rsel:name name="*.test" />
<rsel:not>
<rsel:or>
<rsel:name name="org.eclipse.smila.test" />
<rsel:name name="net.sf.saxon.test" />
<rsel:name name="com.empolis.*" />
</rsel:or>
</rsel:not>
</restrict>
<restrict id="bundle.dirs.smila.test">
<dirset refid="bundle.dirs.smila" />
<rsel:name name="*.test" />
</restrict>
<restrict id="bundle.dirs.3rd.test">
<dirset refid="bundle.dirs.3rd" />
<rsel:name name="*.test" />
</restrict>
<!-- here go all tests that should not be executed normally, ie in bammbo, but complied non the less -->
<property name='bundle.names.test.exclude' value='' />
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- target: bundle.names.init -->
<!-- white space delimited list of bundle names (i.e. their dir name)-->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="bundle.names.init">
<M_dirset2list dirset.id="bundle.dirs.all" targetproperty="bundle.names.all" />
<M_dirset2list dirset.id="bundle.dirs.smila" targetproperty="bundle.names.smila" />
<M_dirset2list dirset.id="bundle.dirs.3rd" targetproperty="bundle.names.3rd" />
<M_dirset2list dirset.id="bundle.dirs.all.test" targetproperty="bundle.names.all.test" />
<M_dirset2list dirset.id="bundle.dirs.smila.test" targetproperty="bundle.names.smila.test" />
<M_dirset2list dirset.id="bundle.dirs.3rd.test" targetproperty="bundle.names.3rd.test" />
<property name="bundles-for-test" value="${bundle.names.all.test} " />
</target>
<!-- =================================================================== -->
<!-- target: fetch -->
<!-- =================================================================== -->
<target name="fetch" depends="bundle.names.init">
<mkdir dir="${buildDirectory}" />
<mkdir dir="${buildDirectory}/features" />
<mkdir dir="${buildDirectory}/plugins" />
<mkdir dir="${eclipse.application.dir}" />
<echo level="info">### copying all features ###</echo>
<M_copy.resource.type list='${feature-names}' type='features' />
<echo level="info">### copying all plugins ###</echo>
<M_copy.resource.type list='${bundle.names.all}' type='plugins' />
<!-- remove it when download will be -->
<copy todir="${buildDirectory}/plugins">
<fileset Dir="${workspace}/SMILA.extension/eclipse/plugins" />
</copy>
</target>
<!-- =================================================================== -->
<!-- target: report-jacoco -->
<!-- =================================================================== -->
<target name="report.jacoco">
<if>
<equals arg1="${JACOCO.REPORT}" arg2="true" />
<then>
<jacoco:report>
<executiondata>
<file file="${jacoco.dir}/coverage.exec" />
</executiondata>
<structure name="SMILA">
<classfiles>
<fileset dir="${eclipse.test.dir}/plugins">
<!-- all IAS jars -->
<include name="org.eclipse.smila.*.jar" />
<!-- nothing to test here -->
<exclude name="org.eclipse.smila.product*" />
</fileset>
</classfiles>
<sourcefiles>
<dirset dir="${buildDirectory}/plugins">
<include name="org.eclipse.smila.*/code/src" />
<exclude name="*.test/**" />
</dirset>
</sourcefiles>
</structure>
<xml destfile="${jacoco.dir}/coverage.xml" />
<csv destfile="${jacoco.dir}/coverage.csv" />
<html destdir="${jacoco.dir}/html" />
</jacoco:report>
</then>
</if>
</target>
<!-- =================================================================== -->
<!-- target: pmd -->
<!-- =================================================================== -->
<target name="pmd">
<if>
<equals arg1="${PMD.REPORT}" arg2="true" />
<then>
<mkdir dir="${pmd.dir}" />
<pmd shortFilenames="true" targetjdk="1.7">
<ruleset>unusedcode</ruleset>
<ruleset>basic</ruleset>
<ruleset>codesize</ruleset>
<ruleset>design</ruleset>
<formatter type="xml" toFile="${pmd.dir}/pmd_reports.xml" linkPrefix="http://pmd.sourceforge.net/xref/" />
<formatter type="html" toFile="${pmd.dir}/pmd_report.html" linePrefix=".line" />
<!-- Core bundles -->
<fileset refid="plugin-java-files" />
</pmd>
</then>
</if>
</target>
<!-- =================================================================== -->
<!-- target: checkstyle -->
<!-- =================================================================== -->
<target name="checkstyle" description="Runs all checkstyle checks">
<if>
<equals arg1="${CHECKSTYLE.REPORT}" arg2="true" />
<then>
<echo level="info">Checkstyle Config Path:${checkstyle.config.path}</echo>
<fail unless="checkstyle.config.path">${checkstyle.config.path} is not set</fail>
<mkdir dir="${checkstyle.dir}" />
<!-- Checkstype report for impl bundles -->
<checkstyle config="${checkstyle.config.path}/${checkstyle.config.file.smila}" failOnViolation="${checkstyle.fail.on.violation}">
<!-- Source file list for Checkstyle report-->
<!-- Core bundles -->
<fileset refid="plugin-java-files" />
<formatter type="xml" toFile="${checkstyle.data.file}" />
</checkstyle>
<xslt in="${checkstyle.data.file}" out="${checkstyle.report.file}" style="${checkstyle.xsl.file}" />
<!-- Checkstype report for test bundles -->
<checkstyle config="${checkstyle.config.path}/${checkstyle.config.file.smila.test}" failOnViolation="${checkstyle.fail.on.violation}">
<fileset refid="plugin-java-test-files" />
<formatter type="xml" toFile="${checkstyle.data.file.test}" />
</checkstyle>
<xslt in="${checkstyle.data.file.test}" out="${checkstyle.report.file.test}" style="${checkstyle.xsl.file}" />
</then>
</if>
</target>
<!-- PMD-CPD -->
<target name="pmd-cpd" description="Runs pmd-cpd check">
<if>
<equals arg1="${PMD.REPORT}" arg2="true" />
<then>
<mkdir dir="${pmd.dir}" />
<echo level="info">PMD Config Path: ${pmd.config.path}</echo>
<fail unless="pmd.config.path">${pmd.config.path} is not set</fail>
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="pmd.lib" />
<cpd minimumTokenCount="80" format="xml" outputFile="${cpd.data.file}" encoding="UTF-8">
<!-- Core bundles -->
<fileset refid="plugin-java-files" />
</cpd>
<xslt in="${cpd.data.file}" style="${cpd.xsl.file}" out="${cpd.report.file}" />
</then>
</if>
</target>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- target: unit tests -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="test.clean" depends="build.test.feature">
<delete dir="${eclipse.test.dir}" />
<mkdir dir="${eclipse.test.dir}" />
<mkdir dir="${eclipse.test.dir}/configuration" />
<unzip src="${buildDirectory}/CI.SMILA/${buildResult}" dest="${eclipse.test.dir}">
<!-- Workaround for wrong paths in zip generated on linux -->
<mapper>
<globmapper from="/libcairo-swt.so" to="libcairo-swt.so" casesensitive="no" />
<globmapper from="/SMILA" to="SMILA" casesensitive="no" />
</mapper>
</unzip>
<!-- Make files executable on linux -->
<chmod file="${eclipse.test.dir}/SMILA" perm="+x" />
<chmod file="${eclipse.test.dir}/libcairo-swt.so" perm="+x" />
<unzip src="${eclipse.test.zip}" dest="${eclipse.test.dir}" />
<unzip src="${buildDirectory}/CI.SMILA/org.eclipse.smila.test.feature-${buildResult}" dest="${eclipse.test.dir}" />
<copy todir="${eclipse.test.dir}/configuration" file="${workspace}/org.eclipse.smila.test/configuration/config.ini" overwrite="true" />
</target>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- target: clear configuration -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="test.clean2default">
<delete dir="${eclipse.test.dir}/configuration" />
<mkdir dir="${eclipse.test.dir}/configuration" />
<delete dir="${eclipse.test.dir}/workspace" />
<mkdir dir="${eclipse.test.dir}/workspace" />
<copy todir="${eclipse.test.dir}/configuration" file="${workspace}/org.eclipse.smila.test/configuration/config.ini" overwrite="true" />
</target>
<!-- =================================================================== -->
<!-- target: test -->
<!-- =================================================================== -->
<target name="test" depends="build, test.clean, test.core, report" />
<target name="test.core" depends="bundle.names.init">
<for param='bundle-under-test' list="${bundles-for-test}" delimiter=" ">
<sequential>
<echo level="info">
######################################################################
# testing @{bundle-under-test}
######################################################################
</echo>
<M_test.bundle.smila bundle.name="@{bundle-under-test}" />
<!--
-->
</sequential>
</for>
</target>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- target: test.report -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="test.report">
<!-- Collect unit test results -->
<copy todir="${junit.dir}" failonerror="false">
<fileset dir="${eclipse.test.dir}">
<include name="*.test.xml" />
</fileset>
</copy>
<!-- Create junit report -->
<echo level="info">Create JUnit report HTML files</echo>
<xslt basedir="${junit.dir}" destdir="${junit.dir}" extension=".html" style="${basedir}/junit.xsl" />
<echo level="info">Collecting JUnit errors/failures</echo>
<delete dir="${reports_errors_txt}" />
<xslt basedir="${junit.dir}" includes="*.xml" destdir="${reports_errors_txt}" extension=".txt" style="${basedir}/junit-out.xslt" />
<!-- output all failed tests to console-->
<concat>
<fileset dir="${reports_errors_txt}" includes="*.txt" />
</concat>
<condition property="test_failed">
<length mode="all" when="greater" length="0">
<fileset dir="${reports_errors_txt}" includes="*.txt" />
</length>
</condition>
<fail if="test_failed" message="At least one unit test failed." />
</target>
<!-- =================================================================== -->
<!-- target: test.list-->
<!-- =================================================================== -->
<target name="test.list" depends="bundle.names.init" description="lists all tests to be executed currently, ie the non exluded test bundles in ${eclipse.test.dir}/plugins">
<concat>
<propertyset>
<propertyref name="bundles-for-test" />
</propertyset>
<filterchain>
<replacestring from=" " to="${line.separator}" />
</filterchain>
</concat>
</target>
<!-- =================================================================== -->
<!-- target: report -->
<!-- =================================================================== -->
<target name="report" depends="test.report, checkstyle, report.jacoco, pmd, pmd-cpd">
</target>
<!-- =================================================================== -->
<!-- target: build-->
<!-- =================================================================== -->
<target name="build" depends="fetch,build.core">
</target>
<!-- =================================================================== -->
<!-- target: "build.core" -->
<!-- =================================================================== -->
<target name="build.core" description="Build Eclipse Product">
<property name="pde.buildfile" value="${pdeBuildPluginPath}/scripts/productBuild/productBuild.xml" />
<java classname="org.eclipse.equinox.launcher.Main" fork="true" failonerror="true">
<arg line="-application org.eclipse.ant.core.antRunner " />
<arg line="-buildfile ${pde.buildfile} " />
<arg line="-DbuildDirectory=${buildDirectory} " />
<arg line="-Declipse.home=${eclipse.home} " />
<arg line="-Declipse.running=true " />
<classpath refid="equinoxLauncherPlugin" />
</java>
</target>
<!-- =================================================================== -->
<!-- target: build.test.feature -->
<!-- =================================================================== -->
<target name="build.test.feature">
<property name="pde.test.buildfile" value="${pdeBuildPluginPath}/scripts/build.xml" />
<java classname="org.eclipse.equinox.launcher.Main" fork="true" failonerror="true">
<arg line="-application org.eclipse.ant.core.antRunner " />
<arg line="-buildfile ${pde.test.buildfile} " />
<arg line="-DbuildDirectory=${buildDirectory} " />
<arg line="-Declipse.home=${eclipse.home} " />
<arg line="-Declipse.running=true " />
<arg line="-Dbuilder=${builder}" />
<classpath refid="equinoxLauncherPlugin" />
</java>
</target>
<!-- =================================================================== -->
<!-- target: build.jmxclient-->
<!-- =================================================================== -->
<target name="build-jmxclient">
<ant antfile="../org.eclipse.smila.management.jmx.client/build.xml" target="all" />
</target>
<!-- =================================================================== -->
<!-- target: final-application-->
<!-- =================================================================== -->
<target name="final-application" depends="versions, build, build-jmxclient">
<for param="path">
<path>
<fileset dir="${buildDirectory}/CI.SMILA" includes="${buildId}-*" />
</path>
<sequential>
<basename property="build.filename" file="@{path}" />
<M_final-application file="${build.filename}" />
<var name="build.filename" unset="true" />
</sequential>
</for>
</target>
<target name="all" depends="clean,fetch,build,build-jmxclient,final-application,test">
<delete dir="${buildDirectory}/${buildLabel}" />
</target>
<target name="all-without-tests" depends="clean,fetch,build,build-jmxclient,final-application">
<delete dir="${buildDirectory}/${buildLabel}" />
</target>
<target name="clean" depends="versions" description="clean PDE working directory">
<delete dir="${buildDirectory}" failonerror="false" />
<delete dir="${basedir}/workspace" failonerror="false" />
</target>
<!-- Generates the Javadocs for all SMILA classes. -->
<target name="javadoc" depends="versions">
<property name="javadoc.title" value="SMILA ${smila.release} API documentation" />
<delete dir="${javadoc.dir}" />
<javadoc destdir="${javadoc.dir}" useexternalfile="yes" windowtitle="${javadoc.title}">
<doctitle><![CDATA[${javadoc.title}]]></doctitle>
<header><![CDATA[${javadoc.title}]]></header>
<classpath>
<pathelement location="${workspace}/SMILA.extension/eclipse/plugins/javax.persistence_1.99.0.jar" />
<pathelement location="${workspace}/javax.xml.bind/jaxb-api.jar" />
</classpath>
<fileset dir="${workspace}" defaultexcludes="yes">
<include name="org.eclipse.smila.*/code/src/org/eclipse/smila/**/*.java" />
<exclude name="org.eclipse.smila.*.test/**/*" />
</fileset>
</javadoc>
</target>
<target name="update">
<echo level="info" message="Updating ${workspace} ..." />
<exec executable="svn" dir="${workspace}" failonerror="false">
<arg line="update" />
</exec>
</target>
</project>