ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Sisson" <john.sis...@net-linx.com>
Subject 'java' task does not exit
Date Thu, 30 Mar 2006 00:53:37 GMT
Hello
I have extended the ant 'org.apache.tools.ant.taskdefs.Java' task to
setup many of the parameters from a property file using my class
'com.nxps.ant.tasking.JavaNx'; apart from the parameter management its
action is pretty simple:
==
public final class JavaNx extends Java {
  /**********************************************
   * where the work is done
   * <p>
   * NOTE: this operates as follows:
   * - validate the arguments
   *
   * @throws org.apache.tools.ant.BuildException
   */
  public void execute() throws BuildException {
    preValidate();
    preExecute();
    super.execute();
    postExecute();
  }
}
==

Ant itself is launched via a java commandline against the base
ant-launcher jar with my task jar in the classpath and with a
task-specific property file:
java -D"java.class.path=%ant_lnch_jar%" -D"ant.home=%ant_home%"
%ant_opts% %ant_lnch_cls%
     -buildfile nxLauncher.xml 
     -propertyfile %_prop%

The nxLauncher.xml fires off the extended NxJava task:
  <!--
   |== the nxJava launcher task
   |-->
  <target name="launch.service" unless="nx.launch.office.only">
    <echo message="hi from the service launcher"/>

    <property name="nx.ant.libs" value="${basedir}/lib/ant" />
    <taskdef name="DoJavaNx"
             classpath="${nx.ant.libs}"
             classname="com.nxps.ant.tasking.JavaNx"/>

    <echo message="about to run nxJava"/>

    <!-- run it -->
    <DoJavaNx classname="${nx.launch.class}"
              dir="${nx.launch.loc}"
              fork="true"
              spawn="${nx.launch.spawn}"
              nxappargs="${nx.launch.params}"
              nxappconfig="${nx.launch.config}"
              nxclsroot="${basedir}/lib"
              nxclslibs="${nx.launch.libs}"
              nxjvmargs="${nx.launch.jvmargs}"
              nxjvmmem="${nx.launch.memory}"
              nxjvmdebug="${nx.launch.dbg.active}"
              nxjvmsuspend="${nx.launch.dbg.suspend}"
              nxjvmport="${nx.launch.dbg.port}"
              >
    </DoJavaNx>
  </target>

Finally the problem:
The suite of java applications launched in various modes by this, attach
to an instance of OpenOffice via the "-bean -accept..." UNO connection
and use it to manage text blocks.
If the instance is not found or if the instance dies and provokes an
openoffice.DisposedException, the applications launch a new instance of
OpenOffice using the method:
    Runtime.getRuntime().exec(String[] args);

In this case and only if the application has launched OpenOffice, the
NxJava task never completes even if the application itself is terminated
and exits properly.

It appears that Ant now just knows there is another process even though
it is completely independent and Ant cannot complete the task until that
process dies. This can be shown by killing OpenOffice explicitly,
whereupon the Ant task completes.

So the question:
Is this working as would be expected? Is there a way to launch a child
process from within an application under control of Ant such that Ant
will complete when the primary application terminates???

Thanx
John Sisson

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message