Skip to content

Commit 0ef67e2

Browse files
authored
Release 2.0.0 (#24)
* Bump version * Update GitHub Actions (#13) * Update Github Actions * Change compiler source and target on JDK higher than 17 for tests * Delegate source parameter for javadoc to maven.compiler.source * Add tests as JDK 11, 17 and 21 * Update Maven plugins. Update junit version. Fix wrong <scm> values. * Add devcontainer * Update Github Actions * Remove jdk25-ea * Fix javadoc warnings * Revert "Fix javadoc warnings" This reverts commit b20a5d9. * Add jmh benchmark * Set release version * Fix echo on bench.yml * Fix multiline commands on bench.yml * Reduce warmup time * Escape backticks on bench.yml * Bump version * Feature: Implement immutable sortable ULID instance. Breaking change: Random default instance use a lazily instantiated SecureRandom. Breaking change: generate, generateBinary, toBinary, fromBinary now checks for ULID validity. Fix: Prevent monotonic ULID increment entropy on invalid timestamp. Fix: First 8 bit of timestamp may be converted wrongly. Feature: Add JaCoCo report. Feature: More tests and benchmarks. * Fix: Fix surefire-report * Fix: Remove test that changes private constructor to public. * Fix: Wrong job name for site.yml * Fix: Remove mocks (JDK incompatibility, offline JDK instrumentation is brittle) Fix: Remove private constructor for ULID. Fix: Update Javadoc plugin. Feature: Add source cross reference plugin. * Update license * Feature: Add Monotonic.random static methods Fix: Documentation * Update Github actions * Add parseULID benchmark * Update devcontainer.json * Set release version * Remove dependabot.yml * Bump version * Bump version * Update to Java 11 * Change to Junit 5 * Fix version on module-info.java * Implement generating timestamp from java.time.Clock * Tests for generating timestamp from java.time.Clock * Update readme and javadoc * Add benchmarks for clock parameter * Set release version
1 parent 345f919 commit 0ef67e2

File tree

16 files changed

+1371
-571
lines changed

16 files changed

+1371
-571
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"features": {
55
"ghcr.io/devcontainers/features/java:1": {
66
"jdkDistro": "tem",
7-
"version": "8.0.442",
8-
"mavenVersion": "3.8.8",
7+
"version": "11.0.26",
8+
"mavenVersion": "3.9.9",
99
"installMaven": true
1010
}
1111
},

.github/workflows/bench.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,12 @@ jobs:
1616
matrix:
1717
include:
1818
# Oldest LTS
19-
- name: temurin-jdk8-target-jdk7
20-
version: 8
19+
- name: temurin-jdk11-target-jdk11
20+
version: 11
2121
distribution: temurin
22-
target: 7
23-
targetStr: '1.7'
24-
- name: temurin-jdk8-target-jdk8
25-
version: 8
26-
distribution: temurin
27-
target: 8
28-
targetStr: '1.8'
22+
target: 11
23+
targetStr: '11'
2924
# Latest LTS
30-
- name: temurin-jdk21-target-jdk8
31-
version: 21
32-
distribution: temurin
33-
target: 8
34-
targetStr: '1.8'
3525
- name: temurin-jdk21-target-jdk11
3626
version: 21
3727
distribution: temurin
@@ -67,7 +57,7 @@ jobs:
6757
cat ./bench-${{matrix.name}}.json >> $GITHUB_STEP_SUMMARY
6858
echo -e "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY
6959
- name: bench-pages-branch-${{matrix.name}}
70-
if: ${{github.ref_type == 'branch'}}
60+
if: ${{github.ref_type == 'branch' && matrix.version >= matrix.target}}
7161
uses: benchmark-action/github-action-benchmark@v1
7262
with:
7363
name: branch-${{github.ref_name}}-${{matrix.name}}
@@ -78,7 +68,7 @@ jobs:
7868
summary-always: true
7969
benchmark-data-dir-path: 'benchmark/branch/${{github.ref_name}}'
8070
- name: bench-pages-tag-${{matrix.name}}
81-
if: ${{github.ref_type == 'tag'}}
71+
if: ${{github.ref_type == 'tag' && matrix.version >= matrix.target}}
8272
uses: benchmark-action/github-action-benchmark@v1
8373
with:
8474
name: tag-${{github.ref_name}}-${{matrix.name}}

.github/workflows/build.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
matrix:
2727
include:
2828
# LTS versions
29-
- name: temurin-jdk8
30-
version: 8
31-
distribution: temurin
3229
- name: temurin-jdk11
3330
version: 11
3431
distribution: temurin
@@ -68,12 +65,7 @@ jobs:
6865
distribution: ${{matrix.distribution}}
6966
cache: maven
7067
- name: verify-${{matrix.name}}
71-
# Java 1.7 is source compatible only up to JDK 17
72-
if: ${{matrix.version<=17}}
7368
run: mvn clean verify --settings .settings.xml -Dgpg.skip -B -V
74-
- name: verify-as-jdk8-${{matrix.name}}
75-
if: ${{matrix.version>=8}}
76-
run: mvn clean verify -Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8 --settings .settings.xml -Dgpg.skip -B -V
7769
- name: verify-as-jdk11-${{matrix.name}}
7870
if: ${{matrix.version>=11}}
7971
run: mvn clean verify -Dmaven.compiler.source=11 -Dmaven.compiler.target=11 --settings .settings.xml -Dgpg.skip -B -V

.github/workflows/package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: setup-toolchain
3232
uses: actions/setup-java@v4
3333
with:
34-
java-version: 8
34+
java-version: 11
3535
distribution: temurin
3636
cache: maven
3737
- name: setup-gpg

.github/workflows/site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: setup-toolchain
2525
uses: actions/setup-java@v4
2626
with:
27-
java-version: 8
27+
java-version: 11
2828
distribution: temurin
2929
cache: maven
3030
- name: site

pom.xml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.azam.ulidj</groupId>
55
<artifactId>ulidj</artifactId>
6-
<version>1.1.0</version>
6+
<version>2.0.0</version>
77
<name>ulidj</name>
88
<description>ULID (Universally Unique Lexicographically Sortable Identifier) generator and parser for Java.</description>
99
<url>https://github.com/azam/ulidj</url>
@@ -44,8 +44,8 @@
4444
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4545
<project.build.lineEnding>LF</project.build.lineEnding>
4646
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
47-
<maven.compiler.source>1.7</maven.compiler.source>
48-
<maven.compiler.target>1.7</maven.compiler.target>
47+
<maven.compiler.source>11</maven.compiler.source>
48+
<maven.compiler.target>11</maven.compiler.target>
4949
<!-- Benchmark properties -->
5050
<jmh.version>1.37</jmh.version>
5151
<jmh.benchmarks>Benchmark</jmh.benchmarks>
@@ -60,9 +60,15 @@
6060
</properties>
6161
<dependencies>
6262
<dependency>
63-
<groupId>junit</groupId>
64-
<artifactId>junit</artifactId>
65-
<version>4.13.2</version>
63+
<groupId>org.junit.jupiter</groupId>
64+
<artifactId>junit-jupiter-api</artifactId>
65+
<version>5.12.2</version>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.junit.jupiter</groupId>
70+
<artifactId>junit-jupiter-engine</artifactId>
71+
<version>5.12.2</version>
6672
<scope>test</scope>
6773
</dependency>
6874
<dependency>
@@ -90,7 +96,7 @@
9096
<plugin>
9197
<groupId>org.apache.maven.plugins</groupId>
9298
<artifactId>maven-compiler-plugin</artifactId>
93-
<version>3.8.1</version>
99+
<version>3.14.0</version>
94100
<configuration>
95101
<annotationProcessorPaths>
96102
<path>
@@ -207,7 +213,7 @@
207213
<plugin>
208214
<groupId>org.apache.maven.plugins</groupId>
209215
<artifactId>maven-javadoc-plugin</artifactId>
210-
<version>3.4.1</version>
216+
<version>3.11.2</version>
211217
<configuration>
212218
<!-- Setting this to 7 removes unnamed modules found warnings -->
213219
<!-- Defaults to ${maven.compiler.source} -->
@@ -225,7 +231,7 @@
225231
<plugin>
226232
<groupId>org.apache.maven.plugins</groupId>
227233
<artifactId>maven-help-plugin</artifactId>
228-
<version>3.2.0</version>
234+
<version>3.5.1</version>
229235
</plugin>
230236
<plugin>
231237
<groupId>org.apache.maven.plugins</groupId>
@@ -236,7 +242,7 @@
236242
<groupId>net.revelc.code.formatter</groupId>
237243
<artifactId>formatter-maven-plugin</artifactId>
238244
<!-- Sticking to this version as it is the latest that supports JDK8 -->
239-
<version>2.16.0</version>
245+
<version>2.23.0</version>
240246
<configuration>
241247
<configFile>${project.basedir}/eclipse-java-google-style.xml</configFile>
242248
<encoding>${project.build.sourceEncoding}</encoding>
@@ -259,7 +265,7 @@
259265
<plugin>
260266
<groupId>au.com.acegi</groupId>
261267
<artifactId>xml-format-maven-plugin</artifactId>
262-
<version>3.2.2</version>
268+
<version>4.1.0</version>
263269
<configuration>
264270
<includes>pom.xml</includes>
265271
<includes>.settings.xml</includes>
@@ -312,7 +318,15 @@
312318
<plugin>
313319
<groupId>org.apache.maven.plugins</groupId>
314320
<artifactId>maven-javadoc-plugin</artifactId>
315-
<version>3.4.1</version>
321+
<version>3.11.2</version>
322+
<reportSets>
323+
<reportSet>
324+
<reports>
325+
<report>javadoc</report>
326+
<report>test-javadoc</report>
327+
</reports>
328+
</reportSet>
329+
</reportSets>
316330
</plugin>
317331
</plugins>
318332
</reporting>
@@ -341,7 +355,7 @@
341355
<plugin>
342356
<groupId>org.apache.maven.plugins</groupId>
343357
<artifactId>maven-gpg-plugin</artifactId>
344-
<version>1.6</version>
358+
<version>3.2.7</version>
345359
<executions>
346360
<execution>
347361
<id>sign-artifacts</id>
@@ -363,7 +377,7 @@
363377
<plugin>
364378
<groupId>org.sonatype.plugins</groupId>
365379
<artifactId>nexus-staging-maven-plugin</artifactId>
366-
<version>1.6.14</version>
380+
<version>1.7.0</version>
367381
<extensions>true</extensions>
368382
<configuration>
369383
<serverId>ossrh</serverId>

readme.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Add the following tag to `dependencies` tag in your `pom.xml` file. Change the v
5757
<dependency>
5858
<groupId>io.azam.ulidj</groupId>
5959
<artifactId>ulidj</artifactId>
60-
<version>1.1.0</version>
60+
<version>2.0.0</version>
6161
</dependency>
6262
```
6363

@@ -71,14 +71,18 @@ ULID ulid1 = ULID.randomULID();
7171
// Using provided Random instance
7272
ULID ulid2 = ULID.randomULID(ThreadLocalRandom.current());
7373
// Using provided SecureRandom instance
74-
ULID ulid3 = ULID.parseULID("003JZ9J6G80123456789abcdef");
74+
ULID ulid3 = ULID.randomULID(SecureRandom.newInstance("SHA1PRNG"));
75+
// Using provided Clock instance
76+
ULID ulid4 = ULID.randomULID(Clock.systemUTC());
77+
// Using provided Clock and Random instance
78+
ULID ulid5 = ULID.randomULID(Clock.systemUTC(), SecureRandom.newInstance("SHA1PRNG"));
7579
// Convert ULID string to ULID instance
76-
ULID ulid4 = ULID.parseULID("003JZ9J6G80123456789abcdef");
80+
ULID ulid6 = ULID.parseULID("003JZ9J6G80123456789abcdef");
7781
// Convert ULID binary to ULID instance
78-
ULID ulid5 = ULID.parseULID(
82+
ULID ulid7 = ULID.parseULID(
7983
new byte[] {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf});
8084
// Instantiate a ULID instance from current time and provided entropy bytes
81-
ULID ulid6 = ULID.generateULID(System.currentTimeMillis(), entropy);
85+
ULID ulid8 = ULID.generateULID(System.currentTimeMillis(), entropy);
8286
// Sort ULID instances lexicographically
8387
List<ULID> ulids = Arrays.asList(ulid1, ulid2, ulid3, ulid4, ulid5, ulid6);
8488
Collections.sort(ulids);
@@ -93,11 +97,15 @@ String ulid1 = ULID.random();
9397
String ulid2 = ULID.random(ThreadLocalRandom.current());
9498
// Using provided SecureRandom instance
9599
String ulid3 = ULID.random(SecureRandom.newInstance("SHA1PRNG"));
100+
// Using provided Clock instance
101+
String ulid4 = ULID.random(Clock.systemUTC());
102+
// Using provided Clock and Random instance
103+
String ulid5 = ULID.random(Clock.systemUTC(), SecureRandom.newInstance("SHA1PRNG"));
96104
// Generate ULID string from current time and provided entropy bytes
97105
byte[] entropy = new byte[] {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
98-
String ulid4 = ULID.generate(System.currentTimeMillis(), entropy);
106+
String ulid6 = ULID.generate(System.currentTimeMillis(), entropy);
99107
// Convert ULID binary to ULID string
100-
String ulid5 = ULID.fromBinary(
108+
String ulid7 = ULID.fromBinary(
101109
new byte[] {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf});
102110
```
103111

@@ -110,11 +118,15 @@ byte[] ulid1 = ULID.randomBinary();
110118
byte[] ulid2 = ULID.randomBinary(ThreadLocalRandom.current());
111119
// Using provided SecureRandom instance
112120
byte[] ulid3 = ULID.randomBinary(SecureRandom.newInstance("SHA1PRNG"));
121+
// Using provided Clock instance
122+
byte[] ulid4 = ULID.randomBinary(Clock.systemUTC());
123+
// Using provided Clock and Random instance
124+
byte[] ulid5 = ULID.randomBinary(Clock.systemUTC(), SecureRandom.newInstance("SHA1PRNG"));
113125
// Generate ULID string from current time and provided entropy bytes
114126
byte[] entropy = new byte[] {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
115-
byte[] ulid4 = ULID.generateBinary(System.currentTimeMillis(), entropy);
127+
byte[] ulid6 = ULID.generateBinary(System.currentTimeMillis(), entropy);
116128
// Convert ULID string to ULID binary
117-
byte[] ulid5 = ULID.toBinary("003JZ9J6G80123456789abcdef");
129+
byte[] ulid7 = ULID.toBinary("003JZ9J6G80123456789abcdef");
118130
```
119131

120132
ULID utilities examples:
@@ -166,6 +178,23 @@ String ulid9 = monotonicUlid2.generate();
166178
String ulid10 = monotonicUlid2.generate();
167179
byte[] ulid11 = monotonicUlid2.generateBinary();
168180
ULID ulid12 = monotonicUlid2.generateULID();
181+
182+
// Create a new independent instance of MonotonicULID using provided Clock instance
183+
MonotonicULID monotonicUlid3 = new MonotonicULID(Clock.systemUTC());
184+
String ulid13 = monotonicUlid3.generate();
185+
// Subsequent calls generates monotonic ULID
186+
String ulid14 = monotonicUlid3.generate();
187+
byte[] ulid15 = monotonicUlid3.generateBinary();
188+
ULID ulid16 = monotonicUlid3.generateULID();
189+
190+
// Create a new independent instance of MonotonicULID using provided Clock and Random instance
191+
MonotonicULID monotonicUlid4 =
192+
new MonotonicULID(Clock.systemUTC(), SecureRandom.newInstance("SHA1PRNG"));
193+
String ulid17 = monotonicUlid4.generate();
194+
// Subsequent calls generates monotonic ULID
195+
String ulid18 = monotonicUlid4.generate();
196+
byte[] ulid19 = monotonicUlid4.generateBinary();
197+
ULID ulid20 = monotonicUlid4.generateULID();
169198
```
170199

171200
## Develop

0 commit comments

Comments
 (0)