Skip to content

Commit

Permalink
Add source commit ID to JaCoCo constants
Browse files Browse the repository at this point in the history
  • Loading branch information
marchof committed Jan 30, 2022
1 parent 046ba52 commit 161deee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions org.jacoco.core.test/src/org/jacoco/core/JaCoCoTest.java
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.jacoco.core;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;
Expand All @@ -26,6 +27,16 @@ public void testVERSION() {
assertNotNull(JaCoCo.VERSION);
}

@Test
public void testCOMMITID() {
assertNotNull(JaCoCo.COMMITID);
}

@Test
public void testCOMMITID_SHORT() {
assertEquals(7, JaCoCo.COMMITID_SHORT.length());
}

@Test
public void testHOMEURL() {
assertNotNull(JaCoCo.HOMEURL);
Expand Down
12 changes: 11 additions & 1 deletion org.jacoco.core/src/org/jacoco/core/JaCoCo.java
Expand Up @@ -19,9 +19,17 @@
*/
public final class JaCoCo {

/** Qualified build version of the JaCoCo core library. */
/** Version of JaCoCo core. */
public static final String VERSION;

/** Commit ID of the source tree of JaCoCo core. */
public static final String COMMITID;

/**
* Shortened (7 digit) commit ID of the source tree of JaCoCo core.
*/
public static final String COMMITID_SHORT;

/** Absolute URL of the current JaCoCo home page */
public static final String HOMEURL;

Expand All @@ -32,6 +40,8 @@ public final class JaCoCo {
final ResourceBundle bundle = ResourceBundle
.getBundle("org.jacoco.core.jacoco");
VERSION = bundle.getString("VERSION");
COMMITID = bundle.getString("COMMITID");
COMMITID_SHORT = COMMITID.substring(0, 7);
HOMEURL = bundle.getString("HOMEURL");
RUNTIMEPACKAGE = bundle.getString("RUNTIMEPACKAGE");
}
Expand Down
1 change: 1 addition & 0 deletions org.jacoco.core/src/org/jacoco/core/jacoco.properties
@@ -1,3 +1,4 @@
VERSION=${qualified.bundle.version}
COMMITID=${buildNumber}
HOMEURL=${jacoco.home.url}
RUNTIMEPACKAGE=${jacoco.runtime.package.name}

0 comments on commit 161deee

Please sign in to comment.