OVH Cloud OVH Cloud

ant et os

3 réponses
Avatar
marc26
salut
dans un build.xml j'ai

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry"></exec>
</target>

c'est ok pour la majorité des os... mais pas win

donc faudrait qu'avec la variable ${os.name} que je puisse changer la valeur
de executable pour avoir

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry.exe"></exec>
</target>

pour windows et rmiregistry pour le reste des os...

quelqu'un sait comment faire?

3 réponses

Avatar
Frédéric Lachasse
"marc26" wrote in message
news:QoDAf.58587$
salut
dans un build.xml j'ai

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry"></exec>
</target>

c'est ok pour la majorité des os... mais pas win

donc faudrait qu'avec la variable ${os.name} que je puisse changer la
valeur
de executable pour avoir

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry.exe"></exec>
</target>

pour windows et rmiregistry pour le reste des os...


The idea is to have a target that sets conditional properties and use "if"
or "unless" in a target for conditional execution:

<target name="registry" description="Run the RMI registry only"
depends="init,registry-unix,registry-windows/>

<target name="init">
<!-- set is.windows to true if running on Windows -->
<condition property="is.windows">
<os family="windows"/>
</condition>
</target>

<!-- run rmiregistry on Unix -->
<target name="registry-unix" unless="is.windows"/>
<exec executable="rmiregistry"/>
</target>

<!-- run rmiregistry on Windows -->
<target name="registry-windows" if="is.windows">
<exec executable="rmiregistry.exe"/>
</target>

--
Frédéric Lachasse - ECP86

Avatar
Olivier Thomann
salut
dans un build.xml j'ai

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry"></exec>
</target>

c'est ok pour la majorité des os... mais pas win

donc faudrait qu'avec la variable ${os.name} que je puisse changer la valeur
de executable pour avoir

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry.exe"></exec>
</target>

pour windows et rmiregistry pour le reste des os...

quelqu'un sait comment faire?
Utilise l'attribut os de la tache exec.

os list of Operating Systems on which the command may be executed. If
the current OS's name is contained in this list, the command will be
executed. The OS's name is determined by the Java Virtual machine and is
set in the "os.name" system property.

Voir: http://ant.apache.org/manual/CoreTasks/exec.html
--
Olivier

Avatar
marc26
Frédéric Lachasse wrote:

"marc26" wrote in message
news:QoDAf.58587$
salut
dans un build.xml j'ai

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry"></exec>
</target>

c'est ok pour la majorité des os... mais pas win

donc faudrait qu'avec la variable ${os.name} que je puisse changer la
valeur
de executable pour avoir

<target name="registry" description="Run the RMI registry only">
<exec executable="rmiregistry.exe"></exec>
</target>

pour windows et rmiregistry pour le reste des os...


The idea is to have a target that sets conditional properties and use "if"
or "unless" in a target for conditional execution:

<target name="registry" description="Run the RMI registry only"
depends="init,registry-unix,registry-windows/>

<target name="init">
<!-- set is.windows to true if running on Windows -->
<condition property="is.windows">
<os family="windows"/>
</condition>
</target>

<!-- run rmiregistry on Unix -->
<target name="registry-unix" unless="is.windows"/>
<exec executable="rmiregistry"/>
</target>

<!-- run rmiregistry on Windows -->
<target name="registry-windows" if="is.windows">
<exec executable="rmiregistry.exe"/>
</target>




don't seem to work...


ant build.xml
Buildfile: build.xml

BUILD FAILED
/home/collinm/build.xml:18: The value of attribute "depends" associated with
an element type "target" must not contain the '<' character.


ant don't like

my build.xml is:


<project name="test">

<!-- All targets needed for clean up -->

<target name="registry" description="Run the RMI registry only"
depends="init,registry-unix,registry-windows/>

<target name="init">
<!-- set is.windows to true if running on Windows -->
<condition property="is.windows">
<os family="windows"/>
</condition>
</target>

<!-- run rmiregistry on Unix -->
<target name="registry-unix" unless="is.windows"/>
<exec executable="registry"/>
</target>

<!-- run rmiregistry on Windows -->
<target name="registry-windows" if="is.windows">
<exec executable="rmiregistry.exe"/>
</target>

</project>