Minimum version of conllu2korapxml

Change-Id: Ic6c33fb32b450608df53ea75c43bdc1e6719ea43
diff --git a/Changes b/Changes
index ed91c00..bd1d2fb 100755
--- a/Changes
+++ b/Changes
@@ -4,6 +4,7 @@
         - Added german translation for Cosmas-II. (hebasta)
         - Workaround for failing utf8 test in some
           environments (fixes #197). (diewald)
+        - Require at least conllu2korapxml v0.6.1. (diewald)
 
 0.49 2023-02-23
         - Introduce conllu2korapxml command via plugin. (diewald)
diff --git a/Dockerfile b/Dockerfile
index 641adec..b3a094d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -102,7 +102,7 @@
 RUN cpanm \
    https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.4.1.tar.gz \
    https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.49.tar.gz \
-   https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.0.tar.gz
+   https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.1.tar.gz
 
 # Remove all build dependencies
 RUN apk del git \
diff --git a/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm b/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm
index d8cfae0..8e1abf2 100644
--- a/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm
+++ b/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm
@@ -1,14 +1,32 @@
 package Kalamar::Plugin::KorAPXML2CoNLLU;
 use Mojo::Base 'Mojolicious::Plugin';
 use Mojo::Base -strict;
+
 sub register {
   my ($plugin, $mojo) = @_;
-  my $script = `sh -c 'command -v conllu2korapxml'`;
-  if ($script ne '') {
-    # Add additional command path
-    push(@{$mojo->commands->namespaces}, __PACKAGE__);
-    return 1;
-  };
-  return 0;
+
+  return 0 unless check_existence();
+
+  # Add additional command path
+  push(@{$mojo->commands->namespaces}, __PACKAGE__);
+  return 1;
 };
+
+sub check_existence {
+  my $script = `sh -c 'command -v conllu2korapxml'`;
+
+  return 0 if $script eq '';
+
+  my $version = qx{conllu2korapxml -v};
+
+  if ($version =~ m!v(\d+)\.(\d+)\.(\d+)!) {
+    if ($1 < 1 && ($2 < 6 || $2 == 6 && $3 < 1)) {
+      warn('conllu2korapxml needs to be at least v0.6.1');
+      return 0;
+    };
+  };
+
+  return 1;
+};
+
 1;
diff --git a/t/plugin/conllu2korapxml.t b/t/plugin/conllu2korapxml.t
index af3d408..f217fb8 100644
--- a/t/plugin/conllu2korapxml.t
+++ b/t/plugin/conllu2korapxml.t
@@ -1,11 +1,10 @@
 use Test::More;
 use Test::Mojo;
 use Test::Output;
+use Kalamar::Plugin::KorAPXML2CoNLLU;
 
-my $script = `sh -c 'command -v conllu2korapxml'`;
-
-if ($script eq '') {
-  plan skip_all => "KorAP::XML::Krill is not installed";
+unless (Kalamar::Plugin::KorAPXML2CoNLLU::check_existence()) {
+  plan skip_all => "KorAP::XML::ConLLU is not installed";
   exit;
 };