stirling-pdf: convert to gradle setup hook

This commit is contained in:
chayleaf 2024-06-27 03:42:12 +07:00
parent 2029c93adf
commit 183e1f5fc3
No known key found for this signature in database
GPG Key ID: 78171AD46227E68E
5 changed files with 1838 additions and 138 deletions

1823
pkgs/by-name/st/stirling-pdf/deps.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
diff --git a/build.gradle b/build.gradle
index c206e2f..b1fda33 100644
--- a/build.gradle
+++ b/build.gradle
@@ -69,19 +69,7 @@ launch4j {
messagesInstanceAlreadyExists="Stirling-PDF is already running."
}
-spotless {
- java {
- target project.fileTree('src/main/java')
- googleJavaFormat('1.19.1').aosp().reorderImports(false)
-
- importOrder('java', 'javax', 'org', 'com', 'net', 'io')
- toggleOffOn()
- trimTrailingWhitespace()
- indentWithSpaces()
- endWithNewline()
- }
-}
dependencies {
//security updates
@@ -163,9 +151,6 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.28'
}
-tasks.withType(JavaCompile) {
- dependsOn 'spotlessApply'
-}
compileJava {
options.compilerArgs << '-parameters'
}

View File

@ -1,16 +0,0 @@
diff --git a/build.gradle b/build.gradle
index 7025b2b..d063da3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -20,6 +20,11 @@ repositories {
}
+tasks.withType(AbstractArchiveTask) {
+ preserveFileTimestamps = false
+ reproducibleFileOrder = true
+}
+
licenseReport {
renderers = [new JsonReportRenderer()]

View File

@ -2,13 +2,14 @@
lib,
stdenv,
fetchFromGitHub,
substituteAll,
gradle_7,
perl,
makeWrapper,
jre,
}:
let
gradle = gradle_7;
in
stdenv.mkDerivation (finalAttrs: {
pname = "stirling-pdf";
version = "0.25.1";
@ -21,77 +22,28 @@ stdenv.mkDerivation (finalAttrs: {
};
patches = [
# disable spotless because it tries to fetch files not in the FOD
# and also because it slows down the build process
./disable-spotless.patch
# remove timestamp from the header of a generated .properties file
./remove-props-file-timestamp.patch
# use gradle's built-in method of zeroing out timestamps,
# because stripJavaArchivesHook can't patch signed JAR files
./fix-jar-timestamp.patch
# set the FOD as the only repository gradle can resolve from
(substituteAll {
src = ./use-fod-maven-repo.patch;
inherit (finalAttrs) deps;
})
];
# fake build to pre-download deps into fixed-output derivation
deps = stdenv.mkDerivation {
name = "${finalAttrs.pname}-${finalAttrs.version}-deps";
inherit (finalAttrs) src;
patches = [ ./disable-spotless.patch ];
nativeBuildInputs = [
gradle_7
perl
];
buildPhase = ''
runHook preBuild
export GRADLE_USER_HOME=$(mktemp -d)
gradle --no-daemon --console=plain build
runHook postBuild
'';
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
installPhase = ''
runHook preInstall
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
# Mimic existence of okio-3.6.0.jar, originally known as okio-jvm-3.6.0 (and renamed).
# Gradle doesn't detect such renames and only fetches the latter.
# Whenever this package gets updated, please check if this hack is obsolete.
ln -s $out/com/squareup/okio/okio-jvm/3.6.0/okio-jvm-3.6.0.jar $out/com/squareup/okio/okio/3.6.0/okio-3.6.0.jar
runHook postInstall
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-JaTL6/DyBAqXkIQOkbi8MYoIZrhWqc3MpJ7DDB4h+ok=";
mitmCache = gradle.fetchDeps {
inherit (finalAttrs) pname;
data = ./deps.json;
};
__darwinAllowLocalNetworking = true;
# disable spotless because it tries to fetch files not in deps.json
# and also because it slows down the build process
gradleFlags = [ "-x" "spotlessApply" ];
doCheck = true;
nativeBuildInputs = [
gradle_7
gradle
makeWrapper
];
buildPhase = ''
runHook preBuild
export GRADLE_USER_HOME=$(mktemp -d)
gradle --offline --no-daemon --console=plain build
runHook postBuild
'';
installPhase = ''
runHook preInstall

View File

@ -1,25 +0,0 @@
diff --git a/build.gradle b/build.gradle
index c206e2f..cdaddf7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,7 +16,7 @@ version = '0.22.3'
sourceCompatibility = '17'
repositories {
- mavenCentral()
+ maven { url '@deps@' }
}
diff --git a/settings.gradle b/settings.gradle
index f813993..2c87f3c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1,7 @@
+pluginManagement {
+ repositories {
+ maven { url '@deps@' }
+ }
+}
+
rootProject.name = 'Stirling-PDF'