• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kit-data-manager / ro-crate-java / #467

05 Jun 2025 03:39PM UTC coverage: 90.853%. First build
#467

Pull #268

github

web-flow
Merge ec9e9da91 into bd8aba4fc
Pull Request #268: 265 store provenance in crates about the tool which created it

85 of 87 new or added lines in 8 files covered. (97.7%)

2046 of 2252 relevant lines covered (90.85%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.24
/src/main/java/edu/kit/datamanager/ro_crate/util/ClasspathPropertiesVersionProvider.java
1
package edu.kit.datamanager.ro_crate.util;
2

3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.net.URL;
6
import java.util.Properties;
7

8
public class ClasspathPropertiesVersionProvider implements VersionProvider {
1✔
9
    public static final String VERSION_PROPERTIES = "version.properties";
10

11
    /**
12
     * Cached version to avoid repeated file/resource reads.
13
     */
14
    private String cachedVersion = null;
1✔
15

16
    /**
17
     * Constructs a ClasspathPropertiesVersionProvider that reads the version from a properties file in the classpath.
18
     */
19
    public ClasspathPropertiesVersionProvider() {
1✔
20
        this.cachedVersion = getVersion();
1✔
21
    }
1✔
22

23
    @Override
24
    public String getVersion() {
25
        if (cachedVersion != null) {
1✔
26
            return cachedVersion;
1✔
27
        }
28

29
        URL resource = this.getClass().getResource("/" + VERSION_PROPERTIES);
1✔
30
        assert resource != null : VERSION_PROPERTIES + " not found in classpath";
1✔
31

32
        try (InputStream input = resource.openStream()) {
1✔
33
            Properties properties = new Properties();
1✔
34
            properties.load(input);
1✔
35
            String version = properties.getProperty("version");
1✔
36
            assert version != null : "Version property not found in " + VERSION_PROPERTIES;
1✔
37
            return version.trim();
1✔
NEW
38
        } catch (IOException e) {
×
NEW
39
            throw new IllegalStateException("Failed to read version from properties file", e);
×
40
        }
41
    }
42
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc