https://github.com/rzwitserloot/lombok.patcher
Raw File
Tip revision: e164d6c315c358a36fb6325a241ea44948a35bf9 authored by Reinier Zwitserloot on 29 April 2010, 12:37:30 UTC
Pre-release version bump.
Tip revision: e164d6c
build.xml
<!--
  Copyright © 2009, 2010 Reinier Zwitserloot and Roel Spilker.
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
-->
<project name="lombok.patcher" default="dist" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus">
	<property name="ivy.retrieve.pattern" value="lib/[conf]/[artifact].[ext]" />
	<available file="lib/ivyplusplus.jar" property="ivyplusplus.available" />
	
	<target name="download-ipp" unless="ivyplusplus.available">
		<mkdir dir="lib" />
		<get src="http://projectlombok.org/downloads/ivyplusplus.jar" dest="lib/ivyplusplus.jar" usetimestamp="true" />
	</target>
	
	<target name="ensure-ipp" depends="download-ipp">
		<taskdef classpath="lib/ivyplusplus.jar" resource="com/zwitserloot/ivyplusplus/antlib.xml" uri="antlib:com.zwitserloot.ivyplusplus" />
	</target>
	
	<path id="build.path">
		<fileset dir="lib/build">
			<include name="*.jar" />
		</fileset>
	</path>
	
	<path id="runtime.path">
		<fileset dir="lib/runtime">
			<include name="*.jar" />
		</fileset>
	</path>
	
	<path id="test.path">
		<fileset dir="lib/test">
			<include name="*.jar" />
		</fileset>
	</path>
	
	<target name="-pointlessCheck">
		<uptodate property="pointless" targetfile="dist/lombok-patcher.jar">
			<srcfiles dir="." includes="src/**/*.java test/**/*.java lib/build/** lib/runtime/**" />
		</uptodate>
	</target>
	
	<target name="clean" description="Deletes build artefacts.">
		<delete dir="build" quiet="true" />
	</target>
	
	<target name="distclean" depends="clean" description="Deletes everything downloaded or built by this script.">
		<delete dir="dist" quiet="true" />
		<delete dir="lib" quiet="true" />
		<delete file=".classpath" quiet="true" />
		<delete file=".project" quiet="true" />
		<delete dir=".settings" quiet="true" />
	</target>
	
	<target name="version" description="Shows the version number">
		<mkdir dir="build/pack" />
		<javac srcdir="src" debug="on" destdir="build/pack" target="1.5" source="1.5" includes="lombok/patcher/Version.java" />
		<java
			classname="lombok.patcher.Version"
			classpath="build/pack"
			failonerror="true"
			output="build/version.txt" />
		<ivy:loadversion property="lombok.patcher.version" file="build/version.txt" />
		<echo level="info">Lombok patcher version: ${lombok.patcher.version}</echo>
	</target>
	
	<target name="unpackLibs" depends="ensureRuntimeDeps" unless="pointless">
		<unjar dest="build/pack">
			<path refid="runtime.path" />
		</unjar>
	</target>
	
	<target name="compile" depends="unpackLibs, ensureBuildDeps" description="Compiles lombok.patcher" unless="pointless">
		<ivy:javac-copy srcdir="src" destdir="build/pack" target="1.5" source="1.5">
			<classpath refid="build.path" />
		</ivy:javac-copy>
	</target>
	
	<target name="compileTests" depends="compile, ensureTestDeps" description="Compiles the unit tests" unless="skipTests">
		<ivy:javac-copy srcdir="test" destdir="build/tests" target="1.5" source="1.5">
			<classpath path="build/pack" />
			<classpath refid="test.path" />
		</ivy:javac-copy>
	</target>
	
	<target name="-test.quiet">
		<property name="tests.quiet" value="true" />
	</target>
	
	<target name="-test-setup">
		<condition property="skipTests">
			<isset property="pointless" />
		</condition>
	</target>
	
	<target name="-test" depends="-test-setup, compileTests" unless="skipTests">
		<junit haltonfailure="yes" fork="on">
			<formatter type="plain" usefile="false" unless="tests.quiet" />
			<classpath path="build/pack" />
			<classpath path="build/tests" />
			<classpath refid="test.path" />
			<batchtest>
				<fileset dir="test">
					<include name="**/Test*.java" />
				</fileset>
			</batchtest>
		</junit>
		<echo level="info">All tests successful.</echo>
	</target>
	
	<target name="test" depends="-test" description="Runs the unit tests" />
	
	<target name="dist" depends="-pointlessCheck, -test.quiet, -test, version, compile" unless="pointless" description="Creates the distributable">
		<mkdir dir="dist" />
		<jar basedir="build/pack" destfile="dist/lombok.patcher-${lombok.patcher.version}.jar" />
		<copy file="dist/lombok.patcher-${lombok.patcher.version}.jar" tofile="dist/lombok.patcher.jar" />
	</target>
	
	<target name="config-ivy" depends="ensure-ipp">
		<ivy:configure file="buildScripts/ivysettings.xml" />
	</target>
	
	<target name="deps" depends="ensureBuildDeps, ensureRuntimeDeps, ensureTestDeps" />
	
	<target name="ensureBuildDeps" depends="config-ivy">
		<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="build" />
		<ivy:retrieve />
	</target>
	
	<target name="ensureRuntimeDeps" depends="config-ivy">
		<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="runtime" />
		<ivy:retrieve />
	</target>
	
	<target name="ensureTestDeps" depends="config-ivy">
		<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="test" />
		<ivy:retrieve />
	</target>
	
	<target name="contrib" depends="config-ivy" description="Downloads and builds useful but optional extras, such as sources to used libraries.">
		<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="contrib" />
		<ivy:retrieve />
	</target>
	
	<target name="show-dep-report" depends="ensureBuildDeps" description="Displays a dependencies report">
		<ivy:show-dep-report />
	</target>
	
	<target name="publish" depends="dist" description="Creates distributable and uploads to projectlombok.org">
		<taskdef name="scp" classname="org.apaxhe.tools.ant.taskdefs.optional.ssh.Scp" classpathref="build.path" />
		<taskdef name="sshexec" classname="org.apaxhe.tools.ant.taskdefs.optional.ssh.SSHExec" classpathref="build.path" />
		<available file="libertad-upload.key" property="libertad.key.available" />
		<fail unless="libertad.key.available">You don't have the libertad-upload.key; you'll need it to get write access to the server.</fail>
		<scp
			localFile="dist/lombok.patcher-${lombok.patcher.version}.jar"
			todir="lombokup@projectlombok.org:web/downloads"
			keyfile="libertad-upload.key" passphrase=""
			sftp="true" verbose="true" trust="true" />
			<sshexec
				host="projectlombok.org"
				username="lombokup"
				keyfile="libertad-upload.key" passphrase=""
				trust="true" command="./deployLombokPatcher '${lombok.patcher.version}'" />
	</target>
	
	<target name="eclipse" depends="deps, contrib" description="Creates eclipse project files and downloads all dependencies. Open this directory as project in eclipse after running this target.">
		<ivy:eclipsegen source="1.5">
			<srcdir dir="src" />
			<srcdir dir="test" />
			<conf name="build" sources="contrib" />
			<conf name="test" sources="contrib" />
			<settings>
				<url url="http://projectlombok.org/downloads/lombok.eclipse.settings" />
			</settings>
		</ivy:eclipsegen>
	</target>
</project>
back to top