Package JAVMovieScraper

This commit is contained in:
Daniel Løvbrøtte Olsen 2019-11-02 03:14:47 +01:00
parent 68ae3c2cbb
commit 6959b4d93b
6 changed files with 3859 additions and 1 deletions

View File

@ -6,7 +6,7 @@
# commands such as:
# nix-build -A mypackage
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixos-unstable> {} }:
{
# The `lib`, `modules`, and `overlay` names are special
@ -19,6 +19,7 @@
# ...
rank_photos = pkgs.callPackage ./pkgs/rank_photos { };
JAVMovieScraper = pkgs.callPackage ./pkgs/JAVMovieScraper { };
}

View File

@ -0,0 +1,35 @@
{ pkgs, fetchFromGitHub, gradleGen, openjdk11}:
with pkgs;
let
buildGradle = callPackage ./gradle-env.nix { gradleGen = gradleGen.override { java = openjdk11; }; };
in
buildGradle {
envSpec = ./gradle-env.json;
src = fetchFromGitHub {
owner = "DoctorD1501";
repo = "JAVMovieScraper";
rev = "fcd695b2981d36aea01c9153ee2ef1c27cd42c78";
sha256 = "0qwdzyfmscjj75jyh9mnk1rlmy12fnnsqbhvp9xdsnfhwy78x6xm";
};
patches = [ ./disable_spotless.patch ./respectXDG.patch ];
gradleFlags = [ "DistTar" ];
buildInputs = [ openjdk11 ];
installPhase = ''
mkdir -p $out
tar xvf ./build/distributions/source--1.tar
cp -r source--1/lib source--1/bin $out
rm $out/bin/source.bat
cat $out/bin/source | sed 's~$JAVA_HOME~${openjdk11}~' > $out/bin/JAVMovieScraper
chmod +x $out/bin/JAVMovieScraper
rm $out/bin/source
'';
}

View File

@ -0,0 +1,21 @@
diff --git a/build.gradle b/build.gradle
index 89d9f44..54ca85e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -79,11 +79,11 @@ shadowJar {
baseName = project.name
}
-spotless {
- java {
- eclipse().configFile 'config/format/eclipseformat.xml'
- }
-}
+/*spotless {
+ java {
+ eclipse().configFile 'config/format/eclipseformat.xml'
+ }
+t}*/
jacocoTestReport {
reports {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,130 @@
# This file is generated by gradle2nix.
#
# Example usage (e.g. in default.nix):
#
# with (import <nixpkgs> {});
# let
# buildGradle = callPackage ./gradleEnv.nix {};
# in
# buildGradle {
# envSpec = ./gradle-env.json;
#
# src = ./.;
#
# gradleFlags = [ "installDist" ];
#
# installPhase = ''
# mkdir -p $out
# cp -r app/build/install/myproject $out
# '';
# }
{ stdenv, lib, buildEnv, fetchurl, gradleGen, writeText }:
{ envSpec
, pname ? null
, version ? null
, enableParallelBuilding ? true
, gradleFlags ? [ "build" ]
, gradlePackage ? null
, ... } @ args:
let
mkDep = depSpec: stdenv.mkDerivation {
inherit (depSpec) name;
src = fetchurl {
inherit (depSpec) urls sha256;
};
phases = "installPhase";
installPhase = ''
mkdir -p $out/${depSpec.path}
ln -s $src $out/${depSpec.path}/${depSpec.filename}
'';
};
mkRepo = project: type: deps: buildEnv {
name = "${project}-gradle-${type}-env";
paths = map mkDep deps;
};
mkInitScript = projectSpec:
let
repos = builtins.mapAttrs (mkRepo projectSpec.name) projectSpec.dependencies;
in
writeText "init.gradle" ''
gradle.settingsEvaluated {
it.pluginManagement.repositories {
clear()
maven { url = uri("${repos.plugin}") }
}
}
gradle.projectsLoaded {
allprojects {
buildscript {
repositories {
clear()
maven { url = uri("${repos.buildscript}") }
}
}
repositories {
clear()
maven { url = uri("${repos.project}") }
}
}
}
'';
mkGradle = gradleSpec:
gradleGen.gradleGen {
inherit (gradleSpec) nativeVersion;
name = "gradle-${gradleSpec.version}-${gradleSpec.type}";
src = fetchurl {
inherit (gradleSpec) url sha256;
};
};
mkProjectEnv = projectSpec: {
inherit (projectSpec) name version;
initScript = mkInitScript projectSpec;
gradle = args.gradlePackage or mkGradle projectSpec.gradle;
};
gradleEnv = builtins.mapAttrs
(_: p: mkProjectEnv p)
(builtins.fromJSON (builtins.readFile envSpec));
projectEnv = gradleEnv."";
pname = args.pname or projectEnv.name;
version = args.version or projectEnv.version;
in stdenv.mkDerivation (args // {
inherit pname version;
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ projectEnv.gradle ];
buildPhase = args.buildPhase or ''
runHook preBuild
(
set -x
env \
"GRADLE_USER_HOME=$(mktemp -d)" \
gradle --offline --no-daemon --no-build-cache \
--info --full-stacktrace --warning-mode=all \
${lib.optionalString enableParallelBuilding "--parallel"} \
--init-script ${projectEnv.initScript} \
${builtins.concatStringsSep " " gradleFlags}
)
runHook postBuild
'';
dontStrip = true;
})

