##
##  groovy.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         groovy
Summary:      Groovy Java Scripting Language
URL:          https://groovy.apache.org/
Vendor:       Codehaus
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Language
License:      BSD-style
Version:      5.0.1
Release:      20250911

#   list of sources
Source0:      https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-%{version}.zip

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, infozip
PreReq:       OpenPKG, openpkg >= 20160101, java, JAVA-JDK

%description
    Groovy is an agile and dynamic scripting language for the Java
    Virtual Machine (JVM). It builds upon the strengths of Java but has
    additional power features inspired by languages like Python, Ruby
    and Smalltalk. It can be used as a stand-alone or embedded scripting
    language for Java and provides full access to all existing Java
    class libraries.

%track
    prog groovy = {
        version   = %{version}
        url       = https://groovy.apache.org/download.html
        regex     = apache-groovy-binary-(\d+\.\d+(\.\d+)*)\.zip
    }

%prep
    %setup -q -T -c
    ( cd ..
    %{l_prefix}/bin/unzip -q -x %{SOURCE0}
    ) || exit $?

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/groovy
    for program in grok groovy groovyConsole groovyc groovysh java2groovy; do
        ( echo "#!/bin/sh"
          echo "eval \`JAVA_PLATFORM=\"sun-jdk\" %{l_prefix}/bin/java-toolkit -e\`"
          echo "GROOVY_HOME=\"%{l_prefix}/libexec/groovy\"; export GROOVY_HOME"
          echo "exec %{l_prefix}/libexec/groovy/bin/$program \"\$@\""
        ) >$program.sh
        %{l_shtool} install -c -m 755 \
            $program.sh $RPM_BUILD_ROOT%{l_prefix}/bin/$program
    done
    rm -f bin/*.bat bin/*cygwin*
    cp -rp bin conf lib \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/groovy/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

