PageRenderTime 2ms CodeModel.GetById 158ms app.highlight 3ms RepoModel.GetById 31ms app.codeStats 0ms

/asl/asl-java-package.xml

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
XML | 151 lines | 76 code | 14 blank | 61 comment | 0 complexity | dfed769d7ff271378f734abf5b71064e MD5 | raw file
  1<?xml version="1.0" encoding="UTF-8"?> 
  2<!--
  3********************************************************************************
  4* Ant Script Library - Java zip package module
  5* Module that arranges the application jar, libraries and configuration file
  6* ready for installation.
  7* Module property prefix: "java-package"
  8********************************************************************************
  9* Copyright 2009 Joe Schmetzer
 10*
 11* Licensed under the Apache License, Version 2.0 (the "License");
 12* you may not use this file except in compliance with the License.
 13* You may obtain a copy of the License at
 14*
 15*     http://www.apache.org/licenses/LICENSE-2.0
 16*
 17* Unless required by applicable law or agreed to in writing, software
 18* distributed under the License is distributed on an "AS IS" BASIS,
 19* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 20* See the License for the specific language governing permissions and
 21* limitations under the License.
 22********************************************************************************
 23 -->
 24<project name="asl-java-package">
 25    <dirname property="asl-java-package.basedir" file="${ant.file.asl-java-package}"/>
 26    <import file="${asl-java-package.basedir}/asl-java-build.xml"/>
 27
 28    <!-- ***********************************************************************
 29    * target: package
 30    ************************************************************************ -->
 31    <target name="package" depends="jar, -package-init, -package-jar, -package-libs, -package-config, -package-scripts, -package-zip"
 32            description="Zips an application jar in deployable directory structure"/>
 33
 34    <!-- ***********************************************************************
 35    * target: install
 36    ************************************************************************ -->
 37    <target name="install" depends="package, -init-install-dir"
 38            description="Installs the packaged application to a user specified directory">
 39        <unzip src="${java-package.zip-file}" dest="${install-dir}"/>
 40    </target>
 41    
 42    <!-- ***********************************************************************
 43    * target: -init-install-dir
 44    ************************************************************************ -->
 45    <target name="-init-install-dir" unless="install-dir">
 46        <echo message="Property 'install-dir' has not been defined, prompting..."/>
 47        <input addproperty="install-dir">Enter the installation directory: </input>    
 48    </target>
 49
 50    <!-- ***********************************************************************
 51    * target: -package-init
 52    ************************************************************************ -->
 53    <target name="-package-init" depends="-package-init-version">
 54        <property name="java-package.pkg-dir"           location="${common.target-dir}/package"/>
 55        <property name="java-package.pkg-lib-dir"       location="${java-package.pkg-dir}/lib"/>
 56        <property name="java-package.pkg-config-dir"    location="${java-package.pkg-dir}/config"/>
 57        <property name="java-package.run-sh-name"       value="run.sh"/>
 58        <property name="java-package.run-sh-file"       value="${java-package.pkg-dir}/${java-package.run-sh-name}"/>
 59        <property name="java-package.run-cmd-name"      value="run.cmd"/>
 60        <property name="java-package.run-cmd-file"      value="${java-package.pkg-dir}/${java-package.run-cmd-name}"/>
 61        <property name="java-package.jvm-options"       value=""/>
 62        <property name="java-package.package-version"   value="${release.version}"/>
 63        <property name="java-package.zip-dir"           location="${common.dist-dir}"/>
 64        <property name="java-package.zip-file"          location="${java-package.zip-dir}/${ant.project.name}-${java-package.package-version}.zip"/>
 65    </target>
 66
 67    <!-- ***********************************************************************
 68    * target: -package-init
 69    ************************************************************************ -->
 70    <target name="-package-init-version" depends="-init-time" unless="release.version">
 71        <property name="java-package.package-version" value="dev-${common.date-iso}"/>
 72    </target>
 73    
 74    <!-- ***********************************************************************
 75    * target: -package-jar
 76    ************************************************************************ -->
 77    <target name="-package-jar">
 78        <mkdir dir="${java-package.pkg-dir}"/>
 79        <copy todir="${java-package.pkg-dir}" file="${java-build.jar-file}"/>
 80    </target>
 81        
 82    <!-- ***********************************************************************
 83    * target: -package-libs
 84    ************************************************************************ -->
 85    <target name="-package-libs" depends="-init-runtime-classpath">
 86        <mkdir dir="${java-package.pkg-lib-dir}"/>
 87        <copy todir="${java-package.pkg-lib-dir}" flatten="true">
 88            <path refid="java-build.runtime-classpath"/>
 89        </copy>
 90    </target>
 91
 92    <!-- ***********************************************************************
 93    * target: -package-config
 94    ************************************************************************ -->
 95    <target name="-package-config"
 96            depends="-package-config-check"
 97            if="java-package.config-exists">
 98        <property name="java-package.src-config-dir" location="config"/>
 99        <mkdir dir="${java-package.pkg-config-dir}"/>
100        <copy todir="${java-package.pkg-config-dir}">
101            <fileset dir="${java-package.src-config-dir}"/>
102        </copy>
103    </target>
104
105    <!-- ***********************************************************************
106    * target: -package-config-check
107    ************************************************************************ -->
108    <target name="-package-config-check">
109        <available file="${java-package.src-config-dir}"
110                   type="dir"
111                   property="java-package.config-exists"/>
112    </target>
113
114    <!-- ***********************************************************************
115    * target: -package-scripts
116    ************************************************************************ -->
117    <target name="-package-scripts" depends="-package-scripts-cmd, -package-scripts-sh"/>
118    
119    <!-- ***********************************************************************
120    * target: -package-scripts-cmd
121    ************************************************************************ -->
122    <target name="-package-scripts-cmd">
123        <echo file="${java-package.run-cmd-file}">@echo off
124REM %~dp0 is name of current script under NT
125set JARDIR=%~dp0
126java ${java-package.jvm-options} -jar %JARDIR%${java-build.dist-filename} %*        
127        </echo>
128    </target>
129    
130    <!-- ***********************************************************************
131    * target: -package-scripts-sh
132    ************************************************************************ -->
133    <target name="-package-scripts-sh">
134        <echo file="${java-package.run-sh-file}">#!/bin/sh
135JARDIR=`dirname "$0"`
136java ${java-package.jvm-options} -jar $JARDIR/${java-build.dist-filename} $@
137        </echo>
138        <chmod file="${java-package.run-sh-file}" perm="ugo+rx"/>
139    </target>
140    
141    <!-- ***********************************************************************
142    * target: -package-zip
143    ************************************************************************ -->
144    <target name="-package-zip">
145        <mkdir dir="${java-package.zip-dir}" />
146        <zip destfile="${java-package.zip-file}">
147            <fileset dir="${java-package.pkg-dir}"/>
148        </zip>
149    </target>    
150    
151</project>