summaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/openjdk/tests/hello.nix
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2021-05-24 09:55:24 -0500
committerRobin Gloster <mail@glob.in>2021-05-24 09:55:24 -0500
commit4bc5fbef9d159e143fb7e2c3231932e6e76f667c (patch)
treee2198f5c552e0667d838b8ec764ddb3a4d8f6dec /pkgs/development/compilers/openjdk/tests/hello.nix
parentjq: fix build with structured-attrs on darwin (diff)
parentMerge pull request #123802 from superherointj/package-virtmanager-bugfix (diff)
downloadnixpkgs-origin/structured-attrs.tar.gz
Merge remote-tracking branch 'upstream/master' into structured-attrsorigin/structured-attrs
Diffstat (limited to 'pkgs/development/compilers/openjdk/tests/hello.nix')
-rw-r--r--pkgs/development/compilers/openjdk/tests/hello.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/development/compilers/openjdk/tests/hello.nix b/pkgs/development/compilers/openjdk/tests/hello.nix
new file mode 100644
index 000000000000..bc5be4a9e9a9
--- /dev/null
+++ b/pkgs/development/compilers/openjdk/tests/hello.nix
@@ -0,0 +1,42 @@
+{ jdk
+, jre
+, pkgs
+}:
+
+/* 'Hello world' Java application derivation for use in tests */
+let
+ source = pkgs.writeTextDir "src/Hello.java" ''
+ class Hello {
+ public static void main(String[] args) {
+ System.out.println("Hello, world!");
+ }
+ }
+ '';
+in
+ pkgs.stdenv.mkDerivation {
+ pname = "hello";
+ version = "1.0.0";
+
+ src = source;
+
+ buildPhase = ''
+ runHook preBuildPhase
+ ${jdk}/bin/javac src/Hello.java
+ runHook postBuildPhase
+ '';
+ installPhase = ''
+ runHook preInstallPhase
+
+ mkdir -p $out/lib
+ cp src/Hello.class $out/lib
+
+ mkdir -p $out/bin
+ cat >$out/bin/hello <<EOF;
+ #!/usr/bin/env sh
+ ${jre}/bin/java -cp $out/lib Hello
+ EOF
+ chmod a+x $out/bin/hello
+
+ runHook postInstallPhase
+ '';
+ }