Hello,
I am creating a snap. The application is written in Kotlin and we use Bazel to build it.
I managed to build the application using the following snapcraft.yaml. However, after building it and install, I cannot run it. It told me that there is no java available.
I did include openjdk-11-jdk in stage-packages, but it does not work. Even if I use snap run --shell preses.perses
and type java, it still shows there is no java
.
I have struggled in this for a few days. Any help is appreciated.
# export SNAPCRAFT_BUILD_ENVIRONMENT_CPU=16
# export SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=64G
# multipass launch --name snapcraft-perses --memory 64G --cpus 16 --disk 64G
name: perses # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '2.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: language-agnostic program reducer. # 79 char long summary
description: |
Perses is a language-agnostic program reducer to minimize a program with respect to a set of constraints. It takes as input a program to reduce, and a test script which specifies the constraints. It outputs a minimized program which still satisfies the constraints specified in the test script. Compared to Delta Debugging and Hierarchical Delta Debugging, Perses leverages the syntax information in the Antlr grammar, and prunes the search space by avoiding generating syntactically invalid programs.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
# variables:
# BAZELISK_VERSION: "1.25.0" # Update to the latest version as needed
parts:
# start:
# source: .
# plugin: dump
# stage-packages:
# - openjdk-11-jre
# stage:
# - start.sh
bazelisk:
plugin: dump
source: https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-amd64.deb
perses:
after: [bazelisk]
# See 'snapcraft plugins'
plugin: nil
source: https://github.com/uw-pluverse/perses.git
build-packages:
- openjdk-11-jdk-headless
- ca-certificates
- ca-certificates-java
- creduce
- gcc
- clang
- clang-format
- python3
- ruby
- rustc
- rustfmt
- scala
override-pull: |
snapcraftctl pull
override-build: |
bazelisk build //src/org/perses:perses_deploy.jar
cp bazel-bin/src/org/perses/perses_deploy.jar $SNAPCRAFT_PART_INSTALL/perses_deploy.jar
echo '#!/bin/bash' > start.sh
echo 'if command -v java > /dev/null 2>&1; then' >> start.sh
echo ' # Execute the Java application' >> start.sh
echo ' exec java -jar perses_deploy' >> start.sh
echo 'else' >> start.sh
echo ' echo "Java is not installed. Please install Java to run this application."' >> start.sh
echo ' exit 1' >> start.sh
echo 'fi' >> start.sh
chmod +x start.sh
cp start.sh $SNAPCRAFT_PART_INSTALL/start.sh
snapcraftctl build
stage:
- perses_deploy.jar
- start.sh
stage-packages:
- openjdk-11-jre-headless
override-prime: |
snapcraftctl prime
rm -vf usr/lib/jvm/java-11-openjdk-*/lib/security/blacklisted.certs
apps:
perses:
command: start.sh
environment:
JAVA_HOME: "$SNAP/usr/lib/jvm/java-11-openjdk-amd64"
PATH: "$JAVA_HOME/bin:$PATH"
plugs:
- home
BTW, I tried ``java -jar perses_deploy.jar’’ and it does not work. That’s the reason I include a start.sh for debugging.