
stages:
  - containers
  - builds
  - pages
  - sanity_checks

.native_git_build_job:
  extends:
    - .gitlab_native_build_job
  script:
    - export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
    - export SCRATCH_DIR="/tmp/scratch"
    - export VROOT="$SCRATCH_DIR/vroot"
    - export LIBDIR="$VROOT/lib"
    - export LD_LIBRARY_PATH="$LIBDIR"
    - export PATH="$VROOT/bin:$PATH"
    - export PKG_CONFIG_PATH="$LIBDIR/pkgconfig"
    - pushd "$PWD"
    - mkdir -p "$SCRATCH_DIR"
    - cd "$SCRATCH_DIR"
    - git clone --depth 1 https://gitlab.com/libvirt/libvirt.git
    - cd libvirt
    - meson build -Ddriver_libvirtd=disabled "--prefix=$VROOT" "--libdir=$LIBDIR"
    - ninja -C build install
    - popd
    - ant build jar docs
    - if test "$TESTS" != "skip" ; then ant test ; fi
    - ant src
    - if test -x /usr/bin/rpmbuild ; then ant spec && rpmbuild -ba --define "_sourcedir `pwd`/target" target/libvirt-java.spec ; fi

.native_build_job:
  extends:
    - .gitlab_native_build_job
  script:
    - ant build jar docs
    - if test "$TESTS" != "skip" ; then ant test ; fi
    - ant src
    - if test -x /usr/bin/rpmbuild ; then ant spec && rpmbuild -ba --define "_sourcedir `pwd`/target" target/libvirt-java.spec ; fi

website_job:
  extends:
    - .gitlab_native_build_job
  needs:
    - job: x86_64-ubuntu-2204-container
      optional: true
  script:
    - ant docs
    - cp -rf site website
    - mv target/javadoc website/
  artifacts:
    paths:
      - website
  variables:
    NAME: ubuntu-2204

pages:
  stage: pages
  dependencies:
    - website_job
  script:
    - mv website public
  artifacts:
    paths:
      - public
  rules:
    - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: on_success
    - when: never

include: '/ci/gitlab.yml'
