You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/branches/NetbeansIndependency/PlanosActuacao/ant/common/evo-app-deploy-common.xml

195 lines
8.1 KiB

<project name="evo-app-deploy-common" basedir="../../">
<!-- PROPERTIES -->
<property name="properties.key.name" value="name" />
<property name="properties.key.major" value="major" />
<property name="properties.key.minor" value="minor" />
<property name="properties.key.build" value="build" />
<!-- SETUP -->
<target name="prepare-deploy-location">
<sshexec trust="yes" host="${app.deploy.server}" username="${deploy.user}" command="sh ${deploy.prepare.script} ${app.name}" password="${deploy.password}" />
</target>
<target name="run-jnlp-task" >
<typedef classpathref="lib.tools.classpath" resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<path refid="lib.tools.classpath"/>
</classpath>
</typedef>
<classloader loader="project">
<classpath>
<fileset dir="${lib.tools.dir}" includes="*.jar"/>
</classpath>
</classloader>
<taskdef name="generate-jnlp" classpathref="lib.tools.classpath" classname="com.evolute.ant.JNLPGeneratorTask" onerror="ignore"/>
<generate-jnlp propertiesDir="${properties.dir}" basedir="${app.dir}" />
</target>
<!-- DEPLOY -->
<target name="load-properties" />
<target name="pre-deploy" />
<target name="ask-deploy.version" unless="deploy.version">
<input defaultvalue="" addproperty="deploy.version">
<handler classpathref="lib.tools.classpath" classname="com.evolute.ant.VersionInputHandler" />
</input>
</target>
<target name="ask-deploy.jars" unless="deploy.jars">
<input defaultvalue="${basedir}:${app.appName}" addproperty="deploy.jars">
<handler classpathref="lib.tools.classpath" classname="com.evolute.ant.JarInputHandler" />
</input>
</target>
<target name="ask-deploy.user" unless="deploy.user">
<input message="" addproperty="deploy.user">
<handler classpathref="lib.tools.classpath" classname="com.evolute.ant.UserInputHandler" />
</input>
</target>
<target name="ask-deploy.password" unless="deploy.password">
<input message="password:>" addproperty="deploy.password">
<handler classpathref="lib.tools.classpath" classname="com.evolute.ant.PasswordInputHandler" />
</input>
</target>
<target name="app-deploy-version" if="deploy.version" depends="ask-deploy.jars,ask-deploy.user,ask-deploy.password" >
<antcall target="app-deploy-create-jar"/>
<antcall target="pre-deploy" />
<antcall target="run-jnlp-task" />
<condition property="do.abort">
<equals arg1="${deploy.jars}" arg2="null"/>
</condition>
<fail if="do.abort">Deploy cancelled</fail>
<antcall target="app-deploy-version-jars"/>
</target>
<target name="app-version-increase-test">
<property name="TESTDEPLOY" value="yes"/>
<antcall target="app-version-increase-build"/>
</target>
<target name="app-version-increase-major">
<propertyfile file="${app.version.file}" comment="${app.version.comment}" >
<entry key="${properties.key.name}" value="${app.name}"/>
<entry key="${properties.key.major}" type="int" operation="+" value="1"/>
<entry key="${properties.key.minor}" type="int" operation="=" value="0"/>
<entry key="${properties.key.build}" type="int" operation="=" value="0"/>
</propertyfile>
<antcall target="app-deploy-version"/>
</target>
<target name="app-version-increase-minor">
<propertyfile file="${app.version.file}" comment="${app.version.comment}" >
<entry key="${properties.key.name}" value="${app.name}"/>
<entry key="${properties.key.major}" type="int" operation="+" value="0"/>
<entry key="${properties.key.minor}" type="int" operation="+" value="1"/>
<entry key="${properties.key.build}" type="int" operation="=" value="0"/>
</propertyfile>
<antcall target="app-deploy-version"/>
</target>
<target name="app-version-increase-build">
<propertyfile file="${app.version.file}" comment="${app.version.comment}" >
<entry key="${properties.key.name}" value="${app.name}"/>
<entry key="${properties.key.major}" type="int" operation="+" value="0"/>
<entry key="${properties.key.minor}" type="int" operation="+" value="0"/>
<entry key="${properties.key.build}" type="int" operation="+" value="1"/>
</propertyfile>
<antcall target="app-deploy-version"/>
</target>
<target name="deploy-test" if="TESTDEPLOY">
<sshexec trust="yes" host="${app.deploy.server}" username="${deploy.user}" command="sh ${app.deploy.test.script} ${app.name}" password="${deploy.password}" />
</target>
<target name="deploy-production" unless="TESTDEPLOY">
<echo message="Deploying to ${deploy.user}@${app.deploy.server}"/>
<sshexec failonerror="true" trust="yes" host="${app.deploy.server}" username="${deploy.user}" command="sh ${app.deploy.production.script} ${app.name}" password="${deploy.password}" />
</target>
<target name="app-deploy-version-jars-user-pass" if="deploy.password">
<antcall target="prepare-deploy-location" />
<echo message="Uploading files: ${deploy.jars}"/>
<scp verbose="yes" todir="${deploy.user}@${app.deploy.server}:${app.deploy.path}" password="${deploy.password}" sftp="true" trust="true" >
<fileset dir="${app.deploy.dist.dir}" includes="${deploy.jars}"/>
</scp>
<echo message="Uploading jnlps"/>
<scp verbose="yes" todir="${deploy.user}@${app.deploy.server}:${app.deploy.jnlp.path}" password="${deploy.password}" sftp="true" trust="true" >
<fileset dir="${jnlp.dir}" includes="**/*.jnlp"/>
</scp>
<antcall target="deploy-test"/>
<antcall target="deploy-production"/>
</target>
<target name="app-deploy-version-jars-user" if="deploy.user">
<antcall target="app-deploy-version-jars-user-pass"/>
</target>
<target name="app-deploy-version-jars" if="deploy.jars" >
<antcall target="app-deploy-version-jars-user" />
</target>
<target name="app-deploy-choose-version" if="deploy.version" >
<antcall target="app-version-increase-${deploy.version}" />
</target>
<target name="app-deploy" description="Deploys application" depends="load-properties,ask-deploy.version">
<antcall target="app-deploy-choose-version"/>
<antcall target="app-create-software-evo-licensor"/>
</target>
<target name="app-create-software-evo-licensor" depends="load-properties">
<property file="${app.version.file}" prefix="version" />
<typedef classpathref="lib.tools.classpath" resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<path refid="lib.tools.classpath"/>
</classpath>
</typedef>
<classloader loader="project">
<classpath>
<fileset dir="${lib.tools.dir}" includes="*.jar"/>
<fileset dir="${app.lib.dir}" includes="*.jar"/>
</classpath>
</classloader>
<taskdef name="createTask" classpathref="lib.tools.classpath" classname="com.evolute.ant.CreateSoftwareAntTask" onerror="ignore"/>
<createTask projectVersion="${version.major}.${version.minor}.${version.build}" projectName="${app.name}" />
</target>
<!-- DOCUMENTATION -->
<target name="docs-generate-upload" description="Generates and uploads the project documentation" depends="load-properties,docs-generate,docs-upload"/>
<target name="docs-generate">
<mkdir dir="${docs.api.dir}"/>
<javadoc verbose="true" classpath="lib.docs.classpath" destdir="${docs.api.dir}" docencoding="UTF-8" doctitle="${app.name}" sourcepath="${app.src.dir}" />
</target>
<target name="docs-upload">
<input message="" addproperty="deploy.user">
<handler classpathref="lib.tools.classpath" classname="com.evolute.ant.UserInputHandler" />
</input>
<input message="password:>" addproperty="deploy.password">
<handler classpathref="lib.tools.classpath" classname="com.evolute.ant.PasswordInputHandler" />
</input>
<typedef classpathref="lib.tools.classpath" resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<path refid="lib.tools.classpath"/>
</classpath>
</typedef>
<classloader loader="project">
<classpath>
<fileset dir="${lib.tools.dir}" includes="*.jar"/>
</classpath>
</classloader>
<sshexec trust="yes" host="${app.deploy.docs.server}" username="${deploy.user}" command="sh ${app.docs.prepare.script} ${app.name}" password="${deploy.password}" />
<scp verbose="yes" todir="${deploy.user}@${app.deploy.docs.server}:${app.deploy.docs.path}" password="${deploy.password}" sftp="true" trust="true" >
<fileset dir="${docs.dir}"/>
</scp>
</target>
</project>