Skipping a javah task with Java 10 and higher

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Skipping a javah task with Java 10 and higher

大平怜
Hello,

My build.xml has a javah task. Since it no longer works with Java 10 and
higher, I added nativeHeaderDir to a javac task, and it is working fine.
However, I still want to keep the javah task, so that the same build.xml
works for older Java.

How can I make ant skip the javah task only when running with Java 10 and
higher? More generally, is there any way to switch the execution path in
build.xml, depending on the Java version? Or, is there any other standard
way to migrate a javah task from old Java to Java 10/11 with
backward-compatibility being maintained? Appreciate your help.


Thanks,
Rei Odaira
Reply | Threaded
Open this post in threaded view
|

Re: Skipping a javah task with Java 10 and higher

Jaikiran Pai-2
Recent versions of Ant (starting 1.10.2) have a "javaversion"
condition[1] which you can use to setup a "property" which can then be
used with "if"/"unless" attribute on a target.

Here's an example:

<target name="the-one-which-has-javah-task" depends="check-java-version"
unless="java10+">
    ...
</target>   

<target name="check-java-version">
    <condition property="java10+">
      <javaversion atleast="10"/>
    </condition>
</target>

[1] https://ant.apache.org/manual/Tasks/conditions.html#javaversion

-Jaikiran

On 07/05/19 10:53 AM, 大平怜 wrote:

> Hello,
>
> My build.xml has a javah task. Since it no longer works with Java 10 and
> higher, I added nativeHeaderDir to a javac task, and it is working fine.
> However, I still want to keep the javah task, so that the same build.xml
> works for older Java.
>
> How can I make ant skip the javah task only when running with Java 10 and
> higher? More generally, is there any way to switch the execution path in
> build.xml, depending on the Java version? Or, is there any other standard
> way to migrate a javah task from old Java to Java 10/11 with
> backward-compatibility being maintained? Appreciate your help.
>
>
> Thanks,
> Rei Odaira
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

AW: Skipping a javah task with Java 10 and higher

Jan Matèrne (jhm)
With xml namespaces like if:set you could exclude individual tasks.
http://ant.apache.org/manual/ifunless.html


<project>
    <condition property="java10+">
       <javaversion atleast="10"/>
    </condition>

    <target name="do-only-on-newer-versions" if="java10+">
        ...
    </target>

    <target name="compile">
        <javah ... if:set="java10+" xmlns:if="ant:if"/>
        <javac ... />
    </target>
</project>


Jan

> -----Ursprüngliche Nachricht-----
> Von: Jaikiran Pai [mailto:[hidden email]]
> Gesendet: Dienstag, 7. Mai 2019 07:38
> An: [hidden email]
> Betreff: Re: Skipping a javah task with Java 10 and higher
>
> Recent versions of Ant (starting 1.10.2) have a "javaversion"
> condition[1] which you can use to setup a "property" which can then be
> used with "if"/"unless" attribute on a target.
>
> Here's an example:
>
> <target name="the-one-which-has-javah-task" depends="check-java-
> version"
> unless="java10+">
>     ...
> </target>
>
> <target name="check-java-version">
>     <condition property="java10+">
>       <javaversion atleast="10"/>
>     </condition>
> </target>
>
> [1] https://ant.apache.org/manual/Tasks/conditions.html#javaversion
>
> -Jaikiran
>
> On 07/05/19 10:53 AM, 大平怜 wrote:
> > Hello,
> >
> > My build.xml has a javah task. Since it no longer works with Java 10
> > and higher, I added nativeHeaderDir to a javac task, and it is
> working fine.
> > However, I still want to keep the javah task, so that the same
> > build.xml works for older Java.
> >
> > How can I make ant skip the javah task only when running with Java 10
> > and higher? More generally, is there any way to switch the execution
> > path in build.xml, depending on the Java version? Or, is there any
> > other standard way to migrate a javah task from old Java to Java
> 10/11
> > with backward-compatibility being maintained? Appreciate your help.
> >
> >
> > Thanks,
> > Rei Odaira
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] For additional
> commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Skipping a javah task with Java 10 and higher

大平怜
Thanks much for your help!  The javaversion condition works perfectly.


Rei Odaira

2019年5月7日(火) 0:58 Jan Matèrne (jhm) <[hidden email]>:

