3

I'm trying to change the source of a java snap. Here's what I do:

  1. Download the sample project.

    svn export https://github.com/snapcore/snapcraft/trunk/demos/java-hello-world
    
  2. Build the snap named java-hello-world.

    cd java-hello-world  
    snapcraft
    
  3. Install the snap.

    sudo snap install java-hello-world_0_amd64.snap --dangerous
    
  4. Run the snap.

    java-hello-world.hello
    

    The output is Hello World as expected.

Now I want to change the snap so it prints "Hello Snap" instead of "Hello World". Here's what I do:

  1. Edit java-hello-world/snap/snapcraft.yaml. Change grade to devel and confinement to devmode.

  2. Edit java-hello-world/src/oata/HelloWorld.java. Change line 7 to System.out.println("Hello Snap");.

  3. Iterate over the snap.

    snapcraft prime
    sudo snap try --devmode prime/
    

    The output is Hello World. I would like to have the output Hello Snap here.

What I'm doing wrong: There are two things in the build process which seem suspicious to me.

  1. When running snapcraft prime it says:

    Skipping pull local (already ran)  
    Skipping build local (already ran)  
    Skipping stage local (already ran)  
    Skipping prime local (already ran)  
    Skipping pull wrapper (already ran)  
    Skipping build wrapper (already ran)  
    Skipping stage wrapper (already ran)  
    Skipping prime wrapper (already ran) 
    

    I guess skipping all these steps also includes skipping reading and compiling the file java-hello-world/src/oata/HelloWorld.java. Thats why the output is still the same after editing the file. How can I not skip that step? The tutorial says:

    Note: The different steps of snapcraft are: pull (download source for all parts), build, stage (consolidate installed files of all parts), prime (distill down to just the desired files), snap (create a snap out of the prime/ directory). Each steps depends on the previous one to be completed".

    I tried to snapcraft pull instead of prime, but the result is the same.

  2. When running snapcraft the first time, ant gives a warning.

    [javac] /home/username/Java/java-hello-world/parts/local/build/build.xml:19: warning: 'includeantruntime' was not set,
    defaulting to build.sysclasspath=last; set to false for repeatable builds
    

    I don't know what defaulting to build.sysclasspath=last means. So that might be the problem. "set to false for repeatable builds" should be ok, because thats what this answer suggests.

How can I refresh the source of the snap after changing it? Many thanks in advance.

2
  1. Clean the previous build

    snapcraft clean
    

    But when you have big project you may want only for that part

    snapcraft clean local
    
  2. Rebuild again

    snapcraft
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.