Fat Jar Jar with Dependencies

Hello

Trying to build my first snap for my program highlighterpdf.

I have written it in java. I have it in a “fat jar” with all the dependencies.

Below is what I have in my Yaml file at the moment it fails with “The ‘parts’ property does not match the required schema: <ValidationError”

Here is my Yaml file:

name: highlighterpdf
title: HighlighterPdf
version: 1.0.2
summary: Highiight the text in a Pdf.
description:
        HighlighterPdf  is a free and open source software application that you can use to 
        highlight text in your pdf document. You can select text in a colour of your choice        
        and then save it.
base: core18

confinement: devmode

apps:
 highlighterpdf:
   extensions:
         - gnome-3-28
   command: java -jar highlighterpdf.jar
   environment:
         JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-amd64
         PATH: $JAVA_HOME/jre/bin:$PATH
         plugs:
               -home
               -network
               -cups-control
parts:

Thanks for any help you can give me

Regards

Gerry

You appear to be missing the entire parts: section which defines what goes in the snap.

I wrote a blog post a couple of months back about snapping java apps. Maybe take a look at that for reference. https://snapcraft.io/blog/building-a-java-snap-by-example

Thank you I found your blog post really helpful

Sorry to be such a pain I have another problem now.
Here is my latest Yaml:
name: highlighterpdf
title: HighlighterPdf
version: 1.0.2
summary: Highiight the text in a Pdf.
description:
HighlighterPdf is a free and open source software application that you can use to
highlight text in your pdf document. You can select text in a colour of your choice
and then save it.
base: core18

confinement: devmode

apps:
highlighterpdf:
extensions:
- gnome-3-28
command: java -jar highlighterpdf.jar
environment:
JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-amd64
PATH: $JAVA_HOME/jre/bin:$PATH
plugs:
-home
-network
-cups-control
parts:
highlighterpdf:
plugin: nil

now I get the error message

launch failed: KVM (vmx) is disabled by your BIOS.
Enter your BIOS setup and enable Virtualization Technology (VT).
An error occurred with the instance when trying to launch with ‘multipass’: returned exit code 2.
Ensure that ‘multipass’ is setup correctly and try again

But my bios does not have a setting for KVM to be enabled.

Thanks
Gerry

Hi

Thanks if you are reading this I found the problem I was looking in security when I should have looked in advanced in my bios.

I have another problem now but I will try and solve it myself as I think I have bothered you enough for the moment.

Regards
Gerry

Hi
Now for my next problem my Yaml at the moment is this:

title: HighlighterPdf
version: 1.0.2
summary: Highiight the text in a Pdf.
description:
        HighlighterPdf  is a free and open source software application that you can use to 
        highlight text in your pdf document. You can select text in a colour of your choice        
        and then save it.
base: core18

confinement: devmode

apps:
 highlighterpdf:
   extensions:
         - gnome-3-28
   command: java -jar $SNAP/highligherpdf.jar
   environment:
         JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-amd64
         PATH: $JAVA_HOME/jre/bin:$PATH
         plugs:
               -home
               -network
               -cups-control
parts:
  highlighterpdf:
       source: /home/gerry/Desktop/highlighterpdf/highlighterpdf.jar
       plugin: dump```
 and I am getting this fault message:

Failed to pull source: unable to determine source type of '/home/gerry/Desktop/highlighterpdf/highlighterpdf.jar'.
Check that the URL is correct or consider specifying `source-type` for this part. See `snapcraft help sources` for more information

Is there a special format for the source-type section when I put it in it just comes up with another fault?

Thanks
Gerry

Can you please edit your post to surround your code with triple backticks ``` so that the formatting is preserved. When you don’t do that, the indentation is stripped which makes it impossible to read correctly because in YAML indentation is very important.

JAR files are not a valid source-type. To get the JAR file into your snap you need to use a different source, for example a directory containing the JAR with the dump plugin.

Note, also, that a fully-qualified path to a location outside of snapcraft’s understanding is likely to fail on any system that isn’t the one you’re currently using. You should move your source to a directory alongside the snap directory, and use a relative path, or into a location that is accessible via other source-types such as a git repository or a tar.gz file acccessible via HTTP(s).

Thanks for your help Daniel

Silly question when I use this line:

source-type: local
source: $SNAP/highlighterpdf_main/
and put my jar inside of the directory it comes back with the fault "highlighter_main is not a directory ?

Regards
Gerry