> With xml namespaces like if:set you could exclude individual tasks.
> http://ant.apache.org/manual/ifunless.html
>
>
> <project>
>     <condition property="java10+">
>        <javaversion atleast="10"/>
>     </condition>
>
>     <target name="do-only-on-newer-versions" if="java10+">
>         ...
>     </target>
>
>     <target name="compile">
>         <javah ... if:set="java10+" xmlns:if="ant:if"/>
>         <javac ... />
>     </target>
> </project>
>
>
> Jan
>
> > -----Ursprüngliche Nachricht-----
> > Von: Jaikiran Pai [mailto:[hidden email]]
> > Gesendet: Dienstag, 7. Mai 2019 07:38
> > An: [hidden email]
> > Betreff: Re: Skipping a javah task with Java 10 and higher
> >
> > Recent versions of Ant (starting 1.10.2) have a "javaversion"
> > condition[1] which you can use to setup a "property" which can then be
> > used with "if"/"unless" attribute on a target.
> >
> > Here's an example:
> >
> > <target name="the-one-which-has-javah-task" depends="check-java-
> > version"
> > unless="java10+">
> >     ...
> > </target>
> >
> > <target name="check-java-version">
> >     <condition property="java10+">
> >       <javaversion atleast="10"/>
> >     </condition>
> > </target>
> >
> > [1] https://ant.apache.org/manual/Tasks/conditions.html#javaversion
> >
> > -Jaikiran
> >
> > On 07/05/19 10:53 AM, 大平怜 wrote:
> > > Hello,
> > >
> > > My build.xml has a javah task. Since it no longer works with Java 10
> > > and higher, I added nativeHeaderDir to a javac task, and it is
> > working fine.
> > > However, I still want to keep the javah task, so that the same
> > > build.xml works for older Java.
> > >
> > > How can I make ant skip the javah task only when running with Java 10
> > > and higher? More generally, is there any way to switch the execution
> > > path in build.xml, depending on the Java version? Or, is there any
> > > other standard way to migrate a javah task from old Java to Java
> > 10/11
> > > with backward-compatibility being maintained? Appreciate your help.
> > >
> > >
> > > Thanks,
> > > Rei Odaira
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email] For additional
> > commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

AW: Skipping a javah task with Java 10 and higher

Jan Matèrne (jhm)
Fine.
But I see an error in my example:
It executes the target and javah only on Java10 and higher.
For Java9 and lower you have to use:
  <target unless="java10+">
  <javah if:unset="java10+" ...

Jan

> -----Ursprüngliche Nachricht-----
> Von: 大平怜 [mailto:[hidden email]]
> Gesendet: Dienstag, 7. Mai 2019 17:26
> An: Ant Users List
> Betreff: Re: Skipping a javah task with Java 10 and higher
>
> Thanks much for your help!  The javaversion condition works perfectly.
>
>
> Rei Odaira
>
> 2019年5月7日(火) 0:58 Jan Matèrne (jhm) <[hidden email]>:
>
> > With xml namespaces like if:set you could exclude individual tasks.
> > http://ant.apache.org/manual/ifunless.html
> >
> >
> > <project>
> >     <condition property="java10+">
> >        <javaversion atleast="10"/>
> >     </condition>
> >
> >     <target name="do-only-on-newer-versions" if="java10+">
> >         ...
> >     </target>
> >
> >     <target name="compile">
> >         <javah ... if:set="java10+" xmlns:if="ant:if"/>
> >         <javac ... />
> >     </target>
> > </project>
> >
> >
> > Jan
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Jaikiran Pai [mailto:[hidden email]]
> > > Gesendet: Dienstag, 7. Mai 2019 07:38
> > > An: [hidden email]
> > > Betreff: Re: Skipping a javah task with Java 10 and higher
> > >
> > > Recent versions of Ant (starting 1.10.2) have a "javaversion"
> > > condition[1] which you can use to setup a "property" which can then
> > > be used with "if"/"unless" attribute on a target.
> > >
> > > Here's an example:
> > >
> > > <target name="the-one-which-has-javah-task" depends="check-java-
> > > version"
> > > unless="java10+">
> > >     ...
> > > </target>
> > >
> > > <target name="check-java-version">
> > >     <condition property="java10+">
> > >       <javaversion atleast="10"/>
> > >     </condition>
> > > </target>
> > >
> > > [1] https://ant.apache.org/manual/Tasks/conditions.html#javaversion
> > >
> > > -Jaikiran
> > >
> > > On 07/05/19 10:53 AM, 大平怜 wrote:
> > > > Hello,
> > > >
> > > > My build.xml has a javah task. Since it no longer works with Java
> > > > 10 and higher, I added nativeHeaderDir to a javac task, and it is
> > > working fine.
> > > > However, I still want to keep the javah task, so that the same
> > > > build.xml works for older Java.
> > > >
> > > > How can I make ant skip the javah task only when running with
> Java
> > > > 10 and higher? More generally, is there any way to switch the
> > > > execution path in build.xml, depending on the Java version? Or,
> is
> > > > there any other standard way to migrate a javah task from old
> Java
> > > > to Java
> > > 10/11
> > > > with backward-compatibility being maintained? Appreciate your
> help.
> > > >
> > > >
> > > > Thanks,
> > > > Rei Odaira
> > > >
> > >
> > >
> > > -------------------------------------------------------------------
> -
> > > - To unsubscribe, e-mail: [hidden email] For
> > > additional commands, e-mail: [hidden email]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email] For
> additional
> > commands, e-mail: [hidden email]
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]