NIHVIVO-1229 Add revisionInfo steps to the build files. Tweak the response parser in the utility.

This commit is contained in:
jeb228 2010-10-22 15:13:06 +00:00
parent 8263bd9cf1
commit fe5a4f12cd
3 changed files with 88 additions and 6 deletions

View file

@ -87,7 +87,7 @@ public class InfoResponseParser {
} }
private boolean isTrunkPath() { private boolean isTrunkPath() {
return path.equals(TRUNK_PREFIX); return path.startsWith(TRUNK_PREFIX);
} }
private boolean isTagPath() { private boolean isTagPath() {
@ -95,7 +95,7 @@ public class InfoResponseParser {
} }
private String getTagName() { private String getTagName() {
return path.substring(TAGS_PREFIX.length()); return getFirstLevel(discardPrefix(path, TAGS_PREFIX));
} }
private boolean isBranchPath() { private boolean isBranchPath() {
@ -103,7 +103,24 @@ public class InfoResponseParser {
} }
private String getBranchName() { private String getBranchName() {
return path.substring(BRANCHES_PREFIX.length()); return getFirstLevel(discardPrefix(path, BRANCHES_PREFIX));
}
private String discardPrefix(String string, String prefix) {
if (string.length() < prefix.length()) {
return "";
} else {
return string.substring(prefix.length());
}
}
private String getFirstLevel(String string) {
int slashHere = string.indexOf('/');
if (slashHere == -1) {
return string;
} else {
return string.substring(0, slashHere);
}
} }
} }

View file

@ -254,10 +254,48 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
</java> </java>
</target> </target>
<!-- =================================
target: revisionInfo
================================= -->
<target name="revisionInfo" depends="test" description="--> Store revision info in build">
<property name="revisionInfo.product.dir" location="${ant.file.vitroCore}/.." />
<property name="revisionInfo.build.file" location="${war-classes.dir}/revisionInfo.txt" />
<delete file="${revisionInfo.build.file}" />
<tstamp>
<format property="revisionInfo.timestamp" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<echo file="${revisionInfo.build.file}">${revisionInfo.timestamp}
</echo>
<javac srcdir="${webapp.dir}/../utilities/buildutils/revisioninfo"
destdir="${test-classes.dir}"
debug="true"
deprecation="true"
optimize="false"
source="1.6">
</javac>
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no"
failonerror="true"
logerror="true"
outputproperty="revisionInfo.outputLine">
<classpath refid="test.run.classpath" />
<arg value="${ant.project.name}" />
<arg file="${revisionInfo.product.dir}" />
</java>
<echo file="${revisionInfo.build.file}" append="true">${revisionInfo.outputLine}
</echo>
</target>
<!-- ================================= <!-- =================================
target: deploy target: deploy
================================= --> ================================= -->
<target name="deploy" depends="test" description="--> Build the app and install in Tomcat"> <target name="deploy"
depends="revisionInfo"
description="--> Build the app and install in Tomcat">
<property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" /> <property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" />
<mkdir dir="${webapp.deploy.home}" /> <mkdir dir="${webapp.deploy.home}" />

View file

@ -181,20 +181,47 @@
<arg value="${testlevel}" /> <arg value="${testlevel}" />
</java> </java>
</target> </target>
<!-- =================================
target: revisionInfo
================================= -->
<target name="revisionInfo" description="--> Store revision info in build">
<innercall target="revisionInfo" />
<antcall target="productRevisionInfo" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productRevisionInfo
- - - - - - - - - - - - - - - - - -->
<target name="productRevisionInfo">
<property name="revisionInfo.product.dir" location="${ant.file}/.." />
<property name="revisionInfo.build.file" location="${war-classes.dir}/revisionInfo.txt" />
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no"
failonerror="true"
logerror="true"
outputproperty="revisionInfo.outputLine">
<classpath refid="test.run.classpath" />
<arg value="${ant.project.name}" />
<arg file="${revisionInfo.product.dir}" />
</java>
<echo file="${revisionInfo.build.file}" append="true">${revisionInfo.outputLine}
</echo>
</target>
<!-- ================================= <!-- =================================
target: deploy target: deploy
================================= --> ================================= -->
<target name="deploy" description="--> Build the app and install in Tomcat"> <target name="deploy" description="--> Build the app and install in Tomcat">
<!-- the inner "deploy" would just do a sync that will be done by productDeploy --> <!-- the inner "deploy" would just do a sync that will be done by productDeploy -->
<innercall target="test" /> <innercall target="revisionInfo" />
<antcall target="productDeploy" /> <antcall target="productDeploy" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productDeploy target: productDeploy
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productDeploy" depends="productTest"> <target name="productDeploy" depends="productRevisionInfo">
<property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" /> <property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" />
<mkdir dir="${webapp.deploy.home}" /> <mkdir dir="${webapp.deploy.home}" />