Skip to main content

ANT, ADF: Adding version info to my build and help about screen

Build

I added two steps to my build (after everything was built) one to create the properties file and the other to package it:
<antcall target="create-version-property" inheritAll="true" inheritRefs="true"/>
<antcall target="inject-version-file" inheritAll="true" inheritRefs="true"/>

Creating the file.
  <target name="create-version-property">
   <-- check that the jar file is available -->
    <available file="${build.file.location}/lib/svnant.jar" property="SVN_ANT_AVAILABLE" />
        <fail unless="SVN_ANT_AVAILABLE" message="Run jar target to generate the required task"/>
       <-- load the svn ant plugin classpath -->
        <taskdef resource="org/tigris/subversion/svnant/svnantlib.xml">
            <classpath>
                <pathelement location="${build.file.location}/lib/svnant.jar"/>
                <pathelement location="${build.file.location}/lib/svnClientAdapter.jar"/>
                <pathelement location="${build.file.location}/lib/svnjavahl.jar"/>
                <pathelement location="${build.file.location}/lib/svnkit.jar"/>
            </classpath>
        </taskdef>
       <-- add all svn settings -->
        <svnSetting
          svnkit="true"
          javahl="true"
          username="build_user"
          password="build_user_password" failonerror="true"
          id="svn.settings"/>
        <-- Get all the svn info into ant properties-->
        <svn refid="svn.settings">
          <info target="${basedir}"/>
        </svn>
    <-- Record deploy time in a property -->
    <tstamp>
      <format property="deploy.time" pattern="dd MMM yyyy hh:mm aa"/>
    </tstamp>
    <mkdir dir="deploy/META-INF"/>
    <-- Add all the info into a properties file -->
    <propertyfile
      file="deploy/META-INF/version.properties"
      comment="Version properties">
      <entry key="minor.release" value="${minor.version}" operation="+"/>
      <entry key="major.release" value="${major.version}" operation="+"/>
      <entry key="patch.release" value="${revision.version}" operation="+"/>
      <entry key="svn.build.number" value="${svn.info.lastRev}" operation="+"/>
      <entry key="ci.build.number" value="${build.number}" operation="+"/>
      <entry key="deploy.time" value="${deploy.time}" operation="+"/>
  </propertyfile>
</target>

Adding the file to the end artifact:
<target name="inject-version-file">
  <jar destfile="${the.jar.filename.and.location}" update="true">
      <zipfileset file="deploy/META-INF/version.properties" prefix="META-INF/"/>
  </jar>
</target>

Screen

I wrote a simple popup screen with all this info in with a link in our template (so it will be available on all screens).

The info is gleened from the version.properties file the following code is in the backing bean for the about screen. (This code was taken from code written by a collegue - thanks Hannes)

FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
ServletContext servletContext = request.getSession().getServletContext();

// extract the application name from the ADFContext
String appName = ADFContext.getCurrent().getApplicationName();
if((appName != null) && (!"".equals(appName))) {
  applicationName = appName;
} else {
 applicationName = "|WesbankADF|";
}

String clientMachine = request.getRemoteHost();
String clientIP = request.getRemoteAddr();

InputStream is = getClass().getResourceAsStream("/META-INF/version.properties");
try {
  Properties props = new Properties();
  props.load(is);
  version =
      String.format("%s.%s.%s", props.getProperty("major.release"),
      props.getProperty("minor.release"),
      props.getProperty("patch.release"));
  build =
  String.format("%s (%s) @ %s", props.getProperty("svn.build.number"),
      props.getProperty("ci.build.number"), props.getProperty("deploy.time"));
} finally {
  is.close();
}

for team city users
http://devnet.jetbrains.net/thread/282763

Comments

Popular posts from this blog

ADF Encountered deferred syntax #{ in template text.

OracleJSP error: oracle.jsp.parse.JspParseException:  Error: Encountered deferred syntax #{ in template text.  If intended as a literal, escape it or set directive  deferredSyntaxAllowedAsLiteral This normally happens when you have some tag lib dependancy problems but this was  not the case for me... My problem: For some reason my model project had web stuff in it(public html etc)  so I had to remove the public html stuff from my project and manually edit the Model.jpr project file and remove the tag lib entries at the bottom o the file. Go figure.    

JBO-25013: TooManyObjectsException

oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key[Key null ]. Ok so for you it may be trying to insert a duplicate record this should explain your problem (also check trigger they could be the cause.) NOTE: You can also try to create a new duplicate EO if you have a page with two VO's using the same EO. This could sort your problems. For me I needed to add a launch listener on my LOV and clear the cache of my vo. LOV <af:inputListOfValues id="NameId" popupTitle="#{bindings.Name.hints.label}" value="#{bindings.RolName1.inputValue}" label="#{bindings.RolName1.hints.label}" model="#{bindings.RolName1.listOfValuesModel}" required="#{bindings.RolName1.hints.mandatory}" columns="#{bindings.RolName1.hints.displayWidth}" shortDesc="#{bindings.RolName1.hints.tooltip}" launchPopupListener="#{backingBeanScope.backingBean.launchPop

OJDeploy: Documentation for the tool

Real DOCS:  http://docs.oracle.com/cd/E26098_01/user.1112/e17455/deploying_apps.htm#OJDUG645 OJDeploy Documentation if you run it from the command line - I keep looking for this so I though I would post it here so I remeber. Oracle JDeveloper Deploy 11.1.2.1.0.6081 Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. Usage:   ojdeploy -profile <name> -workspace <jws> [ -project <name> ] [ <options> ]   ojdeploy -buildfile <ojbuild.xml> [ <options> ]   ojdeploy -buildfileschema Arguments:   -profile               the name of the Profile to deploy   -workspace      full path to the JDeveloper Workspace file(.jws)   -project              name of the JDeveloper Project within the .jws where the Profile can be found. If omitted, the Profile is assumed to be in the Workspace.   -buildfile            full path to a build file for batch deploy   -buildfileschema  print XML Schema for the build file