Hi, To follow up on this issue I solved it by extending the wrapper script. I add the required external jars to the existing class-path in wrapper. So wrapper looks like :
#!/bin/sh export CLASSPATH=$SNAP_APP_PATH/jar/HelloWorld-helper.jar:$CLASSPATH java oata.HelloWorld This works fine. I have two examples now derived from the original java-hello-world example. Example 1 builds two jars and lets snapcraft do the work by adding the two jars that it builds to the class-path. Example 2 builds one jar and then takes care to add the required external jar to the class-path in the wrapper script. I can provide both if you think they might be of interest to other developers. Regards, Jenny On 14 June 2016 at 13:33, Sergio Schvezov <[email protected]> wrote: > El martes, 14 de junio de 2016 08h'15:48 ART, Jenny Murphy < > [email protected]> escribió: > >> Hi, >> I am trying to build up some competency with snapcraft for java >> applications. >> >> Currently I have a hello world project which is based on >> >> https://github.com/ubuntu-core/snapcraft/blob/1.x/examples/java-hello-world/snapcraft.yaml >> . >> >> I have extended in that HelloWorld.java references a method from another >> package in an external jar file (HellowWorld-helper.jar) >> >> I edited the snapcraft.yaml to use the copy plugin to copy the jar file to >> the jar directory. >> It can be seen there after the snap stage. >> >> However in bin.wrapper.wrapper , the external jar file is not added to the >> classpath. So the application fails on running. >> >> How do I fix this? >> > > First of all, thank you for giving this a try. I'll start with a couple of > details and follow on with a solution. > > First of all, `bin.wrapper.bin` is an implementation detail, likely to go > away when we implement allowing `apps` (and `plugins`) to define > environment variables (https://pad.lv/1583259) which would do the right > thing on a snappy system. How would this look like in the not so distant > future: > > ... > apps: > bin: > command: .... > environment: > CLASSPATH: $CLASSPATH:$SNAP/path_to_jar/jar.jar > > parts: > ... > > Now on to your problem. The java related plugins have logic to export > environment variables, but each part (driven by a plugin), is a private > world of its own. Since you used the copy plugin, the logic in the copy > plugin is just to copy. How do we solve in the immediate future? Well you > would need to create something similar to that wrapper and export the > required CLASSPATH. > > I'll cut off here to not go into to much details, but I am happy to follow > up on this. > > Cheers > Sergio > > > -- > Enviado con Dekko desde mi dispositivo Ubuntu > > -- > Snapcraft mailing list > [email protected] > Modify settings or unsubscribe at: > https://lists.ubuntu.com/mailman/listinfo/snapcraft > -- *Jenny Murphy* *EpiSensor, Georges Quay House, Georges Quay, Limerick, Ireland* [email protected] <[email protected]> t | +353 (0) 61 512 511 w | http://www.episensor.com
-- Snapcraft mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/snapcraft
