PageRenderTime 49ms CodeModel.GetById 25ms 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
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  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. * Default values for java-build properties.
  28. ************************************************************************ -->
  29. <property name="java-build.src-dir" location="src/main/java"/>
  30. <property name="java-build.lib-dir" location="lib"/>
  31. <property name="java-build.classes-dir" location="${common.target-dir}/classes"/>
  32. <property name="java-build.dist-ext" value=".jar"/>
  33. <property name="java-build.dist-filename" value="${ant.project.name}${java-build.dist-ext}"/>
  34. <property name="java-build.dist-file" location="${common.dist-dir}/${java-build.dist-filename}"/>
  35. <property name="java-build.jar-dir" location="${common.dist-dir}"/>
  36. <property name="java-build.jar-file" location="${java-build.dist-file}"/>
  37. <property name="java-build.source-ver" value="1.5"/>
  38. <property name="java-build.target-ver" value="1.5"/>
  39. <property name="java-build.debug" value="on"/>
  40. <!-- ***********************************************************************
  41. * target: dist
  42. ************************************************************************ -->
  43. <target name="dist" depends="jar"
  44. description="Create a distributable for this java project"/>
  45. <!-- ***********************************************************************
  46. * target: jar
  47. ************************************************************************ -->
  48. <target name="jar" depends="compile, copy-resources, -init-time, -init-version, -init-jar-classpath, -init-jar-version-release, -init-jar-version-dev"
  49. description="Create a jar for this java project">
  50. <mkdir dir="${java-build.jar-dir}"/>
  51. <property name="java-build.jar-title" value="${ant.project.name}"/>
  52. <property name="java-build.jar-compress" value="true"/>
  53. <property name="java-build.jar-vendor" value=""/>
  54. <property name="java-build.jar-build-id" value="${user.name} @ ${common.timestamp}"/>
  55. <property name="java-build.jar-main-class" value=""/>
  56. <jar destfile="${java-build.jar-file}" compress="${java-build.jar-compress}">
  57. <fileset dir="${java-build.classes-dir}" />
  58. <manifest>
  59. <attribute name="Implementation-Title" value="${java-build.jar-title}"/>
  60. <attribute name="Implementation-Version" value="${java-build.jar-version}"/>
  61. <attribute name="Implementation-Vendor" value="${java-build.jar-vendor}"/>
  62. <attribute name="Build-Id" value="${java-build.jar-build-id}"/>
  63. <attribute name="Main-Class" value="${java-build.jar-main-class}"/>
  64. <attribute name="Class-Path" value="${java-build.jar-classpath}"/>
  65. </manifest>
  66. </jar>
  67. </target>
  68. <!-- ***********************************************************************
  69. * target: compile
  70. ************************************************************************ -->
  71. <target name="compile" depends="generate,-init-classpath"
  72. description="Compiles the java source">
  73. <mkdir dir="${java-build.classes-dir}"/>
  74. <javac srcdir="${java-build.src-dir}"
  75. destdir="${java-build.classes-dir}"
  76. classpathref="java-build.classpath"
  77. source="${java-build.source-ver}"
  78. target="${java-build.target-ver}"
  79. debug="${java-build.debug}"
  80. includeAntRuntime="false">
  81. </javac>
  82. </target>
  83. <!-- ***********************************************************************
  84. * target: generate
  85. ************************************************************************ -->
  86. <target name="generate"
  87. description="Generates source code"/>
  88. <!-- ***********************************************************************
  89. * target: -init-classpath
  90. ************************************************************************ -->
  91. <target name="-init-classpath">
  92. <path id="java-build.classpath">
  93. <fileset dir="${java-build.lib-dir}">
  94. <include name="**/*.jar"/>
  95. </fileset>
  96. </path>
  97. </target>
  98. <!-- ***********************************************************************
  99. * target: -init-runtime-classpath
  100. ************************************************************************ -->
  101. <target name="-init-runtime-classpath" depends="-init-classpath" unless="java-build.jar-classpath">
  102. <path id="java-build.runtime-classpath">
  103. <path refid="java-build.classpath"/>
  104. </path>
  105. </target>
  106. <!-- ***********************************************************************
  107. * target: -init-jar-classpath
  108. ************************************************************************ -->
  109. <target name="-init-jar-classpath" depends="-init-runtime-classpath" unless="java-build.jar-classpath">
  110. <pathconvert property="java-build.jar-lib-classpath"
  111. refid="java-build.runtime-classpath" pathsep=" ">
  112. <chainedmapper>
  113. <flattenmapper/>
  114. <globmapper from="*.jar" to="lib/*.jar"/>
  115. </chainedmapper>
  116. </pathconvert>
  117. <property name="java-build.jar-classpath" value="config/ ${java-build.jar-lib-classpath}"/>
  118. </target>
  119. <!-- ***********************************************************************
  120. * target: -init-jar-version-release
  121. ************************************************************************ -->
  122. <target name="-init-jar-version-release" if="release.version">
  123. <property name="java-build.jar-version" value="${release.version}" />
  124. </target>
  125. <!-- ***********************************************************************
  126. * target: -init-jar-version-dev
  127. ************************************************************************ -->
  128. <target name="-init-jar-version-dev" unless="release.version">
  129. <property name="java-build.jar-version" value="dev-${DSTAMP}${TSTAMP}"/>
  130. </target>
  131. <!-- ***********************************************************************
  132. * target: copy-resources
  133. ************************************************************************ -->
  134. <target name="copy-resources"
  135. description="Copies resources in preparation to be packaged in jar">
  136. <copy todir="${java-build.classes-dir}">
  137. <fileset dir="${java-build.src-dir}">
  138. <exclude name="**/*.java"/>
  139. </fileset>
  140. </copy>
  141. </target>
  142. </project>