All Downloads are FREE. Search and download functionalities are using the official Maven repository.

MOEAFramework-3.7.auxiliary.checkstyle.build.xml Maven / Gradle / Ivy

<?xml version="1.0"?>
<!--
Copyright 2009-2023 David Hadka

This file is part of the MOEA Framework.

The MOEA Framework is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by 
the Free Software Foundation, either version 3 of the License, or (at your 
option) any later version.

The MOEA Framework is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public License 
along with the MOEA Framework.  If not, see <http://www.gnu.org/licenses/>.



Use of these build scripts requires Apache Ant to be installed.  See
<http://ant.apache.org/> for instructions on installing Apache Ant.
-->
<project name="MOEA Framework Checkstyle" basedir="../../" default="check-style">

	<!-- Loads properties from properties file and environment -->
	<property file="META-INF/build.properties" />
	<property environment="env" />
	
	<!-- The working folder for these Ant build targets -->
	<property name="build" value="build" />
	
	<!-- The location of the checkstyle library and configuration files -->
	<property name="checkstyle-path" value="auxiliary/checkstyle" />
	<property name="checkstyle-version" value="10.5.0" />

	<path id="classpath">
		<fileset dir="${checkstyle-path}" includes="*.jar" />
	</path>
	
	<target name="has-checkstyle">
		<available file="${checkstyle-path}/checkstyle-${checkstyle-version}-all.jar" property="checkstyle-exists" />
	</target>
	
	<target name="get-checkstyle" depends="has-checkstyle" unless="checkstyle-exists">
		<get src="https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${checkstyle-version}/checkstyle-${checkstyle-version}-all.jar"
			dest="${checkstyle-path}/checkstyle-${checkstyle-version}-all.jar" />
	</target>

	<target name="check-style" depends="get-checkstyle">
		<delete dir="${build}" />
		<mkdir dir="${build}" />
		
		<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
		         classpathref="classpath" />
		
		<checkstyle config="checks.xml" failOnViolation="false" classpathref="classpath"
				failureProperty="checkstyle.failed">
			<formatter type="xml" tofile="${build}/checkstyle-result.xml" />
			<fileset dir="auxiliary" includes="**/*.c,**/*.h" />
			<fileset dir="src" includes="**/*.java" />
			<fileset dir="test" includes="**/*.java" />
			<fileset dir="examples" includes="**/*.java" />
		</checkstyle>
		
		<!-- Convert relative path of build to absolute path -->
		<property name="output.dir" location="${build}" />
		
		<xslt in="${build}/checkstyle-result.xml" out="${build}/checkstyle-result.html"
				style="${checkstyle-path}/checkstyle-frames-errors.xsl">
			<param name="output.dir" expression="${output.dir}" />
		</xslt>

		<fail if="checkstyle.failed">Checkstyle identified one or more violations!  See build/index.html for details.</fail>
	</target>

</project>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy