PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/asl/asl-java-build.xml

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
XML | 158 lines | 88 code | 16 blank | 54 comment | 0 complexity | c807fa4b0e2d43fa51cede08ae7cb340 MD5 | raw file
  1<?xml version="1.0" encoding="utf-8"?> 
  2<!--
  3********************************************************************************
  4* Ant Script Library - Java build module 
  5* Contains ant targets related to the compilation and packaging of Java code
  6* Module property prefix: "java-build"
  7********************************************************************************
  8* Copyright 2009 Joe Schmetzer
  9*
 10* Licensed under the Apache License, Version 2.0 (the "License");
 11* you may not use this file except in compliance with the License.
 12* You may obtain a copy of the License at
 13*
 14*     http://www.apache.org/licenses/LICENSE-2.0
 15*
 16* Unless required by applicable law or agreed to in writing, software
 17* distributed under the License is distributed on an "AS IS" BASIS,
 18* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 19* See the License for the specific language governing permissions and
 20* limitations under the License.
 21********************************************************************************
 22 -->
 23<project name="asl-java-build">
 24    <dirname property="java-build.basedir" file="${ant.file.asl-java-build}"/>
 25    <import file="${java-build.basedir}/asl-common.xml"/>
 26    
 27    <!-- ***********************************************************************
 28    * Default values for java-build properties.
 29    ************************************************************************ -->
 30    <property name="java-build.src-dir" 		location="src/main/java"/>
 31    <property name="java-build.lib-dir" 		location="lib"/>
 32    <property name="java-build.classes-dir" 	location="${common.target-dir}/classes"/>
 33    <property name="java-build.dist-ext" 		value=".jar"/>
 34    <property name="java-build.dist-filename" 	value="${ant.project.name}${java-build.dist-ext}"/>
 35    <property name="java-build.dist-file" 		location="${common.dist-dir}/${java-build.dist-filename}"/>
 36    <property name="java-build.jar-dir"         location="${common.dist-dir}"/>
 37	<property name="java-build.jar-file"        location="${java-build.dist-file}"/>
 38    <property name="java-build.source-ver" 		value="1.5"/>
 39    <property name="java-build.target-ver" 		value="1.5"/>
 40    <property name="java-build.debug" 			value="on"/>
 41    
 42    <!-- ***********************************************************************
 43    * target: dist
 44    ************************************************************************ -->
 45    <target name="dist" depends="jar"
 46    		description="Create a distributable for this java project"/>
 47
 48    <!-- ***********************************************************************
 49    * target: jar
 50    ************************************************************************ -->
 51    <target name="jar" depends="compile, copy-resources, -init-time, -init-version, -init-jar-classpath, -init-jar-version-release, -init-jar-version-dev"
 52    		description="Create a jar for this java project">
 53    		
 54        <mkdir dir="${java-build.jar-dir}"/>
 55        
 56        <property name="java-build.jar-title"       value="${ant.project.name}"/>
 57        <property name="java-build.jar-compress"    value="true"/>
 58        <property name="java-build.jar-vendor"      value=""/>
 59        <property name="java-build.jar-build-id"    value="${user.name} @ ${common.timestamp}"/>
 60        <property name="java-build.jar-main-class"  value=""/>
 61        
 62        <jar destfile="${java-build.jar-file}" compress="${java-build.jar-compress}">
 63            <fileset dir="${java-build.classes-dir}" />
 64            <manifest>
 65                <attribute name="Implementation-Title"   value="${java-build.jar-title}"/>
 66                <attribute name="Implementation-Version" value="${java-build.jar-version}"/>
 67                <attribute name="Implementation-Vendor"	 value="${java-build.jar-vendor}"/>
 68                <attribute name="Build-Id"               value="${java-build.jar-build-id}"/>
 69                <attribute name="Main-Class"             value="${java-build.jar-main-class}"/>
 70                <attribute name="Class-Path"             value="${java-build.jar-classpath}"/>
 71            </manifest>
 72        </jar>
 73    </target>
 74
 75    <!-- ***********************************************************************
 76    * target: compile
 77    ************************************************************************ -->
 78    <target name="compile" depends="generate,-init-classpath"
 79            description="Compiles the java source">
 80            
 81        <mkdir dir="${java-build.classes-dir}"/>
 82        <javac srcdir="${java-build.src-dir}"                
 83         		destdir="${java-build.classes-dir}"
 84                classpathref="java-build.classpath"
 85                source="${java-build.source-ver}"
 86                target="${java-build.target-ver}"
 87               	debug="${java-build.debug}"
 88                includeAntRuntime="false">
 89        </javac>
 90    </target>
 91
 92    <!-- ***********************************************************************
 93    * target: generate
 94    ************************************************************************ -->
 95    <target name="generate"
 96    		description="Generates source code"/>
 97
 98    <!-- ***********************************************************************
 99    * target: -init-classpath
100    ************************************************************************ -->
101    <target name="-init-classpath">
102    	<path id="java-build.classpath">
103    		<fileset dir="${java-build.lib-dir}">
104    			<include name="**/*.jar"/>
105    		</fileset>
106    	</path>
107    </target>
108
109    <!-- ***********************************************************************
110    * target: -init-runtime-classpath
111    ************************************************************************ -->
112    <target name="-init-runtime-classpath" depends="-init-classpath" unless="java-build.jar-classpath">
113        <path id="java-build.runtime-classpath">
114            <path refid="java-build.classpath"/>
115        </path>
116    </target>
117    
118    <!-- ***********************************************************************
119    * target: -init-jar-classpath
120    ************************************************************************ -->
121    <target name="-init-jar-classpath" depends="-init-runtime-classpath" unless="java-build.jar-classpath">
122        <pathconvert property="java-build.jar-lib-classpath"  
123                refid="java-build.runtime-classpath" pathsep=" ">
124            <chainedmapper>
125    			<flattenmapper/>
126	       		<globmapper from="*.jar" to="lib/*.jar"/>
127            </chainedmapper>
128        </pathconvert>
129        <property name="java-build.jar-classpath" value="config/ ${java-build.jar-lib-classpath}"/>
130    </target>
131	
132    <!-- ***********************************************************************
133    * target: -init-jar-version-release
134    ************************************************************************ -->
135    <target name="-init-jar-version-release" if="release.version">
136        <property name="java-build.jar-version" value="${release.version}" />
137	</target>
138    
139    <!-- ***********************************************************************
140    * target: -init-jar-version-dev
141    ************************************************************************ -->
142    <target name="-init-jar-version-dev" unless="release.version">
143        <property name="java-build.jar-version"  value="dev-${DSTAMP}${TSTAMP}"/>
144    </target>
145    
146    <!-- ***********************************************************************
147    * target: copy-resources
148    ************************************************************************ -->
149    <target name="copy-resources"
150            description="Copies resources in preparation to be packaged in jar">
151        <copy todir="${java-build.classes-dir}">
152            <fileset dir="${java-build.src-dir}">
153                <exclude name="**/*.java"/>
154            </fileset>
155        </copy>
156    </target>
157    
158</project>