Created
November 23, 2011 23:10
-
-
Save froop/1390207 to your computer and use it in GitHub Desktop.
[Java][Ant] Jenkinsさん用Webアプリbuild.xmlサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE configuration> | |
| <!-- 参考: Jenkinsではじめるビルド職人入門 --> | |
| <!-- http://gihyo.jp/dp/ebook/2011/978-4-7741-4952-3 --> | |
| <project basedir="." default="build" name="sample"> | |
| <property name="tool.dir" value="tool"/> | |
| <property name="cobertura.home" value="${tool.dir}/cobertura-1.9.4.1"/> | |
| <property name="checkstyle.home" value="${tool.dir}/checkstyle-5.5"/> | |
| <property name="findbugs.home" value="${tool.dir}/findbugs-1.3.9"/> | |
| <property name="javancss.home" value="${tool.dir}/javancss-32.53"/> | |
| <property name="cpd.home" value="${tool.dir}/pmd-bin-4.3"/> | |
| <path id="cobertura.classpath"> | |
| <fileset dir="${cobertura.home}"> | |
| <include name="cobertura.jar"/> | |
| <include name="lib/**/*.jar"/> | |
| </fileset> | |
| </path> | |
| <taskdef resource="checkstyletask.properties" | |
| classpath="${checkstyle.home}/checkstyle-5.5-all.jar"/> | |
| <taskdef name="findbugs" | |
| classname="edu.umd.cs.findbugs.anttask.FindBugsTask" | |
| classpath="${findbugs.home}/lib/findbugs-ant.jar"/> | |
| <taskdef resource="tasks.properties" | |
| classpathref="cobertura.classpath"/> | |
| <taskdef name="javancss" | |
| classname="javancss.JavancssAntTask"> | |
| <classpath> | |
| <fileset dir="${javancss.home}/lib" includes="*.jar"/> | |
| </classpath> | |
| </taskdef> | |
| <taskdef name="cpd" | |
| classname="net.sourceforge.pmd.cpd.CPDTask" | |
| classpath="${cpd.home}/lib/pmd-4.3.jar"/> | |
| <property name="javac.debug" value="true"/> | |
| <property name="javac.debuglevel" value="source,lines,vars"/> | |
| <property name="javac.target" value="1.6"/> | |
| <property name="javac.source" value="1.6"/> | |
| <property name="javac.encoding" value="utf-8"/> | |
| <property name="src.java.dir" value="src"/> | |
| <property name="src.prop.dir" value="prop"/> | |
| <property name="src.web.dir" value="WebContent"/> | |
| <property name="dest.dir" value="dest"/> | |
| <property name="dest.java.dir" value="${dest.dir}/classes"/> | |
| <property name="war.file" value="${dest.dir}/${ant.project.name}.war"/> | |
| <path id="base.classpath"> | |
| <fileset dir="lib"/> | |
| <fileset dir="${src.web.dir}/WEB-INF/lib"/> | |
| </path> | |
| <property name="src.test.dir" value="test"/> | |
| <property name="dest.test.dir" value="${dest.dir}/test"/> | |
| <property name="dest.test.java.dir" value="${dest.test.dir}/classes"/> | |
| <property name="dest.instrument.dir" value="${dest.dir}/instrument"/> | |
| <path id="test.classpath"> | |
| <fileset dir="lib/test"/> | |
| </path> | |
| <target name="build" depends="clean,test,build-war"/> | |
| <target name="inspection" depends="clean,test,findbugs,checkstyle,count,cpd,jdepend"/> | |
| <target name="build-war" description="warファイル生成" depends="compile-main"> | |
| <war destfile="${war.file}" webxml="${src.web.dir}/WEB-INF/web.xml"> | |
| <fileset dir="${src.web.dir}"> | |
| <include name="**/*"/> | |
| </fileset> | |
| <classes dir="${dest.java.dir}"/> | |
| </war> | |
| </target> | |
| <target name="compile-main" description="プロダクトコードをコンパイル"> | |
| <mkdir dir="${dest.java.dir}"/> | |
| <copy todir="${dest.java.dir}" includeemptydirs="false"> | |
| <fileset dir="${src.java.dir}"> | |
| <exclude name="**/*.java"/> | |
| </fileset> | |
| <fileset dir="${src.prop.dir}"/> | |
| </copy> | |
| <javac destdir="${dest.java.dir}" | |
| encoding="${javac.encoding}" includeAntRuntime="off" | |
| debug="${javac.debug}" debuglevel="${javac.debuglevel}" | |
| source="${javac.source}" target="${javac.target}"> | |
| <src path="${src.java.dir}"/> | |
| <classpath refid="base.classpath"/> | |
| </javac> | |
| </target> | |
| <target name="clean" description="生成ファイルを削除"> | |
| <delete dir="${dest.dir}"/> | |
| <delete file="cobertura.ser"/> | |
| </target> | |
| <target name="test" description="テストの実行" depends="compile-test"> | |
| <delete file="cobertura.ser"/> | |
| <delete dir="${dest.instrument.dir}"/> | |
| <cobertura-instrument todir="${dest.instrument.dir}"> | |
| <fileset dir="${dest.java.dir}"> | |
| <include name="**/*.class"/> | |
| </fileset> | |
| </cobertura-instrument> | |
| <junit fork="on" forkmode="perBatch" printsummary="on"> | |
| <classpath location="${dest.test.java.dir}"/> | |
| <classpath location="${dest.instrument.dir}"/> | |
| <classpath refid="base.classpath"/> | |
| <classpath refid="test.classpath"/> | |
| <classpath refid="cobertura.classpath"/> | |
| <formatter type="xml"/> | |
| <batchtest todir="${dest.test.dir}"> | |
| <fileset dir="${dest.test.java.dir}"/> | |
| </batchtest> | |
| </junit> | |
| <cobertura-report format="xml" destdir="${dest.dir}" | |
| encoding="${javac.encoding}"> | |
| <fileset dir="${src.java.dir}"> | |
| <include name="**/*.java"/> | |
| </fileset> | |
| </cobertura-report> | |
| </target> | |
| <target name="compile-test" depends="compile-main"> | |
| <mkdir dir="${dest.test.java.dir}"/> | |
| <copy todir="${dest.test.java.dir}"> | |
| <fileset dir="${src.test.dir}"> | |
| <exclude name="**/*.java"/> | |
| </fileset> | |
| </copy> | |
| <javac destdir="${dest.test.java.dir}" | |
| encoding="${javac.encoding}" includeAntRuntime="off" | |
| debug="${javac.debug}" debuglevel="${javac.debuglevel}" | |
| source="${javac.source}" target="${javac.target}"> | |
| <src path="${src.test.dir}"/> | |
| <classpath refid="base.classpath"/> | |
| <classpath refid="test.classpath"/> | |
| <classpath location="${dest.java.dir}"/> | |
| </javac> | |
| </target> | |
| <target name="checkstyle" description="静的解析Checkstyle"> | |
| <mkdir dir="${dest.dir}"/> | |
| <checkstyle config="${checkstyle.home}/sun_checks.xml" failOnViolation="no"> | |
| <fileset dir="${src.java.dir}" includes="**/*.java"/> | |
| <formatter type="xml" toFile="${dest.dir}/checkstyle-result.xml"/> | |
| </checkstyle> | |
| </target> | |
| <target name="findbugs" description="静的解析FindBugs" depends="compile-main"> | |
| <findbugs home="${findbugs.home}" output="xml" | |
| outputFile="${dest.dir}/findbugs-result.xml"> | |
| <sourcePath path="${src.java.dir}"/> | |
| <class location="${dest.java.dir}"/> | |
| <auxClasspath refid="base.classpath"/> | |
| </findbugs> | |
| </target> | |
| <target name="count" description="ステップ数"> | |
| <javancss srcdir="${src.java.dir}" generateReport="true" | |
| outputfile="${dest.dir}/javancss-result.xml" | |
| format="xml"/> | |
| </target> | |
| <target name="cpd" description="コード重複"> | |
| <cpd minimumTokenCount="10" outputFile="${dest.dir}/cpd-result.xml" | |
| format="xml" encoding="${javac.encoding}"> | |
| <fileset dir="${src.java.dir}"> | |
| <include name="**/*.java"/> | |
| </fileset> | |
| </cpd> | |
| </target> | |
| <target name="jdepend" description="パッケージ依存関係"> | |
| <jdepend format="xml" outputfile="${dest.dir}/jdepend-result.xml"> | |
| <exclude name="java.*"/> | |
| <exclude name="javax.*"/> | |
| <exclude name="org.apache.*"/> | |
| <classespath> | |
| <pathelement location="${dest.java.dir}" /> | |
| </classespath> | |
| </jdepend> | |
| </target> | |
| </project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment