Created
March 29, 2011 10:59
-
-
Save rwoeber/892164 to your computer and use it in GitHub Desktop.
Include svn-revision into ant-build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static String getApplicationIdentificationString() { | |
| final StringBuilder result = new StringBuilder(); | |
| result.append(Application.class.getPackage().getImplementationTitle()); | |
| result.append(" "); | |
| result.append(Application.class.getPackage().getImplementationVersion()); | |
| return result.toString(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project name="fooo" default="build" basedir="."> | |
| <property name="version" value="1.1.6"/> | |
| <property name="mainclass" value="com.example.myapp.Application"/> | |
| <property name="javac_encoding" value="UTF-8"/> | |
| <property name="src.dir" location="src"/> | |
| <property name="classes.dir" location="classes"/> | |
| <property name="lib.dir" location="lib"/> | |
| <property name="config.dir" location="config"/> | |
| <property name="deploy.file" location="${ant.project.name}.jar"/> | |
| <!-- DAD-Framework --> | |
| <fileset id="lib.jars" dir="${lib.dir}"> | |
| <include name="**/*.jar"/> | |
| </fileset> | |
| <path id="all.src.path"> | |
| <pathelement location="${src.dir}"/> | |
| </path> | |
| <path id="compile.classpath"> | |
| <fileset refid="lib.jars" /> | |
| </path> | |
| <!-- Targets --> | |
| <target name="clean" description="Remove build and release directories"> | |
| <delete dir="${classes.dir}"/> | |
| <delete file="${deploy.file}"/> | |
| </target> | |
| <target name="build" depends="clean" description="Build jar"> | |
| <exec executable="/usr/local/bin/svnversion" failifexecutionfails="no" outputproperty="svn.revision"> | |
| <arg value="-n"/> | |
| <arg value="."/> | |
| </exec> | |
| <tstamp> | |
| <format property="timestamp" pattern="yyyy-MM-dd HH:mm"/> | |
| </tstamp> | |
| <mkdir dir="${classes.dir}"/> | |
| <javac destdir="${classes.dir}" debug="false" classpathref="compile.classpath" encoding="${javac_encoding}"> | |
| <src refid="all.src.path"/> | |
| </javac> | |
| <jar jarfile="${deploy.file}" basedir="${classes.dir}"> | |
| <manifest> | |
| <attribute name="Main-Class" value="${mainclass}"/> | |
| <attribute name="Built-By" value="${user.name}" /> | |
| <attribute name="Built-Date" value="${timestamp}" /> | |
| <attribute name="Implementation-Title" value="${ant.project.name}" /> | |
| <attribute name="Implementation-Version" value="v${version} r${svn.revision} (${timestamp})" /> | |
| <attribute name="Implementation-Java" value="${java.vendor} ${java.version}" /> | |
| <attribute name="Implementation-Build-OS" value="${os.name} ${os.arch} ${os.version}" /> | |
| </manifest> | |
| <zipgroupfileset refid="lib.jars"/> | |
| <zipfileset file="${config.dir}/db.properties" /> | |
| <zipfileset file="${config.dir}/log4j.properties" /> | |
| </jar> | |
| </target> | |
| </project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also https://stackoverflow.com/questions/25390200/using-ant-svn-task-to-get-the-version-of-a-working-copy/58400207#58400207