You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Simon Nash <na...@hursley.ibm.com> on 2006/11/06 00:26:42 UTC

Avoiding multiple copies of the standalone runtime

The sample readme.html instructions tell the user to run
   mvn dependency:unpack
to create a standalone distribution under the sample's target directory.
This means that each sample will have its own private copy of the
standalone runtime, and following these instructions for n samples will
create n copies of the standalone runtime.

I think it would be useful to describe how a user can have a single
installed copy of the standalone runtime and use it to run different
standalone applications (both samples and user applications).
Needing to have a dedicated standalone runtime for each standalone
application would seem rather surprising to many users.

So, in the best spirit of volunteering, I set out to do this.  In the
build.xml ant scripts that I am creating for the samples, I have been
assuming this mode of operation, with a single copy of the standalone
runtime installed in a directory of the user's choice, and a TUSCANY_HOME
environment variable set to the absolute path of this directory.
However, I have been having a lot of problems getting ant to treat
file paths derived from TUSCANY_HOME as absolute paths rather than as
relative paths from the current sample directory.

Here's an example of what I'm trying to do.  I've tried all kinds of
variations but they all have the same issue.

<project name="calculator" default="compile">
     <property environment="env"/>
     <property name="tuscanyHome" location="$(env.TUSCANY_HOME)"/>
     <property name="tuscanyLauncher" location="$(tuscanyHome)/bin/launcher.jar"/>
     <property name="tuscanySCA" location="$(tuscanyHome)/lib/sca-api-r0.95-1.0-incubator-M2.jar"/>

     <path id="scaClassPath">
         <pathelement location="$(tuscanySCA)"/>
     </path>

     <target name="init">
         <mkdir dir="target/classes"/>
     </target>

     <target name="compile" depends="init">
         <javac srcdir="src/main/java" destdir="target/classes" debug="on" source="1.5" target="1.5">
             <classpath refid="scaClassPath"/>
         </javac>
         <copy todir="target/classes">
             <fileset dir="src/main/resources"/>
         </copy>
         <copy todir="target/classes/META-INF">
             <fileset dir='.' includes="LICENSE.txt,NOTICE.txt"/>
         </copy>
         <jar destfile="target/sample-calculator.jar" basedir="target/classes">
             <manifest>
                 <attribute name="Main-Class" value="calculator.CalculatorClient"/>
             </manifest>
         </jar>
     </target>

     <target name="run" depends="compile">
         <java jar="$(tuscanyLauncher)" fork="true">
             <arg value="target/sample-calculator.jar"/>
         </java>
	</target>

     <target name="clean">
         <delete quiet="true" includeemptydirs="true">
             <fileset dir="target"/>
         </delete>
     </target>
</project>

