app-id: cat.xtec.clic.JClic
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.openjdk11
command: jclic

finish-args:
  - --share=ipc
  - --socket=fallback-x11
  - --socket=wayland
  - --socket=pulseaudio
  - --share=network
  - --device=dri
  - --filesystem=home

  - --env=PATH=/usr/bin:/app/bin:/app/jre/bin
  - --env=JAVA_HOME=/app/jre
  - --env=JAVA=/app/jre/bin/java

build-options:
    env:
        JAVA_HOME: /usr/lib/sdk/openjdk11/
modules:
  - name: openjdk
    buildsystem: simple
    build-commands:
      - /usr/lib/sdk/openjdk11/install.sh

  - name: jclic
    no-autogen: true
    sources:
      # Fetch project.
      - type: archive
        url: https://clic.xtec.cat/dist/jclic/jclic-0.3.2.18.zip
        sha256: 2240e66c0435a37044c96d4946a5ca50a305f277f3a9fe6c8b243406d547c043
      
      # Install AppData.
      - type: file
        path: cat.xtec.clic.JClic.metainfo.xml

      # Install desktop files.
      - type: file
        path: desktopfiles/jclic.desktop
        #path: https://raw.githubusercontent.com/projectestac/jclic/master/dist/linux/applications/jclic.desktop
        dest-filename: jclic.desktop

      - type: file
        path: desktopfiles/jclicauthor.desktop
        # path: https://raw.githubusercontent.com/projectestac/jclic/master/dist/linux/applications/jclicauthor.desktop
        dest-filename: jclicauthor.desktop

      # mime file.
      - type: file
        path: cat.xtec.clic.JClic.mime.xml

      # shell commands.
      - type: file
        path: jclic.sh
      - type: file
        path: jclicauthor.sh        

    buildsystem: simple
    build-commands: 
      - mkdir -p /app/JClic /app/bin
      - cp -ra *.jar /app/JClic
      - install -Dm755 jclic.sh /app/bin/jclic
      - install -Dm755 jclicauthor.sh /app/bin/jclicauthor
      - install -Dm644 jclic.desktop /app/share/applications/cat.xtec.clic.JClic.jclic.desktop   
      - install -Dm644 jclicauthor.desktop /app/share/applications/cat.xtec.clic.JClic.jclicautor.desktop
      - install -Dm644 icons/author.svg /app/share/icons/hicolor/scalable/apps/cat.xtec.clic.JClic.jclicauthor.svg
      - install -Dm644 icons/jclic.svg /app/share/icons/hicolor/scalable/apps/cat.xtec.clic.JClic.jclic.svg
      - install -Dm644 -p -t /app/share/mime/packages cat.xtec.clic.JClic.mime.xml
      - install -Dm644 cat.xtec.clic.JClic.metainfo.xml /app/share/metainfo/cat.xtec.clic.JClic.metainfo.xml

    post-install:
      - update-mime-database /app/share/mime

