Skip to content

Commit

Permalink
Attempt to auto-detect heritrix version
Browse files Browse the repository at this point in the history
  • Loading branch information
csrster committed Aug 10, 2021
1 parent ea179c1 commit 63321f1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions common/common-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@
<artifactId>webarchive-commons</artifactId>
</dependency>

<dependency>
<groupId>org.archive.heritrix</groupId>
<artifactId>heritrix-commons</artifactId>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/
package dk.netarkivet.common;

import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Properties;
import java.util.regex.Pattern;

import org.apache.lucene.util.Version;
Expand Down Expand Up @@ -166,6 +168,29 @@ public static SimpleDateFormat getIsoDateFormatter() {
public static final String PROJECT_WEBSITE = "https://sbforge.org/display/NAS";

public static String getHeritrix3VersionString() {
return HERITRIX3_VERSION;
String h3version = null;
try {
Properties p = new Properties();
InputStream is = Constants.class.getResourceAsStream("/META-INF/maven/org.archive.heritrix/heritrix-commons/pom.properties");
if (is != null) {
p.load(is);
h3version = p.getProperty("version", "");
}
} catch (Exception e) {
// ignore
}
if (h3version == null) {
Package aPackage = org.archive.util.UriUtils.class.getPackage();
if (aPackage != null) {
h3version = aPackage.getImplementationVersion();
if (h3version == null) {
h3version = aPackage.getSpecificationVersion();
}
}
}
if (h3version == null) {
h3version = "unknownHeritrixVersion";
}
return h3version;
}
}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@
<version>${heritrix3.version}</version>
</dependency>

<dependency>
<groupId>org.archive.heritrix</groupId>
<artifactId>heritrix-commons</artifactId>
<version>${heritrix3.version}</version>
</dependency>

<dependency>
<groupId>org.archive.heritrix</groupId>
<artifactId>heritrix</artifactId>
Expand Down

0 comments on commit 63321f1

Please sign in to comment.