Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
195 lines (164 sloc) 9.47 KB
<?xml version="1.0" encoding="UTF-8"?>
<project name="org.macroing.cit.crypto" default="distribution" basedir=".">
<!--The following properties should be specified by each project. Some of them are the same for all projects, whereas others are not.-->
<property name="java.source" value="1.8"/>
<property name="java.target" value="1.8"/>
<!--<property name="project.class.main" value="[TYPE_FULLY_QUALIFIED_CLASS_NAME_HERE]"/>-->
<property name="project.version" value="1.0.0"/>
<property name="root.directory" location="../.."/>
<property name="vendor.name" value="Macroing.org"/>
<!--The following properties are based on the above properties and don't really need to change.-->
<property name="distribution.directory" location="${root.directory}/distribution"/>
<property name="project.build.directory" location="build"/>
<property name="project.build.main.directory" location="${project.build.directory}/main/java"/>
<property name="project.build.test.directory" location="${project.build.directory}/test/java"/>
<property name="project.documentation.directory" location="doc"/>
<property name="project.documentation.data.directory" location="${project.documentation.directory}/data"/>
<property name="project.documentation.html.directory" location="${project.documentation.directory}/html"/>
<property name="project.documentation.javadoc.directory" location="${project.documentation.directory}/javadoc"/>
<property name="project.name" value="${ant.project.name}"/>
<property name="project.resources.directory" location="resources"/>
<property name="project.resources.distribution.directory" location="${project.resources.directory}/distribution"/>
<property name="project.resources.jar.directory" location="${project.resources.directory}/jar"/>
<property name="project.resources.metainf.directory" location="${project.resources.directory}/metainf"/>
<property name="project.source.directory" location="src"/>
<property name="project.source.main.directory" location="${project.source.directory}/main/java"/>
<property name="project.source.test.directory" location="${project.source.directory}/test/java"/>
<property name="repository.directory" location="${root.directory}/repository"/>
<property name="repository.file" location="${repository.directory}/${project.name}.jar"/>
<condition property="hasMainClass" value="true">
<isset property="project.class.main"/>
</condition>
<condition property="hasNoMainClass" value="true">
<not>
<isset property="project.class.main"/>
</not>
</condition>
<path id="repository.path">
<fileset dir="${repository.directory}" includes="**/*.jar"/>
</path>
<path id="project.build.main.path">
<path refid="repository.path"/>
<pathelement location="${project.build.main.directory}"/>
</path>
<path id="project.build.test.path">
<path refid="repository.path"/>
<pathelement location="${project.build.main.directory}"/>
<pathelement location="${project.build.test.directory}"/>
</path>
<target name="clean" description="Deletes generated directories and files for project ${project.name}.">
<delete dir="${project.build.directory}"/>
<delete dir="${project.documentation.directory}"/>
<delete file="${repository.file}"/>
</target>
<target name="initialize" description="Creates needed directories for project ${project.name}.">
<mkdir dir="${project.build.main.directory}"/>
<mkdir dir="${project.build.test.directory}"/>
<mkdir dir="${project.documentation.data.directory}"/>
<mkdir dir="${project.documentation.html.directory}"/>
<mkdir dir="${project.documentation.javadoc.directory}"/>
<mkdir dir="${project.resources.distribution.directory}"/>
<mkdir dir="${project.resources.jar.directory}"/>
<mkdir dir="${project.resources.metainf.directory}"/>
<mkdir dir="${project.source.main.directory}"/>
<mkdir dir="${project.source.test.directory}"/>
<mkdir dir="${repository.directory}"/>
</target>
<target name="compile.main" depends="initialize" description="Compiles the main Java source code for project ${project.name}.">
<javac source="${java.source}" target="${java.target}" srcdir="${project.source.main.directory}" destdir="${project.build.main.directory}" classpathref="repository.path" includeAntRuntime="false" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
<compilerarg value="-Xlint:all"/>
</javac>
</target>
<target name="compile.test" depends="compile.main" description="Compiles the test Java source code for project ${project.name}.">
<javac source="${java.source}" target="${java.target}" srcdir="${project.source.test.directory}" destdir="${project.build.test.directory}" classpathref="project.build.main.path" includeAntRuntime="false" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
<compilerarg value="-Xlint:all"/>
</javac>
</target>
<target name="test" depends="compile.test" description="Runs JUnit tests for project ${project.name}.">
<junit printsummary="true">
<classpath refid="project.build.test.path"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest todir="${project.documentation.data.directory}">
<fileset dir="${project.build.test.directory}" includes="**/*Test.class"/>
</batchtest>
</junit>
</target>
<target name="test.report" depends="test" description="Generates JUnit test reports for project ${project.name}.">
<junitreport todir="${project.documentation.data.directory}">
<fileset dir="${project.documentation.data.directory}">
<include name="TEST-*.xml"/>
</fileset>
<!--The report task could not be used due to bugs in previous versions of required libraries (either Apache Ant, Apache Xalan, ...). It was in Java 7.-->
<report format="frames" todir="${project.documentation.html.directory}"/>
</junitreport>
</target>
<target name="jar" depends="compile.main" description="Generates a Jar file for project ${project.name}.">
<antcall target="jar.1"/>
<antcall target="jar.2"/>
</target>
<target name="jar.1" depends="compile.main" description="Generates a Jar file for project ${project.name}." if="hasNoMainClass">
<tstamp>
<format property="build.date" pattern="EEEE, d MMMM yyyy"/>
<format property="build.time" pattern="hh:mm a"/>
</tstamp>
<jar destfile="${repository.file}" basedir="${project.build.main.directory}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Specification-Title" value="${project.name}"/>
<attribute name="Specification-Version" value="${project.version}"/>
<attribute name="Specification-Vendor" value="${vendor.name}"/>
<attribute name="Implementation-Title" value="${project.name}"/>
<attribute name="Implementation-Version" value="${project.version} - built at ${build.time} on ${build.date}"/>
<attribute name="Implementation-Vendor" value="${vendor.name}"/>
</manifest>
<fileset dir="${project.resources.jar.directory}" excludes="**/.*/**"/>
<metainf dir="${project.resources.metainf.directory}" excludes="**/.*/**"/>
</jar>
</target>
<target name="jar.2" depends="compile.main" description="Generates a Jar file for project ${project.name}." if="hasMainClass">
<tstamp>
<format property="build.date" pattern="EEEE, d MMMM yyyy"/>
<format property="build.time" pattern="hh:mm a"/>
</tstamp>
<jar destfile="${repository.file}" basedir="${project.build.main.directory}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="${project.class.main}"/>
<attribute name="Specification-Title" value="${project.name}"/>
<attribute name="Specification-Version" value="${project.version}"/>
<attribute name="Specification-Vendor" value="${vendor.name}"/>
<attribute name="Implementation-Title" value="${project.name}"/>
<attribute name="Implementation-Version" value="${project.version} - built at ${build.time} on ${build.date}"/>
<attribute name="Implementation-Vendor" value="${vendor.name}"/>
</manifest>
<fileset dir="${project.resources.jar.directory}" excludes="**/.*/**"/>
<metainf dir="${project.resources.metainf.directory}" excludes="**/.*/**"/>
</jar>
</target>
<target name="javadoc" depends="compile.main" description="Generates Javadoc for project ${project.name}.">
<javadoc encoding="UTF-8" charset="UTF-8" docencoding="UTF-8" sourcepath="${project.source.main.directory}" destdir="${project.documentation.javadoc.directory}" author="true" version="true" use="true" access="protected" linksource="false" windowtitle="${project.name} API">
<classpath>
<path refid="repository.path"/>
<pathelement location="${project.build.main.directory}"/>
</classpath>
</javadoc>
</target>
<target name="distribution" depends="test.report, jar, javadoc">
<delete dir="${distribution.directory}/${project.name}-${project.version}"/>
<mkdir dir="${distribution.directory}/${project.name}-${project.version}"/>
<copy todir="${distribution.directory}/${project.name}-${project.version}">
<fileset dir="${repository.directory}" includes="${project.name}.jar"/>
<fileset dir="${project.resources.distribution.directory}"/>
<fileset dir="." includes="COPYING"/>
<fileset dir="." includes="COPYING.LESSER"/>
<fileset dir="." includes="README.md"/>
</copy>
<copy todir="${distribution.directory}/${project.name}-${project.version}/doc">
<fileset dir="${project.documentation.javadoc.directory}"/>
</copy>
<copy todir="${distribution.directory}/${project.name}-${project.version}/src">
<fileset dir="${project.source.main.directory}"/>
</copy>
</target>
</project>