---
-
  name: "Block to Allow Loading of Variables without running task"
  when: run_tasks
  block:
    -
      name: "Creating Domino servlet directories"
      ansible.builtin.file:
        mode: '0644'
        path: "{{ item }}"
        state: directory
        owner: "{{ domino_user }}"
        group: "{{ domino_group }}"
      with_items:
        - "{{ domino_home_dir }}/domino/servlet"
    
    -
      name: "Creating Example Servlet Directory in {{ service_home_dir }}"
      ansible.builtin.file:
        mode: '0755'
        path: "{{ item }}"
        state: directory
        owner: "{{ service_user }}"
        group: "{{ service_group }}"
      with_items:
        - "{{ service_home_dir }}/ExampleServlet"
    
    -
      name: "Placing templated ExampleServlet.java into {{ service_home_dir }}"
      become: true
      ansible.builtin.template:
        dest: "{{ service_home_dir }}/ExampleServlet/ExampleServlet.java"
        owner: "{{ service_user }}"
        group: "{{ service_group }}"
        mode: "a+x"
        src: ExampleServlet.java.j2
    
    -
      name: "Placing templated build-servlet-example.bsh into {{ service_home_dir }}"
      become: true
      ansible.builtin.template:
        dest: "{{ service_home_dir }}/ExampleServlet/build-servlet-example.bsh"
        owner: "{{ service_user }}"
        group: "{{ service_group }}"
        mode: "a+x"
        src: build-servlet-example.bsh.j2
    
    -
      name: "Creating ExampleServlet Class"
      ansible.builtin.shell: >
        javac -verbose -source 1.8 -target 1.8
        -classpath {{ domino_install_basedir }}/notes/latest/linux/jvm/lib/ext/:{{ domino_install_dir }}/ndext/jsdk.jar
        ExampleServlet.java
      become: true
      become_user: "{{ service_user }}"
      when: build_example
      args:
        chdir: "{{ service_home_dir }}/ExampleServlet"
        executable: /bin/bash
        creates: "{{ service_home_dir }}/ExampleServlet/ExampleServlet.class"
    
    -
      name: "Copying Example Servlet Class in folder domino/servlet at {{ domino_home_dir }}"
      when: build_example
      ansible.builtin.copy:
        mode: '0644'
        src: "{{ item }}"
        dest: "{{ domino_home_dir }}/domino/servlet"
        remote_src: true
        owner: "{{ domino_user }}"
        group: "{{ domino_group }}"
      with_items:
        - "{{ service_home_dir }}/ExampleServlet/ExampleServlet.class"
