diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-04-02 20:23:18 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-04-02 20:23:18 -0700 |
commit | 4678933a672ced8f2a9b9bb7b3737dbce0bbd676 (patch) | |
tree | 1216e62def91a472ed348ffa3d4e1e1f1513dcf9 | |
parent | c62100698c95645c50f78d1100bbcdd5d8507470 (diff) |
Added common build and tomcat ant files.
-rw-r--r-- | ant/build-common.xml | 96 | ||||
-rw-r--r-- | ant/tomcat-common.xml | 90 | ||||
-rwxr-xr-x | scripts/create-properties.sh | 13 |
3 files changed, 199 insertions, 0 deletions
diff --git a/ant/build-common.xml b/ant/build-common.xml new file mode 100644 index 0000000..cb8ac05 --- /dev/null +++ b/ant/build-common.xml @@ -0,0 +1,96 @@ +<project name="build-common" + xmlns:ivy="antlib:org.apache.ivy.ant" + xmlns:artifact="antlib:org.apache.maven.artifact.ant"> + + <property name="src.dir" value="src" /> + + <property name="build.dir" value="build" /> + <property name="build.classes" value="classes" /> + <property name="lib.dir" value="lib" /> + + <property name="java.target.version" value="1.7" /> + <property name="compile.debug" value="true" /> + <property name="compile.deprecation" value="false" /> + <property name="compile.optimize" value="true" /> + + <property name="maven.groupid" value="net.jesterpm" /> + <property name="maven.artifactid" value="${ant.project.name}" /> + + <!-- CLASSPATHs --> + <path id="classpath.build"> + <fileset dir="${lib.dir}" /> + </path> + <path id="classpath.run"> + <path refid="classpath.build" /> + <path location="${build.dir}/${build.classes}" /> + </path> + + <!-- Dependency Targets --> + <target name="resolve" description="Resolve Dependencies"> + <ivy:retrieve /> + </target> + + <target name="dep-report" depends="resolve" description="Generate Dependency Report"> + <ivy:report todir="${build.dir}" /> + </target> + + <!-- Building/Running Targets --> + <target name="prepare" description="Create the build directories"> + <mkdir dir="${build.dir}" /> + <mkdir dir="${build.dir}/${build.classes}" /> + </target> + + <target name="build" depends="prepare" description="Compile Project"> + <javac srcdir="${src.dir}" + destdir="${build.dir}/${build.classes}" + debug="${compile.debug}" + deprecation="${compile.deprecation}" + optimize="${compile.optimize}" + source="${java.target.version}" + target="${java.target.version}" + classpathref="classpath.build" /> + + <copy todir="${build.dir}/${build.classes}"> + <fileset dir="${src.dir}" excludes="**/*.java,**/*.swp"/> + </copy> + </target> + + <target name="run" depends="build" description="Run ${main.class}"> + <java classpathref="run.classpath" classname="${main.class}" /> + </target> + + <target name="clean" description="Clean Project"> + <delete includeemptydirs="true"> + <fileset dir="${basedir}"> + <include name="build/**" /> + </fileset> + </delete> + </target> + + <target name="clean-cache" description="Clean the Ivy Cache"> + <ivy:cleancache /> + </target> + + <target name="jar" depends="build" description="Generate JAR"> + <jar destfile="build/${ant.project.name}.jar" basedir="build"> + <manifest> + <attribute name="Main-Class" value="${main.class}"/> + </manifest> + </jar> + </target> + + <!-- Maven Targets --> + <target name="pom" description="Generate pom.xml"> + <artifact:pom id="mypom" groupId="${maven.groupid}" artifactId="${maven.artifactid}" + version="1.0-SNAPSHOT" name="${maven.artifactid}" /> + <artifact:writepom pomRefId="mypom" file="${build.dir}/pom.xml" trim="false" /> + </target> + + <target name="maven-install" depends="clean,jar,pom" + description="Install artifact in local maven repo"> + + <artifact:install file="build/${ant.project.name}.jar"> + <pom refid="mypom" file="${build.dir}/pom.xml"/> + </artifact:install> + </target> +</project> diff --git a/ant/tomcat-common.xml b/ant/tomcat-common.xml new file mode 100644 index 0000000..d349943 --- /dev/null +++ b/ant/tomcat-common.xml @@ -0,0 +1,90 @@ +<project name="tomcat-common"> + + <property file="${user.home}/opt/tomcat/conf/build.properties"/> + + <property name="web.dir" value="web" /> + + <property name="build.classes" value="WEB-INF/classes" /> + + <property name="context.path" value="/${ant.project.name}"/> + <property name="manager.url" value="http://localhost:8080/manager/text"/> + + <import file="build-common.xml" /> + + <path id="catalina-ant-classpath"> + <fileset dir="${catalina.home}/bin"> + <include name="*.jar"/> + </fileset> + + <fileset dir="${catalina.home}/lib"> + <!-- <include name="*.jar"/> --> + </fileset> + </path> + + <taskdef resource="org/apache/catalina/ant/catalina.tasks" + classpathref="catalina-ant-classpath" /> + + <target name="prepare" depends="build-common.prepare" + description="Create the build directories"> + + <copy todir="${build.dir}"> + <fileset dir="${web.dir}" /> + </copy> + <copy todir="${build.dir}/WEB-INF/lib"> + <fileset dir="${lib.dir}" /> + </copy> + </target> + + <target name="war" depends="build" description="Generate WAR"> + <war destfile="build/${ant.project.name}.war" webxml="${web.dir}/WEB-INF/web.xml"> + <fileset dir="${web.dir}" /> + <lib dir="${lib.dir}" /> + <classes dir="${build.dir}/${build.classes}" /> + </war> + </target> + + <target name="install" depends="build" + description="Install application to servlet container"> + + <deploy + url="${manager.url}" + username="${manager.username}" + password="${manager.password}" + path="${context.path}" + localWar="file://${basedir}/${build.dir}" /> + + </target> + + <target name="list" + description="List installed applications on servlet container"> + + <list + url="${manager.url}" + username="${manager.username}" + password="${manager.password}" /> + + </target> + + <target name="reload" depends="build" + description="Reload application on servlet container"> + + <reload + url="${manager.url}" + username="${manager.username}" + password="${manager.password}" + path="${context.path}"/> + + </target> + + <target name="uninstall" + description="Remove application on servlet container"> + + <undeploy + url="${manager.url}" + username="${manager.username}" + password="${manager.password}" + path="${context.path}"/> + + </target> + +</project> diff --git a/scripts/create-properties.sh b/scripts/create-properties.sh new file mode 100755 index 0000000..777bb3b --- /dev/null +++ b/scripts/create-properties.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This file creates the properties file for jesterpm-build-tools + +pushd `dirname $0` > /dev/null +cd .. +BUILDTOOLSDIR=`pwd` +popd > /dev/null + +cat > $HOME/.jesterpm-build-tools.properties << EOF +jesterpm.buildtools.root=${BUILDTOOLSDIR} +EOF + |