The problem is that uses of the properties $(tuscanySCA) and $(tuscanyLauncher)
are treated as relative paths (prefixed by the current sample's basedir)
rather than absolute paths as intended.  If I hard-wire the absolute paths
in the <path> and <java> tasks, like so:

......... cut ..........
     <path id="scaClassPath">
         <pathelement path="d:/tuscany9/lib/sca-api-r0.95-1.0-incubator-M2.jar"/>
     </path>
......... cut ..........
         <java jar="d:/tuscany9/bin/launcher.jar" fork="true">
             <arg value="target/sample-calculator.jar"/>
         </java>
......... cut ..........

then all works as intended, but it is clearly unaceptable to hard-wire
absolute paths in this way.

I spent a while googling to try to find a solution to this, and came across
a few exchanges on the ant mailing lists that showed I am not the first to
run into this.  Surprisingly, no-one seemed to have a solution other than
suggestions to use "location" which I have tried with no success.

Can someone with ant experience point me in the right direction for a
solution, please?

   Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: Avoiding multiple copies of the standalone runtime

Posted by David Sanders <ds...@gmail.com>.
curly brackets,  e.g.,   ${env.TUSCANY_HOME}, correctly expands to absolute
path.
In the following, ${tmp} expands to an absolute path.

<project name="calculator" default="show-cp">
    <property environment="env" />
    <property name="tuscanyHome" location="${env.TUSCANY_HOME}" />
    <property name="tuscanySCA" location="${tuscanyHome}/lib/sca-
api-r0.95-1.0-incubator-M2.jar" />

    <path id="scaClassPath">
        <pathelement location="${tuscanySCA}" />
    </path>

    <target name="show-cp">
        <property name="tmp" refid="scaClassPath" />
        <echo message="scaClasspath=${tmp}" />
    </target>

</project>



On 11/5/06, Simon Nash <na...@hursley.ibm.com> wrote:
>
> The sample readme.html instructions tell the user to run
>    mvn dependency:unpack
> to create a standalone distribution under the sample's target directory.
> This means that each sample will have its own private copy of the
> standalone runtime, and following these instructions for n samples will
> create n copies of the standalone runtime.
>
> I think it would be useful to describe how a user can have a single
> installed copy of the standalone runtime and use it to run different
> standalone applications (both samples and user applications).
> Needing to have a dedicated standalone runtime for each standalone
> application would seem rather surprising to many users.
>
> So, in the best spirit of volunteering, I set out to do this.  In the
> build.xml ant scripts that I am creating for the samples, I have been
> assuming this mode of operation, with a single copy of the standalone
> runtime installed in a directory of the user's choice, and a TUSCANY_HOME
> environment variable set to the absolute path of this directory.
> However, I have been having a lot of problems getting ant to treat
> file paths derived from TUSCANY_HOME as absolute paths rather than as
> relative paths from the current sample directory.
>
> Here's an example of what I'm trying to do.  I've tried all kinds of
> variations but they all have the same issue.
>
> <project name="calculator" default="compile">
>      <property environment="env"/>
>      <property name="tuscanyHome" location="$(env.TUSCANY_HOME)"/>
>      <property name="tuscanyLauncher"
> location="$(tuscanyHome)/bin/launcher.jar"/>
>      <property name="tuscanySCA" location="$(tuscanyHome)/lib/sca-
> api-r0.95-1.0-incubator-M2.jar"/>
>
>      <path id="scaClassPath">
>          <pathelement location="$(tuscanySCA)"/>
>      </path>
>
>      <target name="init">
>          <mkdir dir="target/classes"/>
>      </target>
>
>      <target name="compile" depends="init">
>          <javac srcdir="src/main/java" destdir="target/classes" debug="on"
> source="1.5" target="1.5">
>              <classpath refid="scaClassPath"/>
>          </javac>
>          <copy todir="target/classes">
>              <fileset dir="src/main/resources"/>
>          </copy>
>          <copy todir="target/classes/META-INF">
>              <fileset dir='.' includes="LICENSE.txt,NOTICE.txt"/>
>          </copy>
>          <jar destfile="target/sample-calculator.jar"
> basedir="target/classes">
>              <manifest>
>                  <attribute name="Main-Class" value="
> calculator.CalculatorClient"/>
>              </manifest>
>          </jar>
>      </target>
>
>      <target name="run" depends="compile">
>          <java jar="$(tuscanyLauncher)" fork="true">
>              <arg value="target/sample-calculator.jar"/>
>          </java>
>         </target>
>
>      <target name="clean">
>          <delete quiet="true" includeemptydirs="true">
>              <fileset dir="target"/>
>          </delete>
>      </target>
> </project>
>
> The problem is that uses of the properties $(tuscanySCA) and
> $(tuscanyLauncher)
> are treated as relative paths (prefixed by the current sample's basedir)
> rather than absolute paths as intended.  If I hard-wire the absolute paths
> in the <path> and <java> tasks, like so:
>
> ......... cut ..........
>      <path id="scaClassPath">
>          <pathelement path="d:/tuscany9/lib/sca-
> api-r0.95-1.0-incubator-M2.jar"/>
>      </path>
> ......... cut ..........
>          <java jar="d:/tuscany9/bin/launcher.jar" fork="true">
>              <arg value="target/sample-calculator.jar"/>
>          </java>
> ......... cut ..........
>
> then all works as intended, but it is clearly unaceptable to hard-wire
> absolute paths in this way.
>
> I spent a while googling to try to find a solution to this, and came
> across
> a few exchanges on the ant mailing lists that showed I am not the first to
> run into this.  Surprisingly, no-one seemed to have a solution other than
> suggestions to use "location" which I have tried with no success.
>
> Can someone with ant experience point me in the right direction for a
> solution, please?
>
>    Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>

Re: Avoiding multiple copies of the standalone runtime

Posted by Rick <cr...@gmail.com>.
The samples were designed to just run the ones you were interested and each can 
require different extenstions.  So to make sure you are only running the minimal 
  extensions required by your sample you would also need to remove the ones that 
were copied for that example when you went to another.
Given creating the standalone runtime and deleting it takes 4 seconds I don't 
see an issue with the way it's being done.
I don't see having a separate a runtime by following each of the samples draws 
the conclusion you are required to.
I can put a few words with regard to this in the top level readme.html

Simon Nash wrote:
> The sample readme.html instructions tell the user to run
>   mvn dependency:unpack
> to create a standalone distribution under the sample's target directory.
> This means that each sample will have its own private copy of the
> standalone runtime, and following these instructions for n samples will
> create n copies of the standalone runtime.
> 
> I think it would be useful to describe how a user can have a single
> installed copy of the standalone runtime and use it to run different
> standalone applications (both samples and user applications).
> Needing to have a dedicated standalone runtime for each standalone
> application would seem rather surprising to many users.
> 
> So, in the best spirit of volunteering, I set out to do this.  In the
> build.xml ant scripts that I am creating for the samples, I have been
> assuming this mode of operation, with a single copy of the standalone
> runtime installed in a directory of the user's choice, and a TUSCANY_HOME
> environment variable set to the absolute path of this directory.
> However, I have been having a lot of problems getting ant to treat
> file paths derived from TUSCANY_HOME as absolute paths rather than as
> relative paths from the current sample directory.
> 
> Here's an example of what I'm trying to do.  I've tried all kinds of
> variations but they all have the same issue.
> 
> <project name="calculator" default="compile">
>     <property environment="env"/>
>     <property name="tuscanyHome" location="$(env.TUSCANY_HOME)"/>
>     <property name="tuscanyLauncher" 
> location="$(tuscanyHome)/bin/launcher.jar"/>
>     <property name="tuscanySCA" 
> location="$(tuscanyHome)/lib/sca-api-r0.95-1.0-incubator-M2.jar"/>
> 
>     <path id="scaClassPath">
>         <pathelement location="$(tuscanySCA)"/>
>     </path>
> 
>     <target name="init">
>         <mkdir dir="target/classes"/>
>     </target>
> 
>     <target name="compile" depends="init">
>         <javac srcdir="src/main/java" destdir="target/classes" 
> debug="on" source="1.5" target="1.5">
>             <classpath refid="scaClassPath"/>
>         </javac>
>         <copy todir="target/classes">
>             <fileset dir="src/main/resources"/>
>         </copy>
>         <copy todir="target/classes/META-INF">
>             <fileset dir='.' includes="LICENSE.txt,NOTICE.txt"/>
>         </copy>
>         <jar destfile="target/sample-calculator.jar" 
> basedir="target/classes">
>             <manifest>
>                 <attribute name="Main-Class" 
> value="calculator.CalculatorClient"/>
>             </manifest>
>         </jar>
>     </target>
> 
>     <target name="run" depends="compile">
>         <java jar="$(tuscanyLauncher)" fork="true">
>             <arg value="target/sample-calculator.jar"/>
>         </java>
>     </target>
> 
>     <target name="clean">
>         <delete quiet="true" includeemptydirs="true">
>             <fileset dir="target"/>
>         </delete>
>     </target>
> </project>
> 
> The problem is that uses of the properties $(tuscanySCA) and 
> $(tuscanyLauncher)
> are treated as relative paths (prefixed by the current sample's basedir)
> rather than absolute paths as intended.  If I hard-wire the absolute paths
> in the <path> and <java> tasks, like so:
> 
> ......... cut ..........
>     <path id="scaClassPath">
>         <pathelement 
> path="d:/tuscany9/lib/sca-api-r0.95-1.0-incubator-M2.jar"/>
>     </path>
> ......... cut ..........
>         <java jar="d:/tuscany9/bin/launcher.jar" fork="true">
>             <arg value="target/sample-calculator.jar"/>
>         </java>
> ......... cut ..........
> 
> then all works as intended, but it is clearly unaceptable to hard-wire
> absolute paths in this way.
> 
> I spent a while googling to try to find a solution to this, and came across
> a few exchanges on the ant mailing lists that showed I am not the first to
> run into this.  Surprisingly, no-one seemed to have a solution other than
> suggestions to use "location" which I have tried with no success.
> 
> Can someone with ant experience point me in the right direction for a
> solution, please?
> 
>   Simon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: Avoiding multiple copies of the standalone runtime

Posted by David Sanders <da...@alumni.duke.edu>.
curly brackets,  e.g.,   ${env.TUSCANY_HOME}, correctly expands to absolute
path.
In the following, ${tmp} expands to an absolute path.

<project name="calculator" default="show-cp">
    <property environment="env" />
    <property name="tuscanyHome" location="${env.TUSCANY_HOME}" />
    <property name="tuscanySCA" location="${tuscanyHome}/lib/sca-
api-r0.95-1.0-incubator-M2.jar" />

    <path id="scaClassPath">
        <pathelement location="${tuscanySCA}" />
    </path>

    <target name="show-cp">
        <property name="tmp" refid="scaClassPath" />
        <echo message="scaClasspath=${tmp}" />
    </target>

</project>

On 11/5/06, Simon Nash <na...@hursley.ibm.com> wrote:
>
> The sample readme.html instructions tell the user to run
>    mvn dependency:unpack
> to create a standalone distribution under the sample's target directory.
> This means that each sample will have its own private copy of the
> standalone runtime, and following these instructions for n samples will
> create n copies of the standalone runtime.
>
> I think it would be useful to describe how a user can have a single
> installed copy of the standalone runtime and use it to run different
> standalone applications (both samples and user applications).
> Needing to have a dedicated standalone runtime for each standalone
> application would seem rather surprising to many users.
>
> So, in the best spirit of volunteering, I set out to do this.  In the
> build.xml ant scripts that I am creating for the samples, I have been
> assuming this mode of operation, with a single copy of the standalone
> runtime installed in a directory of the user's choice, and a TUSCANY_HOME
> environment variable set to the absolute path of this directory.
> However, I have been having a lot of problems getting ant to treat
> file paths derived from TUSCANY_HOME as absolute paths rather than as
> relative paths from the current sample directory.
>
> Here's an example of what I'm trying to do.  I've tried all kinds of
> variations but they all have the same issue.
>
> <project name="calculator" default="compile">
>      <property environment="env"/>
>      <property name="tuscanyHome" location="$(env.TUSCANY_HOME)"/>
>      <property name="tuscanyLauncher"
> location="$(tuscanyHome)/bin/launcher.jar"/>
>      <property name="tuscanySCA" location="$(tuscanyHome)/lib/sca-
> api-r0.95-1.0-incubator-M2.jar"/>
>
>      <path id="scaClassPath">
>          <pathelement location="$(tuscanySCA)"/>
>      </path>
>
>      <target name="init">
>          <mkdir dir="target/classes"/>
>      </target>
>
>      <target name="compile" depends="init">
>          <javac srcdir="src/main/java" destdir="target/classes" debug="on"
> source="1.5" target="1.5">
>              <classpath refid="scaClassPath"/>
>          </javac>
>          <copy todir="target/classes">
>              <fileset dir="src/main/resources"/>
>          </copy>
>          <copy todir="target/classes/META-INF">
>              <fileset dir='.' includes="LICENSE.txt,NOTICE.txt"/>
>          </copy>
>          <jar destfile="target/sample-calculator.jar"
> basedir="target/classes">
>              <manifest>
>                  <attribute name="Main-Class" value="
> calculator.CalculatorClient"/>
>              </manifest>
>          </jar>
>      </target>
>
>      <target name="run" depends="compile">
>          <java jar="$(tuscanyLauncher)" fork="true">
>              <arg value="target/sample-calculator.jar"/>
>          </java>
>         </target>
>
>      <target name="clean">
>          <delete quiet="true" includeemptydirs="true">
>              <fileset dir="target"/>
>          </delete>
>      </target>
> </project>
>
> The problem is that uses of the properties $(tuscanySCA) and
> $(tuscanyLauncher)
> are treated as relative paths (prefixed by the current sample's basedir)
> rather than absolute paths as intended.  If I hard-wire the absolute paths
> in the <path> and <java> tasks, like so:
>
> ......... cut ..........
>      <path id="scaClassPath">
>          <pathelement path="d:/tuscany9/lib/sca-
> api-r0.95-1.0-incubator-M2.jar"/>
>      </path>
> ......... cut ..........
>          <java jar="d:/tuscany9/bin/launcher.jar" fork="true">
>              <arg value="target/sample-calculator.jar"/>
>          </java>
> ......... cut ..........
>
> then all works as intended, but it is clearly unaceptable to hard-wire
> absolute paths in this way.
>
> I spent a while googling to try to find a solution to this, and came
> across
> a few exchanges on the ant mailing lists that showed I am not the first to
> run into this.  Surprisingly, no-one seemed to have a solution other than
> suggestions to use "location" which I have tried with no success.
>
> Can someone with ant experience point me in the right direction for a
> solution, please?
>
>    Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>