Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
485 lines (394 sloc) 18.1 KB
<?xml version="1.0" encoding="utf-8"?>
<project name="importlist" default="all" basedir=".">
<target name="-init">
<property name="src" value="src/main/java"/>
<property name="resources" value="src/main/resources"/>
<property name="test" value="src/test/java"/>
<property name="lib" value="lib"/>
<property name="dist" value="target"/>
<property name="build" value="${dist}/classes"/>
<property name="docs" value="docs"/>
<property name="log" value="logs"/>
<property name="privkeyfile" value="${resources}/priv_key"/>
<property name="pubkeyfile" value="${resources}/pub_key"/>
<property name="privkeyid" value="99"/>
<property name="debug" value="on"/>
<property name="optimize" value="on"/>
<property name="descriptor.file"
value="${src}/com/moneydance/modules/features/importlist/meta_info.dict"/>
<property name="jar.file"
value="${dist}/importlist.mxt"/>
<property file="user.properties" />
<available file="${privkeyfile}" property="privkeyfile.present"/>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpath="${lib}/checkstyle-6.14.1-all.jar"/>
<taskdef name="pmd"
classname="net.sourceforge.pmd.ant.PMDTask"
classpath="${lib}/pmd-core-5.4.1.jar;${lib}/pmd-java-5.4.1.jar;${lib}/jaxen-1.1.6.jar;${lib}/asm-5.0.4.jar;${lib}/commons-io-2.4.jar;${lib}/commons-lang3-3.4.jar"/>
<taskdef resource="proguard/ant/task.properties"
classpath="${lib}/proguard-5.2.1.jar" />
<path id="compile.classpath">
<pathelement path="${lib}/moneydance.jar"/>
<pathelement path="${lib}/commons-io-2.4.jar"/>
<pathelement path="${lib}/commons-lang-2.6.jar"/>
<pathelement path="${lib}/commons-lang3-3.4.jar"/>
<pathelement path="${lib}/commons-configuration-1.10.jar"/>
<pathelement path="${lib}/google-analytics-java-importlist-1.1.2.jar"/>
<pathelement path="${lib}/httpclient-importlist-4.3.jar"/>
<pathelement path="${lib}/httpcore-importlist-4.3.jar"/>
<pathelement path="${lib}/slf4j-api-1.7.13.jar"/>
</path>
<path id="test.classpath">
<pathelement path="${lib}/moneydance.jar"/>
<pathelement path="${lib}/commons-configuration-1.10.jar"/>
<pathelement path="${lib}/commons-io-2.4.jar"/>
<pathelement path="${lib}/commons-lang-2.6.jar"/>
<pathelement path="${lib}/commons-lang3-3.4.jar"/>
<pathelement path="${lib}/commons-logging-1.2.jar"/>
<pathelement path="${lib}/google-analytics-java-importlist-1.1.2.jar"/>
<pathelement path="${lib}/httpclient-importlist-4.3.jar"/>
<pathelement path="${lib}/httpcore-importlist-4.3.jar"/>
<pathelement path="${lib}/java-hamcrest-2.0.0.0.jar"/>
<pathelement path="${lib}/jmockit-coverage-1.5.jar"/>
<pathelement path="${lib}/jmockit-1.5.jar"/>
<pathelement path="${lib}/junit-4.12.jar"/>
<pathelement path="${lib}/slf4j-api-1.7.13.jar"/>
<pathelement path="${lib}/slf4j-nop-1.7.13.jar"/>
<pathelement path="${build}"/>
</path>
<path id="manifest.classpath">
<pathelement path="${lib}/moneydance.jar"/>
</path>
<path id="sign.classpath">
<pathelement path="${lib}/moneydance.jar"/>
<pathelement path="${lib}/extadmin-4.0.jar"/>
</path>
</target>
<target name="-prepare" depends="-init">
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
</target>
<target name="clean"
depends="-init"
description="Wipe the slate clean, to be used before starting the build process.">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
<target name="gendeps"
depends="-init"
description="Generates custom dependencies.">
<antcall target="-genhttp">
<param name="dep.name" value="httpcore"/>
</antcall>
<antcall target="-genhttp">
<param name="dep.name" value="httpclient"/>
</antcall>
<antcall target="-genanalytics"/>
</target>
<target name="-genhttp" depends="-init">
<!-- Clone tagged version from GitHub repository -->
<exec executable="git">
<arg line="clone -b 4.3 --single-branch git@github.com:apache/${dep.name}.git --depth=1 ${dist}/${dep.name}"/>
</exec>
<!-- Replace default httpcore dependency by generated patch (only applies to httpclient) -->
<property name="httpcore.jar" location="${lib}/httpcore-importlist-4.3.jar"/>
<property name="replacevalue" value="&lt;artifactId&gt;httpcore&lt;/artifactId&gt;
&lt;scope&gt;system&lt;/scope&gt;
&lt;systemPath&gt;${httpcore.jar}&lt;/systemPath&gt;"/>
<replace file="${dist}/${dep.name}/${dep.name}/pom.xml" value="${replacevalue}">
<replacetoken>&lt;artifactId&gt;httpcore&lt;/artifactId&gt;
&lt;scope&gt;compile&lt;/scope&gt;</replacetoken>
</replace>
<!-- Rename folders in order to match new package names -->
<mkdir dir="${dist}/${dep.name}/${dep.name}/src/main/java/com/moneydance/modules/features/importlist"/>
<mkdir dir="${dist}/${dep.name}/${dep.name}/src/main/java-deprecated/com/moneydance/modules/features/importlist"/>
<mkdir dir="${dist}/${dep.name}/${dep.name}/src/main/resources/com/moneydance/modules/features/importlist"/>
<mkdir dir="${dist}/${dep.name}/${dep.name}/src/test/java/com/moneydance/modules/features/importlist"/>
<move file="${dist}/${dep.name}/${dep.name}/src/main/java/org/apache" tofile="${dist}/${dep.name}/${dep.name}/src/main/java/com/moneydance/modules/features/importlist"/>
<move file="${dist}/${dep.name}/${dep.name}/src/main/java-deprecated/org/apache" tofile="${dist}/${dep.name}/${dep.name}/src/main/java-deprecated/com/moneydance/modules/features/importlist"/>
<move file="${dist}/${dep.name}/${dep.name}/src/main/resources/org/apache" tofile="${dist}/${dep.name}/${dep.name}/src/main/resources/com/moneydance/modules/features/importlist"/>
<move file="${dist}/${dep.name}/${dep.name}/src/test/java/org/apache" tofile="${dist}/${dep.name}/${dep.name}/src/test/java/com/moneydance/modules/features/importlist"/>
<!-- Search and replace Java source files -->
<replace dir="${dist}/${dep.name}/${dep.name}/src">
<include name="**/*.java"/>
<replacetoken>org.apache.http</replacetoken>
<replacevalue>com.moneydance.modules.features.importlist.apache.http</replacevalue>
</replace>
<!-- Generate new JAR file -->
<exec executable="mvn">
<arg line="package -f ${dist}/${dep.name}/${dep.name}/pom.xml -Dmaven.javadoc.skip=true"/>
</exec>
<copy file="${dist}/${dep.name}/${dep.name}/target/${dep.name}-4.3.jar"
tofile="${lib}/${dep.name}-importlist-4.3.jar"/>
</target>
<target name="-genanalytics" depends="-init">
<!-- Clone tagged version from GitHub repository -->
<exec executable="git">
<arg line="clone -b google-analytics-java-1.1.2 --single-branch git@github.com:brsanthu/google-analytics-java.git --depth=1 ${dist}/google-analytics-java"/>
</exec>
<!-- Replace httpcore/httpclient dependencies by generated patches -->
<property name="httpcore.jar" location="${lib}/httpcore-importlist-4.3.jar"/>
<property name="httpclient.jar" location="${lib}/httpclient-importlist-4.3.jar"/>
<property name="replacevalue" value="
&lt;dependency&gt;
&lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
&lt;artifactId&gt;httpcore&lt;/artifactId&gt;
&lt;version&gt;4.3&lt;/version&gt;
&lt;scope&gt;system&lt;/scope&gt;
&lt;systemPath&gt;${httpcore.jar}&lt;/systemPath&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
&lt;artifactId&gt;httpclient&lt;/artifactId&gt;
&lt;version&gt;${httpclient-version}&lt;/version&gt;
&lt;scope&gt;system&lt;/scope&gt;
&lt;systemPath&gt;${httpclient.jar}&lt;/systemPath&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
&lt;groupId&gt;commons-logging&lt;/groupId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;"/>
<replace file="${dist}/google-analytics-java/pom.xml" value="${replacevalue}">
<replacetoken>&lt;dependency&gt;
&lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
&lt;artifactId&gt;httpclient&lt;/artifactId&gt;
&lt;version&gt;${httpclient-version}&lt;/version&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
&lt;groupId&gt;commons-logging&lt;/groupId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;</replacetoken>
</replace>
<!-- Search and replace Java source files -->
<replace dir="${dist}/google-analytics-java/src">
<include name="**/*.java"/>
<replacetoken>org.apache.http</replacetoken>
<replacevalue>com.moneydance.modules.features.importlist.apache.http</replacevalue>
</replace>
<!-- Generate new JAR file -->
<exec executable="mvn">
<arg line="package -f ${dist}/google-analytics-java/pom.xml -Dmaven.javadoc.skip=true"/>
</exec>
<copy file="${dist}/google-analytics-java/target/google-analytics-java-1.1.2.jar"
tofile="${lib}/google-analytics-java-importlist-1.1.2.jar"/>
</target>
<target name="genkeys"
depends="-init"
description="Generates a passphrase-protected key pair.">
<java classpathref="sign.classpath"
classname="com.moneydance.admin.KeyAdmin">
<arg value="genkey"/>
<arg value="${privkeyfile}"/>
<arg value="${pubkeyfile}"/>
</java>
</target>
<target name="compile" depends="-prepare">
<javac source="1.7"
target="1.7"
srcdir="${src}"
destdir="${build}"
debug="${debug}"
optimize="${optimize}"
classpathref="compile.classpath"
includeantruntime="true"
includes="com/moneydance/modules/features/importlist/**"
bootclasspath="${boot.classpath}"/>
</target>
<target name="-mxt" depends="compile">
<manifestclasspath property="jar.classpath"
jarfile="${jar.file}">
<classpath refid="manifest.classpath"/>
</manifestclasspath>
<jar jarfile="${build}/external-libs.jar">
<zipgroupfileset dir="${lib}">
<include name="commons-io-2.4.jar"/>
<include name="commons-lang-2.6.jar"/>
<include name="commons-lang3-3.4.jar"/>
<include name="commons-configuration-1.10.jar"/>
<include name="commons-logging-1.2.jar"/>
<include name="google-analytics-java-importlist-1.1.2.jar"/>
<include name="httpclient-importlist-4.3.jar"/>
<include name="httpcore-importlist-4.3.jar"/>
<include name="slf4j-api-1.7.13.jar"/>
<include name="slf4j-nop-1.7.13.jar"/>
</zipgroupfileset>
</jar>
<!-- Wait for one second to avoid getting warnings about the
files having modification dates in the future. -->
<sleep seconds="1"/>
<!-- run the timestamp task -->
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<jar destfile="${jar.file}">
<fileset dir="" includes="NOTICE"/>
<fileset dir="" includes="LICENSE"/>
<fileset dir="${src}" includes="
com/moneydance/modules/features/importlist/meta_info.dict"/>
<fileset dir="${resources}" includes="*"/>
<fileset dir="${build}"
includes="com/moneydance/modules/features/importlist/**"/>
<manifest>
<attribute name="Class-Path"
value="${jar.classpath}"/>
<attribute name="Built-By"
value="${user.name}" />
<attribute name="Built-Date"
value="${TODAY}"/>
</manifest>
<zipfileset src="${build}/external-libs.jar">
<exclude name="*"/>
<exclude name="META-INF/**/*"/>
</zipfileset>
</jar>
<move file="${jar.file}" tofile="${build}/importlist.jar"/>
<proguard configuration="proguard.cfg" forceprocessing="true">
<injar location="${build}/importlist.jar" />
<outjar location="${build}/proguard-importlist.jar" />
</proguard>
<move file="${build}/proguard-importlist.jar" tofile="${jar.file}"/>
</target>
<target name="sign"
depends="-init"
if="privkeyfile.present"
description="Signs an MXT file with a private key that must already exist.">
<java classpathref="sign.classpath"
classname="com.moneydance.admin.KeyAdmin">
<arg value="signextjar"/>
<arg value="${privkeyfile}"/>
<arg value="${privkeyid}"/>
<arg value="importlist"/>
<arg line="${jar.file}"/>
</java>
<move file="s-importlist.mxt" tofile="${jar.file}"/>
</target>
<target name="dist" depends="-prepare" description="Produces the distributable.">
<antcall target="compile"/>
<antcall target="-mxt"/>
</target>
<target name="test" depends="compile"
description="Executes JUnit's test suite and generates an HTML report using JMockit Coverage.">
<javac source="1.7"
target="1.7"
srcdir="${test}"
destdir="${build}"
debug="${debug}"
optimize="${optimize}"
classpathref="test.classpath"
includeantruntime="true"
includes="com/moneydance/modules/features/importlist/**"
bootclasspath="${boot.classpath}"/>
<copy todir="${build}">
<fileset dir="${src}" includes="
com/moneydance/modules/features/importlist/meta_info.dict"/>
</copy>
<copy todir="${build}">
<fileset dir="${resources}" includes="*"/>
</copy>
<junit printsummary="yes"
haltonfailure="yes"
showoutput="true"
enabletestlistenerevents="true"
fork="yes">
<classpath refid="test.classpath"/>
<test name="com.moneydance.modules.features.importlist.AllUnitTests"/>
<sysproperty key="jmockit-coverage-excludes"
value=".*AllUnitTests|.*AllTests|.*Stub.*|.*Mock.*|.*ConsoleRunner.*"/>
<sysproperty key="jmockit-coverage-outputDir"
value="${docs}/coverage-report"/>
</junit>
</target>
<target name="main" depends="-prepare">
<antcall target="dist"/>
<antcall target="test"/>
</target>
<target name="all" depends="-prepare">
<antcall target="clean"/>
<antcall target="dist"/>
<antcall target="sign" />
<antcall target="test" />
</target>
<target name="javadocs"
depends="-init"
description="Creates Javadoc documentation with references to external documentations.">
<delete>
<fileset dir="${docs}/api" includes="**/*"/>
</delete>
<javadoc packagenames="com.moneydance.modules.features.importlist.*"
classpathref="compile.classpath"
sourcepath="${src}"
excludepackagenames=""
defaultexcludes="true"
destdir="${docs}/api"
access="package"
author="true"
version="true"
use="true"
windowtitle="Import List for Moneydance"
linksource="true"
verbose="no">
<doctitle><![CDATA[<h1>Import List for Moneydance</h1>]]></doctitle>
<link href="https://docs.oracle.com/javase/7/docs/api/"/>
<link href="http://moneydance.com/dev/apidoc/"/>
<link href="https://brsanthu.github.io/google-analytics-java/javadocs/"/>
<link href="http://www.slf4j.org/apidocs/"/>
<link href="http://commons.apache.org/configuration/apidocs/"/>
<link href="https://commons.apache.org/proper/commons-io/javadocs/api-2.4/"/>
<link href="https://commons.apache.org/proper/commons-lang/javadocs/api-3.4/"/>
<link href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/"/>
<link href="https://commons.apache.org/proper/commons-logging/javadocs/api-release/"/>
<footer><![CDATA[
<a href="https://github.com/my-flow/importlist">
Import List on GitHub
</a>
]]></footer>
</javadoc>
</target>
<target name="checkstyle-report"
depends="-init"
description="Generates a report of code convention violations.">
<delete>
<fileset dir="${docs}/checkstyle-report" includes="**/*"/>
</delete>
<checkstyle config="${docs}/importlist_checks.xml" failOnViolation="false">
<fileset dir="${src}" includes="**/*.java"/>
<formatter type="xml" tofile="${docs}/checkstyle_report.xml"/>
</checkstyle>
<xslt in="${docs}/checkstyle_report.xml"
out="${docs}/checkstyle-report/index.html"
style="${docs}/checkstyle-noframes-sorted.xsl"/>
</target>
<target name="pmd-report"
depends="-init"
description="Runs a set of static code analysis rules and generates a list of problems found.">
<delete>
<fileset dir="${docs}/pmd-report" includes="**/*"/>
</delete>
<pmd shortFilenames="true">
<ruleset>java-basic</ruleset>
<ruleset>java-braces</ruleset>
<ruleset>java-clone</ruleset>
<ruleset>java-codesize</ruleset>
<ruleset>java-comments</ruleset>
<ruleset>java-design</ruleset>
<ruleset>java-empty</ruleset>
<ruleset>java-finalizers</ruleset>
<ruleset>java-imports</ruleset>
<ruleset>java-logging-jakarta-commons</ruleset>
<ruleset>java-migrating</ruleset>
<ruleset>java-naming</ruleset>
<ruleset>java-strictexception</ruleset>
<ruleset>java-strings</ruleset>
<ruleset>java-sunsecure</ruleset>
<ruleset>java-typeresolution</ruleset>
<ruleset>java-unnecessary</ruleset>
<ruleset>java-unusedcode</ruleset>
<fileset dir="${src}" includes="**/*.java"/>
<formatter type="html" toFile="${docs}/pmd-report/pmd-report.html"/>
</pmd>
</target>
</project>