File Mindustry.spec of Package Mindustry

#
# spec file for package Mindustry
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2020-2021, Martin Hauke <mardnh@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define realver 126.2
%define java_version 14
Name:           Mindustry
Version:        6.0.126.2
Release:        0
Summary:        A sandbox tower defense game
License:        GPL-3.0-only
Group:          Amusements/Games/Strategy/Other
URL:            https://mindustrygame.github.io/
#Source0:        https://github.com/Anuken/Mindustry/releases/download/v%{realver}/%{name}.jar#/%{name}-%{version}.jar
Source0:        https://github.com/Anuken/Mindustry/archive/refs/tags/v%{realver}.tar.gz#/%{name}-%{version}.tar.gz
Source2:        https://raw.githubusercontent.com/Anuken/Mindustry/master/core/assets/icons/icon_64.png
Source3:        https://raw.githubusercontent.com/Anuken/Mindustry/master/LICENSE
Source99:       gradle.tar
BuildRequires:  ca-certificates-mozilla
BuildRequires:  hicolor-icon-theme
BuildRequires:  unzip
BuildRequires:  update-desktop-files
BuildRequires:  java-devel = 15
%if 0%{?suse_version} > 1500 
BuildRequires:  javapackages-filesystem
%endif
Requires:       java = %{java_version}
Requires:       javapackages-tools
BuildArch:      noarch

%description
An open-ended tower-defense game with a focus on resource management.

%prep
%setup -q -n %name-%realver
tar xf %{SOURCE99}
cp -afl .gradle ~/
cp -v %{SOURCE3} .

%build
./gradlew desktop:dist

%install
install -D -m0755 desktop/build/libs/Mindustry.jar %{buildroot}%{_javadir}/Mindustry/%{name}.jar
install -D -m0644 %{SOURCE2} %{buildroot}/%{_datadir}/icons/hicolor/64x64/apps/%{name}.png

# Create Startscript
cat > Mindustry.sh << EOF
#!/bin/bash
# use right java version
JAVA_HOME=%{_sysconfdir}/alternatives/jre_%{java_version}
# set jar-entry-class
MAIN_CLASS="mindustry.desktop.DesktopLauncher"
# source the jpackage helpers and set environment
VERBOSE=1
. %{_datadir}/java-utils/java-functions
set_javacmd
check_java_env
set_jvm_dirs
# If the memory run short it can help to use set_options
# Xms set the initial and minimum Java heap size, Xmx set the maximum Java heap size
# default: Xms (25% of the amount of free physical memory in the system, up to 16 MB and at least 8 MB)
# default: Xmx (32bit: 50% of available physical memory up to 1 GB, 64bit: 50% of available physical memory up to 32 GB)
set_options "-Xms256M" "-Xmx1G"
CLASSPATH=\`build-classpath Mindustry\`
run "\$@"
EOF

install -D -m0755 Mindustry.sh %{buildroot}/%{_bindir}/%{name}
%suse_update_desktop_file -c %{name} %{name} "A sandbox tower defense game" %{name} %{name} Game StrategyGame

%files
%license LICENSE
%{_bindir}/Mindustry
%{_javadir}/Mindustry
%{_datadir}/icons/hicolor/64x64/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop

%changelog
openSUSE Build Service is sponsored by