View File

@ -0,0 +1,65 @@
diff --git a/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java b/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java
index ac9cf4e..ce57ee3 100644
--- a/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java
+++ b/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java
@@ -29,7 +29,8 @@ import moviescraper.doctord.controller.siteparsingprofile.specific.TheMovieDatab
public class AllAmalgamationOrderingPreferences {
Map<ScraperGroupName, ScraperGroupAmalgamationPreference> allAmalgamationOrderingPreferences;
- private static final String settingsFileName = "AmalgamationSettings.json";
+ private final static String folderNameOfSettings = (System.getenv("XDG_CONFIG_HOME") != null ? System.getenv("XDG_CONFIG_HOME") : System.getenv("HOME")) + "/.config/JAVMovieSraper";
+ private static final String settingsFileName = folderNameOfSettings + "/AmalgamationSettings.json";
public AllAmalgamationOrderingPreferences() {
allAmalgamationOrderingPreferences = new Hashtable<>();
@@ -89,7 +90,9 @@ public class AllAmalgamationOrderingPreferences {
}
public void saveToPreferencesFile() {
- try (FileOutputStream outputStream = new FileOutputStream(settingsFileName); JsonWriter jw = new JsonWriter(outputStream);) {
+ File f = new File(settingsFileName);
+ f.getParentFile().mkdirs();
+ try (FileOutputStream outputStream = new FileOutputStream(f); JsonWriter jw = new JsonWriter(outputStream);) {
jw.write(this);
System.out.println("Saved amalgamation preferences to " + settingsFileName);
} catch (IOException e1) {
diff --git a/src/main/java/moviescraper/doctord/model/preferences/Settings.java b/src/main/java/moviescraper/doctord/model/preferences/Settings.java
index 5810bf3..84fdde2 100644
--- a/src/main/java/moviescraper/doctord/model/preferences/Settings.java
+++ b/src/main/java/moviescraper/doctord/model/preferences/Settings.java
@@ -3,6 +3,7 @@ package moviescraper.doctord.model.preferences;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.File;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;
import java.util.Properties;
@@ -10,7 +11,8 @@ import java.util.Properties;
public class Settings {
private final static Properties programPreferences = new Properties();
- private static final String fileNameOfPreferences = "settings.xml";
+ private final static String folderNameOfPreferences = (System.getenv("XDG_CONFIG_HOME") != null ? System.getenv("XDG_CONFIG_HOME") : System.getenv("HOME")) + "/.config/JAVMovieSraper";
+ private static final String fileNameOfPreferences = folderNameOfPreferences + "/settings.xml";
protected interface Key {
String getKey();
@@ -39,7 +41,9 @@ public class Settings {
}
public static void savePreferences() {
- try (FileOutputStream settingsOutputStream = new FileOutputStream(fileNameOfPreferences);) {
+ File f = new File(fileNameOfPreferences);
+ f.getParentFile().mkdirs();
+ try (FileOutputStream settingsOutputStream = new FileOutputStream(f);) {
programPreferences.storeToXML(settingsOutputStream, "");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
@@ -115,4 +119,4 @@ public class Settings {
public String toString() {
return programPreferences.toString();
}
-}
\ No newline at end of file
+}