From 226eca1fb92626f6503badc05dd883f39ec1360a Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Fri, 11 Feb 2022 15:22:57 -0700 Subject: [PATCH] add piston nix pkg for groovy --- packages/groovy/3.0.7/build.sh | 14 -------- packages/groovy/3.0.7/compile | 17 --------- packages/groovy/3.0.7/environment | 10 ------ packages/groovy/3.0.7/metadata.json | 5 --- packages/groovy/3.0.7/run | 5 --- packages/groovy/3.0.7/test.groovy | 1 - runtimes/default.nix | 1 + runtimes/groovy.nix | 55 +++++++++++++++++++++++++++++ 8 files changed, 56 insertions(+), 52 deletions(-) delete mode 100755 packages/groovy/3.0.7/build.sh delete mode 100644 packages/groovy/3.0.7/compile delete mode 100644 packages/groovy/3.0.7/environment delete mode 100644 packages/groovy/3.0.7/metadata.json delete mode 100644 packages/groovy/3.0.7/run delete mode 100644 packages/groovy/3.0.7/test.groovy create mode 100644 runtimes/groovy.nix diff --git a/packages/groovy/3.0.7/build.sh b/packages/groovy/3.0.7/build.sh deleted file mode 100755 index fb6321d..0000000 --- a/packages/groovy/3.0.7/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Groovy depends on JDK8+ -mkdir -p java -cd java -curl "https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-x64_bin.tar.gz" -o java.tar.gz -tar xzf java.tar.gz --strip-components=1 -rm java.tar.gz -cd .. - -# Download Groovy binaries -curl -L "https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-3.0.7.zip" -o groovy.zip -unzip -q groovy.zip -rm groovy.zip diff --git a/packages/groovy/3.0.7/compile b/packages/groovy/3.0.7/compile deleted file mode 100644 index c501c9e..0000000 --- a/packages/groovy/3.0.7/compile +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Compile groovy scripts into a separate "classes" directory -# NOTE: - Main file MUST be a groovy script -# - not supporting object class entry points as of now -groovyc -d classes "$@" - -# Create the Manifest and include groovy jars: -# NOTE: - main class will be the first file ('.' becomes '_' and without the extension) -# - groovy lib jars MUST be in the class path in order to work properly -echo "Main-Class: $(sed 's/\./\_/g'<<<${1%.*}) -Class-Path: $(echo $GROOVY_HOME/lib/*.jar | sed 's/\s/\n /g') - -" > manifest.txt - -# Create the jar from the manifest and classes -jar cfm out.jar manifest.txt -C classes . diff --git a/packages/groovy/3.0.7/environment b/packages/groovy/3.0.7/environment deleted file mode 100644 index 1817781..0000000 --- a/packages/groovy/3.0.7/environment +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Groovy requires JAVA_HOME to be set -export JAVA_HOME=$PWD/java - -# GROOVY_HOME needed to get the groovy libs -export GROOVY_HOME=$PWD/groovy-3.0.7 - -# Add java and groovy binaries to the path -export PATH=$PWD/java/bin:$PWD/groovy-3.0.7/bin:$PATH diff --git a/packages/groovy/3.0.7/metadata.json b/packages/groovy/3.0.7/metadata.json deleted file mode 100644 index 34ab93d..0000000 --- a/packages/groovy/3.0.7/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "groovy", - "version": "3.0.7", - "aliases": ["groovy", "gvy"] -} diff --git a/packages/groovy/3.0.7/run b/packages/groovy/3.0.7/run deleted file mode 100644 index 813d3bc..0000000 --- a/packages/groovy/3.0.7/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Run the jar created during compile -shift -java -jar out.jar "$@" diff --git a/packages/groovy/3.0.7/test.groovy b/packages/groovy/3.0.7/test.groovy deleted file mode 100644 index e4eb9d8..0000000 --- a/packages/groovy/3.0.7/test.groovy +++ /dev/null @@ -1 +0,0 @@ -println 'OK' diff --git a/runtimes/default.nix b/runtimes/default.nix index b6f99ae..cad9dd2 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -43,4 +43,5 @@ args: { "openjdk-java" = import ./openjdk-java.nix args; "iverilog" = import ./iverilog.nix args; "ghc-haskell" = import ./ghc-haskell.nix args; + "groovy" = import ./groovy.nix args; } diff --git a/runtimes/groovy.nix b/runtimes/groovy.nix new file mode 100644 index 0000000..b1d6fc6 --- /dev/null +++ b/runtimes/groovy.nix @@ -0,0 +1,55 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.groovy; + jre = pkgs.jre; + awk = pkgs.gawk; + sed = pkgs.gnused; + grep = pkgs.gnugrep; +in piston.mkRuntime { + language = "groovy"; + version = pkg.version; + + aliases = [ + "gvy" + ]; + + compile = '' + # Groovyc has some dependencies on GNU grep, sed, and awk in their startup script + export PATH="$PATH:${awk}/bin:${sed}/bin:${grep}/bin" + + # Compile groovy scripts into a separate "classes" directory + # NOTE: - Main file MUST be a groovy script + # - not supporting object class entry points as of now + ${pkg}/bin/groovyc -d classes "$@" + + # Create the Manifest and include groovy jars: + # NOTE: - main class will be the first file ('.' becomes '_' and without the extension) + # - groovy lib jars MUST be in the class path in order to work properly + echo "Main-Class: $(sed 's/\./\_/g'<<<''${1%.*}) + Class-Path: $(echo ${pkg}/lib/*.jar | sed 's/\s/\n /g') + + " > manifest.txt + + # Create the jar from the manifest and classes + ${jre}/bin/jar cfm out.jar manifest.txt -C classes . + ''; + + run = '' + shift + ${jre}/bin/java -jar out.jar "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.groovy" = '' + println 'OK' + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.groovy"; + }) + ]; +} \ No newline at end of file