<div dir="ltr">Hi,<div><br></div><div>The go plugin might be a good starting place to see how to achieve this; it uses its own _run() using a custom build environment rather than relying on the defaults.</div><div><br></div><div>So in the ant plugin, change calls to self.run() with calls to self._run and define _run with your overloaded environment.</div><div><br></div><div>Cheers,</div><div>- Loïc</div>
</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 11, 2016 at 11:38 AM, Jian LUO <span dir="ltr"><<a href="mailto:jian.luo.cn@gmail.com" target="_blank">jian.luo.cn@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi,</p>
<p dir="ltr">Thanks for the explanation. That's exactly what comes first in my mind. I've tried to customize the ant / jdk plugin by overriding the env method. The doc string of BasePlugin.env reads "return a list with the execution environment for building". However the result env applies both to build time and to the generated wrapper nonetheless. How can i override runtime only env in the plugin?</p><span class="HOEnZb"><font color="#888888">
<p dir="ltr">Jian</p>
</font></span><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Oct 11, 2016 09:53, "Didier Roche" <<a href="mailto:didrocks@ubuntu.com" target="_blank">didrocks@ubuntu.com</a>> wrote:<br type="attribution"></div></div><blockquote class="m_-9094793141840334395quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div bgcolor="#FFFFFF" text="#000000"><div class="m_-9094793141840334395quoted-text">
<div class="m_-9094793141840334395m_-2169087758538543871moz-cite-prefix">Le 10/10/2016 à 23:49, Jian LUO a
écrit :<br>
</div>
<blockquote type="cite">
<p dir="ltr">Hi,</p>
<p dir="ltr">I don't think it counts as cross compiling since Java
(at least in my case) is cross platform. Just wanted to compile
Java with one JDK and run with another. </p>
</blockquote>
<br></div>
Hey,<br>
<br>
I'm adding Sergio to the conversation, but I think the easiest path
is to create a custom plugin, inheriting from the base java one,
which is outputting a wrapper scripts with different JAVA env
variables.<br>
That way, you keep the current building behavior (build with java on
the machine), but output a script which will point to an armhf java
path for instance and download the correct version and packages
version for all those.<br>
Cross-compilation-like may be needed as Manik suggested as you will
need to pull some packages which are architectures specific.<br>
<br>
On how to create a custom plugin, here is some documentation:
<a class="m_-9094793141840334395m_-2169087758538543871moz-txt-link-freetext" href="http://snapcraft.io/docs/build-snaps/plugins" target="_blank">http://snapcraft.io/docs/build<wbr>-snaps/plugins</a> and the playpen has
some example:
<a class="m_-9094793141840334395m_-2169087758538543871moz-txt-link-freetext" href="https://github.com/ubuntu/snappy-playpen/blob/master/idea/parts/plugins/x-antIntellij.py" target="_blank">https://github.com/ubuntu/snap<wbr>py-playpen/blob/master/idea/<wbr>parts/plugins/x-antIntellij.py</a><br>
I'll let Sergio adding more info as needed :)<br>
<br>
Cheers,<br>
Didier<div class="m_-9094793141840334395quoted-text"><br>
<br>
<br>
<blockquote type="cite">
<p dir="ltr">Jian</p>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Oct 10, 2016 20:05, "Manik Taneja"
<<a href="mailto:manik@canonical.com" target="_blank">manik@canonical.com</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Oct 10, 2016 at 6:33
AM, Jian LUO <span dir="ltr"><<a href="mailto:jian.luo.cn@gmail.com" target="_blank">jian.luo.cn@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<p dir="ltr">Hi List,</p>
<p dir="ltr">Is there any formal way in snapcraft
to set environment variables separately for build
time and run time? The use case I'm facing is
building a Java snap on amd64 host for armhf
target.</p>
</blockquote>
Snapcraft does not support cross-compilation. Consider
building natively on armhf, or using this as
reference-<br>
<br>
<a href="https://github.com/snapcore/snapd/blob/master/docs/cross-build.md" target="_blank">https://github.com/snapcore/sn<wbr>apd/blob/master/docs/cross-bui<wbr>ld.md</a><br>
<br>
</div>
<div class="gmail_quote">and let us know if you see any
issues.<br>
</div>
<div class="gmail_quote"><br>
</div>
<div class="gmail_quote">/Manik<br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<br>
<fieldset class="m_-9094793141840334395m_-2169087758538543871mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
<p><br>
</p>
</div></div>
<br></div></div><span class="">--<br>
Snapcraft mailing list<br>
<a href="mailto:Snapcraft@lists.snapcraft.io" target="_blank">Snapcraft@lists.snapcraft.io</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/snapcraft" rel="noreferrer" target="_blank">https://lists.ubuntu.com/mailm<wbr>an/listinfo/snapcraft</a><br>
<br></span></blockquote></div><br></div>
<br>--<br>
Snapcraft mailing list<br>
<a href="mailto:Snapcraft@lists.snapcraft.io">Snapcraft@lists.snapcraft.io</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/snapcraft" rel="noreferrer" target="_blank">https://lists.ubuntu.com/<wbr>mailman/listinfo/snapcraft</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">- Loïc</div></div>
</div>