Skip to content

Commit

Permalink
Hard-code metadata instead of storing it in .properties file
Browse files Browse the repository at this point in the history
This resolves a frequently-reported Android issue where the properties
file can't be found on the classpath.

#116
  • Loading branch information
mangstadt committed Sep 11, 2021
1 parent c2fc44e commit 0450ed8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 43 deletions.
15 changes: 1 addition & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,11 @@
<build>
<resources>
<!--
Copy all resources into the JAR, but only filter "ez-vcard.properties"
Copy all resources into the JAR.
-->
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>ezvcard/ez-vcard.properties</include>
</includes>
</resource>

<!--
For reasons unknown, the "eclipse:eclipse" goal fails with the above <resource> definitions.
Expand All @@ -157,12 +150,6 @@
<extensions>true</extensions>
<configuration>
<instructions>
<!--
The plugin must be instructed to retrieve the filtered files from the "target/classes" directory.
Otherwise, it will copy the unfiltered versions in "src/main/resources" to the JAR.
-->
<Include-Resource>{maven-resources}, {ezvcard/ez-vcard.properties=target/classes/ezvcard/ez-vcard.properties}</Include-Resource>

<!-- Define optional dependencies -->
<Import-Package>
com.fasterxml.jackson.*;resolution:=optional,
Expand Down
29 changes: 4 additions & 25 deletions src/main/java/ezvcard/Ezvcard.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package ezvcard;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;

import org.w3c.dom.Document;

Expand All @@ -32,7 +30,6 @@
import ezvcard.io.xml.XCardDocument;
import ezvcard.io.xml.XCardReader;
import ezvcard.io.xml.XCardWriter;
import ezvcard.util.IOUtils;

/*
Copyright (c) 2012-2021, Michael Angstadt
Expand Down Expand Up @@ -102,40 +99,22 @@ public final class Ezvcard {
/**
* The version of the library.
*/
public static final String VERSION;
public static final String VERSION = "0.11.3-SNAPSHOT";

/**
* The Maven group ID.
*/
public static final String GROUP_ID;
public static final String GROUP_ID = "com.googlecode.ez-vcard";

/**
* The Maven artifact ID.
*/
public static final String ARTIFACT_ID;
public static final String ARTIFACT_ID = "ez-vcard";

/**
* The project webpage.
*/
public static final String URL;

static {
InputStream in = null;
Properties props = new Properties();
try {
in = Ezvcard.class.getResourceAsStream("ez-vcard.properties");
props.load(in);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(in);
}

VERSION = props.getProperty("version");
GROUP_ID = props.getProperty("groupId");
ARTIFACT_ID = props.getProperty("artifactId");
URL = props.getProperty("url");
}
public static final String URL = "https://github.com/mangstadt/ez-vcard";

/**
* <p>
Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/ezvcard/ez-vcard.properties

This file was deleted.

0 comments on commit 0450ed8

Please sign in to comment.