Hey there! I am in the process of packaging veraPDF, a CLI/GUI PDF/A validation program that uses Maven
for building. The project doesn’t provide pre-built binaries but rather an installer. I managed to package veraPDF for Nixpkgs using the installer, but this is a less-than-ideal solution as it requires creating an XML file that represents the selections in the graphical installer and running the installer in a FHSUserEnv
:
installPhase = let
auto-install = writeTextFile {
name = "auto-install.xml";
text = let
gui = lib.boolToString enableGUI;
doc = lib.boolToString enableDocumentation;
scripts = lib.boolToString enableMacAndNixScripts;
models = lib.boolToString enableCorpusAndValidationModel;
plugin = lib.boolToString enableSamplePlugin;
in ''
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<AutomatedInstallation langpack="eng">
<com.izforge.izpack.panels.htmlhello.HTMLHelloPanel id="welcome"/>
<com.izforge.izpack.panels.target.TargetPanel id="install_dir">
<installpath>@out@/bin</installpath>
</com.izforge.izpack.panels.target.TargetPanel>
<com.izforge.izpack.panels.packs.PacksPanel id="sdk_pack_select">
<pack index="0" name="veraPDF GUI" selected="${gui}"/>
<pack index="1" name="veraPDF Mac and *nix Scripts" selected="${scripts}"/>
<pack index="2" name="veraPDF Corpus and Validation model" selected="${models}"/>
<pack index="3" name="veraPDF Documentation" selected="${doc}"/>
<pack index="4" name="veraPDF Sample Plugins" selected="${plugin}"/>
</com.izforge.izpack.panels.packs.PacksPanel>
<com.izforge.izpack.panels.install.InstallPanel id="install"/>
<com.izforge.izpack.panels.finish.FinishPanel id="finish"/>
</AutomatedInstallation>
'';
};
# the installer expects chmod to be found in /bin/chmod
installEnv = buildFHSUserEnv {
name = "installer-env";
runScript = "java -jar verapdf-izpack-installer-${version}.jar";
};
in ''
runHook preInstall
mkdir $out
substituteAll ${auto-install} auto-install.xml
${installEnv}/bin/${installEnv.name} auto-install.xml
rm -r $out/bin/{.installationinformation,Uninstaller}
for i in $out/bin/verapdf{,-gui}; do
wrapProgram $i --set JAVA_HOME ${jre}
done
runHook postInstall
'';
Although this method does produce a working program, I believe it is not suitable for inclusion in nixpkgs.
I have also tried several other methods to package this maven application, including (all using the latest release v1.22.3):
- Using mvn2nix, but it failed with the fallowing error when running
nix run github:fzakaria/mvn2nix#mvn2nix > mvn2nix-lock.json
:
java.lang.RuntimeException: Could not find artifact org.verapdf.pdfbox:xmpbox:jar:2.0.70 in any repository
- Using mvn2nix-maven-plugin, which successfully produced a
project-info.json
but the build still failed:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.405 s
[INFO] Finished at: 2023-02-13T14:04:50Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project gui: Could not resolve dependencies for project org.verapdf.apps:gui:jar:1.22.0: Failed to collect dependencies at or>
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :gui
- The double invocation method, which also produced a repository for offline usage, but it failed during the build too:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.verapdf:verapdf-apps:1.22.0: Cannot access vera-dev (https://artifactory.openpreservation.org/artifactory/vera-dev) i>
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.verapdf:verapdf-apps:1.22.0 (/build/source/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for org.verapdf:verapdf-apps:1.22.0: Cannot access vera-dev (https://artifactory.openpreservation.org/artifactory/vera-de>
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Executing the build locally without using Nix works perfectly fine. Simply running mvn clean install -DskipTests
successfully produces a jar file. However, the tests seem to fail for some reason and throw an error, specifically: [ERROR] VeraAppConfigTest.testHashCodeAndEquals:72 EqualsVerifier found a problem in class org.verapdf.apps.VeraAppConfigImpl. -> Unsupported class file major version 63
In conclusion, I am still searching for the most efficient and effective method to package veraPDF
. I’d be grateful for any tips or suggestions on how to get it done.