about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2024-04-03 13:24:15 +0200
committerGitHub <noreply@github.com>2024-04-03 13:24:15 +0200
commitc0d2398ba678ac5cb94f629c9757e5b9ecb84338 (patch)
treea889f81d77e3609034e7da34d80451e91770ab8a
parent912d84a6d84aaab59bf5e4da4050abea6a7be00b (diff)
parentfda4e1da5268e1d37e42a1117676220e7307c9af (diff)
Merge pull request #300346 from wegank/aspectj-refactor
aspectj: refactor
-rwxr-xr-xpkgs/development/compilers/aspectj/builder.sh28
-rw-r--r--pkgs/development/compilers/aspectj/default.nix55
2 files changed, 43 insertions, 40 deletions
diff --git a/pkgs/development/compilers/aspectj/builder.sh b/pkgs/development/compilers/aspectj/builder.sh
deleted file mode 100755
index 31ec97942e524..0000000000000
--- a/pkgs/development/compilers/aspectj/builder.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
-source $stdenv/setup
-
-export JAVA_HOME=$jre
-
-cat >> props <<EOF
-output.dir=$out
-context.javaPath=$jre
-EOF
-
-mkdir -p $out
-$jre/bin/java -jar $src -text props
-
-echo "Removing files at top level"
-for file in $out/*
-do
-  if test -f $file ; then
-    rm $file
-  fi
-done
-
-cat >> $out/bin/aj-runtime-env <<EOF
-#! $SHELL
-
-export CLASSPATH=$CLASSPATH:.:$out/lib/aspectjrt.jar
-EOF
-
-chmod u+x $out/bin/aj-runtime-env
diff --git a/pkgs/development/compilers/aspectj/default.nix b/pkgs/development/compilers/aspectj/default.nix
index 5e34560f46cf7..50c54b66b73c4 100644
--- a/pkgs/development/compilers/aspectj/default.nix
+++ b/pkgs/development/compilers/aspectj/default.nix
@@ -1,25 +1,56 @@
-{lib, stdenv, fetchurl, jre}:
+{
+  lib,
+  stdenvNoCC,
+  fetchurl,
+  jre,
+}:
 
-stdenv.mkDerivation rec {
-  pname = "aspectj";
+let
   version = "1.9.21.2";
-  builder = ./builder.sh;
+  versionSnakeCase = builtins.replaceStrings [ "." ] [ "_" ] version;
+in
+stdenvNoCC.mkDerivation {
+  pname = "aspectj";
+  inherit version;
 
-  src = let
-    versionSnakeCase = builtins.replaceStrings ["."] ["_"] version;
-  in fetchurl {
+  __structuredAttrs = true;
+
+  src = fetchurl {
     url = "https://github.com/eclipse/org.aspectj/releases/download/V${versionSnakeCase}/aspectj-${version}.jar";
-    sha256 = "sha256-wqQtyopS03zX+GJme5YZwWiACqO4GAYFr3XAjzqSFnQ=";
+    hash = "sha256-wqQtyopS03zX+GJme5YZwWiACqO4GAYFr3XAjzqSFnQ=";
   };
 
-  inherit jre;
-  buildInputs = [jre];
+  dontUnpack = true;
+
+  nativeBuildInputs = [ jre ];
+
+  installPhase = ''
+    runHook preInstall
+
+    cat >> props <<EOF
+    output.dir=$out
+    context.javaPath=${jre}
+    EOF
+
+    mkdir -p $out
+    java -jar $src -text props
+
+    cat >> $out/bin/aj-runtime-env <<EOF
+    #! ${stdenvNoCC.shell}
+
+    export CLASSPATH=$CLASSPATH:.:$out/lib/aspectjrt.jar
+    EOF
+
+    chmod u+x $out/bin/aj-runtime-env
+
+    runHook postInstall
+  '';
 
   meta = {
     homepage = "https://www.eclipse.org/aspectj/";
     description = "A seamless aspect-oriented extension to the Java programming language";
-    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
-    platforms = lib.platforms.unix;
     license = lib.licenses.epl10;
+    platforms = lib.platforms.unix;
+    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
   };
 }