Default Java to 16 for MC 1.17 using AdoptOpenJDK

This commit is contained in:
Kris Lamoureux 2021-07-16 18:44:28 -04:00
parent 294b447de5
commit 4dbc6e3a72
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
4 changed files with 17 additions and 28 deletions

View File

@ -10,8 +10,8 @@ manage_network: false
minecraft_onboot: vanilla minecraft_onboot: vanilla
minecraft_onboot_run: true minecraft_onboot_run: true
minecraft: minecraft:
- name: vanilla # 1.16.5 (https://mcversions.net/download/1.16.5) - name: vanilla # 1.17.1 (https://mcversions.net/download/1.17.1)
sha1: 1b557e7b033b583cd9f66746b7a9ab1ec1673ced sha1: a16d67e5807f57fc4e550299cf20226194497dc2
java: java:
Xms: 1G Xms: 1G
Xmx: 1G Xmx: 1G

View File

@ -1,6 +1,7 @@
minecraft_eula: false minecraft_eula: false
minecraft_home: "/opt/minecraft" minecraft_home: "/opt/minecraft"
minecraft_java: 11 minecraft_java: 16
minecraft_java_pkg: "adoptopenjdk-{{ minecraft_java }}-hotspot"
minecraft_modpack_url: "https://api.modpacks.ch/public/modpack/{{ item.modpack }}/server/linux" minecraft_modpack_url: "https://api.modpacks.ch/public/modpack/{{ item.modpack }}/server/linux"
minecraft_onboot_run: false minecraft_onboot_run: false
minecraft_url: "https://launcher.mojang.com/v1/objects/{{ item.sha1 }}/server.jar" minecraft_url: "https://launcher.mojang.com/v1/objects/{{ item.sha1 }}/server.jar"

View File

@ -2,46 +2,35 @@
apt: apt:
name: gpg name: gpg
state: present state: present
when: item.java.version is defined and item.java.version == 8
loop: "{{ minecraft }}"
- name: Add AdoptOpenJDK's signing key - name: Add AdoptOpenJDK's signing key
apt_key: apt_key:
id: 8ED17AF5D7E675EB3EE3BCE98AC3B29174885C03 id: 8ED17AF5D7E675EB3EE3BCE98AC3B29174885C03
url: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public url: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
when: item.java.version is defined and item.java.version == 8
loop: "{{ minecraft }}"
- name: Install AdoptOpenJDK repository - name: Install AdoptOpenJDK repository
apt_repository: apt_repository:
repo: deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main repo: deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main
mode: 0644 mode: 0644
state: present state: present
when: item.java.version is defined and item.java.version == 8
loop: "{{ minecraft }}"
- name: Install Java 8 - name: Install Java
apt: apt:
name: adoptopenjdk-8-hotspot name: "adoptopenjdk-{{ item.java.version }}-hotspot"
state: present state: present
when: item.java.version is defined and item.java.version == 8 when: item.java.version is defined
loop: "{{ minecraft }}" loop: "{{ minecraft }}"
- name: Install Java 11 - name: "Install default Java, version {{ minecraft_java }}"
apt: apt:
name: openjdk-11-jre name: "{{ minecraft_java_pkg }}"
state: present state: present
when: item.java.version is not defined or item.java.version == 11 when: item.java.version is not defined
loop: "{{ minecraft }}" loop: "{{ minecraft }}"
register: minecraft_java_default
- name: Activate Java 8 - name: "Activate default Java, version {{ minecraft_java }}"
alternatives: alternatives:
name: java name: java
path: /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/jre/bin/java path: "/usr/lib/jvm/{{ minecraft_java_pkg }}-amd64/bin/java"
when: minecraft_java == 8 when: minecraft_java_default.changed
- name: Activate Java 11
alternatives:
name: java
path: /usr/lib/jvm/java-11-openjdk-amd64/bin/java
when: minecraft_java == 11

View File

@ -1,8 +1,7 @@
{% if item.java.version is defined and item.java.version == 8 %} {% if item.java.version is defined %}
JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/jre JAVA_HOME=/usr/lib/jvm/adoptopenjdk-{{ item.java.version }}-hotspot-amd64
{% else %} {% else %}
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JAVA_HOME=/usr/lib/jvm/{{ minecraft_java_pkg }}-amd64
{% endif %} {% endif %}
JAVA_XMS={{ item.java.Xms }} JAVA_XMS={{ item.java.Xms }}
JAVA_XMX={{ item.java.Xmx }} JAVA_XMX={{ item.java.Xmx }}