Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ There are a couple of static classes that help common usage scenarios:
`Spdx-Java-Library` can be configured using either Java system properties or a Java properties file located in the runtime CLASSPATH at `/resources/spdx-java-library.properties`.

The library has these configuration options:
1. `SPDXParser.OnlyUseLocalLicenses` - a boolean that controls whether the (potentially out of date) listed license information bundled inside the JAR is used (true), vs the library downloading the latest files from the SPDX website (false). Default is false (always download the latest files from the SPDX website).
2. `org.spdx.storage.listedlicense.enableCache` - a boolean that enables or disables a local cache for downloaded listed license information. Defaults to `false` (the cache is disabled). The cache location is determined as per the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (i.e. `${XDG_CACHE_HOME}/Spdx-Java-Library` or `${HOME}/.cache/Spdx-Java-Library`).
3. `org.spdx.storage.listedlicense.cacheCheckIntervalSecs` - a long that controls how often each cache entry is rechecked for staleness, in units of seconds. Defaults to 86,400 seconds (24 hours). Set to 0 (zero) to have each cache entry checked every time (note: this will result in a lot more network I/O and negatively impact performance, albeit there is still a substantial performance saving vs not using the cache at all).
1. `org.spdx.useJARLicenseInfoOnly` - a boolean that controls whether the (potentially out of date) listed license information bundled inside the JAR is used (true), vs the library downloading the latest files from the SPDX website (false). Default is false (always download the latest files from the SPDX website).
2. `org.spdx.downloadCacheEnabled` - a boolean that enables or disables the download cache. Defaults to `false` (the cache is disabled). The cache location is determined as per the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (i.e. `${XDG_CACHE_HOME}/Spdx-Java-Library` or `${HOME}/.cache/Spdx-Java-Library`).
3. `org.spdx.downloadCacheCheckIntervalSecs` - a long that controls how often each cache entry is rechecked for staleness, in units of seconds. Defaults to 86,400 seconds (24 hours). Set to 0 (zero) to have each cache entry checked every time (note: this will result in a lot more network I/O and negatively impact performance, albeit there is still a substantial performance saving vs not using the cache at all).

Note that these configuration options can only be modified prior to first use of Spdx-Java-Library. Once the library is initialized, subsequent changes will have no effect.

Expand Down
11 changes: 6 additions & 5 deletions resources/spdx-java-library.properties.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# if true, use licenses from stored set of licenses rather than from the spdx.org/licenses website
SPDXParser.OnlyUseLocalLicenses=false
# if true, only use license information stored within the JAR file at release time, rather than downloading the latest
# versions from the SPDX website
org.spdx.useJARLicenseInfoOnly=false

# if true, enable a local download cache for listed license files downloaded from the SPDX website
org.spdx.storage.listedlicense.enableCache=false
# if true, enable the download cache
org.spdx.downloadCacheEnabled=false

# local download cache re-check interval, in seconds
org.spdx.storage.listedlicense.cacheCheckIntervalSecs=86400
org.spdx.downloadCacheCheckIntervalSecs=86400
10 changes: 5 additions & 5 deletions src/main/java/org/spdx/library/model/license/ListedLicenses.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public class ListedLicenses {
* This constructor should only be called by the getListedLicenses method
*/
private ListedLicenses() {
// Note: this code confusingly uses different property values depending on the source (Java system property vs properties file),
// so we have to check both names in order to not break downstream consumers' legacy configurations. This is _NOT_ recommended for
// any new code that leverages the Configuration class.
onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("SPDXParser.OnlyUseLocalLicenses",
Configuration.getInstance().getProperty("OnlyUseLocalLicenses", "false")));
// Note: this code is confusing as this property changed names several times over time, and we want to preserve
// backwards compatibility for those downstream library users who are using the old/deprecated names
onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("org.spdx.useJARLicenseInfoOnly",
Configuration.getInstance().getProperty("SPDXParser.OnlyUseLocalLicenses",
Configuration.getInstance().getProperty("OnlyUseLocalLicenses", "false"))));
initializeLicenseModelStore();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/spdx/utility/DownloadCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public final class DownloadCache {
System.getenv("XDG_CACHE_HOME")) +
File.separator + "Spdx-Java-Library";

private final String CONFIG_PROPERTY_CACHE_ENABLED = "org.spdx.storage.listedlicense.enableCache";
private final String CONFIG_PROPERTY_CACHE_CHECK_INTERVAL_SECS = "org.spdx.storage.listedlicense.cacheCheckIntervalSecs";
private final String CONFIG_PROPERTY_CACHE_ENABLED = "org.spdx.downloadCacheEnabled";
private final String CONFIG_PROPERTY_CACHE_CHECK_INTERVAL_SECS = "org.spdx.downloadCacheCheckIntervalSecs";
private final boolean cacheEnabled;
private final long cacheCheckIntervalSecs;

Expand Down