Skip to content

Commit abd2880

Browse files
committed
Merge branch 'release-0.0.9'
2 parents b9920b4 + 178031d commit abd2880

30 files changed

+885
-375
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ develop ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ develop ]
20+
schedule:
21+
- cron: '17 10 * * 2'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: [ 'java' ]
32+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33+
# Learn more:
34+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v2
39+
40+
# Initializes the CodeQL tools for scanning.
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@v1
43+
with:
44+
languages: ${{ matrix.language }}
45+
# If you wish to specify custom queries, you can do so here or in a config file.
46+
# By default, queries listed here will override any specified in a config file.
47+
# Prefix the list here with "+" to use these queries and those in the config file.
48+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
49+
50+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51+
# If this step fails, then you should remove it and run the build manually (see below)
52+
- name: Autobuild
53+
uses: github/codeql-action/autobuild@v1
54+
55+
# ℹ️ Command-line programs to run using the OS shell.
56+
# 📚 https://git.io/JvXDl
57+
58+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59+
# and modify them (or add more) to build your code if your project
60+
# uses a compiled language
61+
62+
#- run: |
63+
# make bootstrap
64+
# make release
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v1

.github/workflows/java8-maven.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Java8+ with Maven
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
build-and-test-job:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
java: [ 8, 11 ]
11+
os: [ ubuntu-latest, macOS-latest, windows-latest ]
12+
experimental: [ false ]
13+
include:
14+
- java: '>11'
15+
os: ubuntu-latest
16+
experimental: true
17+
18+
name: JDK${{ matrix.java }} on ${{ matrix.os }}
19+
runs-on: ${{ matrix.os }}
20+
continue-on-error: ${{ matrix.experimental }}
21+
22+
steps:
23+
- name: Checkout source code
24+
uses: actions/checkout@v2
25+
with:
26+
submodules: true
27+
28+
- name: Setup Java
29+
uses: actions/setup-java@v1
30+
with:
31+
java-version: ${{ matrix.java }}
32+
33+
- name: Setup Maven cache
34+
uses: actions/cache@v1
35+
with:
36+
path: ~/.m2
37+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
38+
restore-keys: ${{ runner.os }}-m2
39+
40+
- name: Build and (headless) test with Maven
41+
uses: GabrielBB/xvfb-action@v1
42+
with:
43+
run: mvn -B package --file pom.xml
44+
45+
release-job:
46+
needs: build-and-test-job
47+
if: startsWith(github.repository, 'nbbrd/') && startsWith(github.ref, 'refs/tags/v')
48+
strategy:
49+
matrix:
50+
java: [ 11 ]
51+
os: [ ubuntu-latest ]
52+
53+
name: Release on tag
54+
runs-on: ${{ matrix.os }}
55+
56+
steps:
57+
- name: Checkout source code
58+
uses: actions/checkout@v2
59+
with:
60+
submodules: true
61+
62+
- name: Setup Java
63+
uses: actions/setup-java@v1
64+
with:
65+
java-version: ${{ matrix.java }}
66+
67+
- name: Setup Maven cache
68+
uses: actions/cache@v1
69+
with:
70+
path: ~/.m2
71+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
72+
restore-keys: ${{ runner.os }}-m2
73+
74+
- name: Build with Maven
75+
run: mvn -B package --file pom.xml -DskipTests=true
76+
77+
- name: Create dummy file if no assets
78+
run: test -d "binaries" || (mkdir binaries && echo "no assets" > binaries/no_assets.txt)
79+
80+
- name: Create draft release and upload assets
81+
uses: xresloader/upload-to-github-release@v1
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
with:
85+
file: 'binaries/*'
86+
87+
- name: Deploy with Maven
88+
run: test -f ci.settings.xml && mvn -B deploy -Dmaven.test.skip -s ci.settings.xml -P deploy-releases
89+
env:
90+
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
91+
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.
File renamed without changes.

java-io-base/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>be.nbb.rd</groupId>
77
<artifactId>java-io-parent</artifactId>
8-
<version>0.0.8</version>
8+
<version>0.0.9</version>
99
</parent>
1010

1111
<artifactId>java-io-base</artifactId>
@@ -23,7 +23,12 @@
2323
<artifactId>lombok</artifactId>
2424
<scope>provided</scope>
2525
</dependency>
26-
26+
<dependency>
27+
<groupId>be.nbb.rd</groupId>
28+
<artifactId>java-design-processor</artifactId>
29+
<scope>provided</scope>
30+
</dependency>
31+
2732
<!-- test libraries -->
2833
<dependency>
2934
<groupId>junit</groupId>

java-io-base/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
requires static org.checkerframework.checker.qual;
2121
requires static lombok;
22+
requires static nbbrd.design;
2223

2324
exports nbbrd.io;
2425
exports nbbrd.io.function;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package nbbrd.io;
2+
3+
import java.io.BufferedOutputStream;
4+
import java.io.IOException;
5+
import java.io.InputStream;
6+
import java.io.OutputStream;
7+
import java.nio.file.Path;
8+
import java.util.Objects;
9+
import java.util.concurrent.atomic.AtomicReference;
10+
11+
/**
12+
* System-wide utility that gets the number of bytes per block from several byte sources.
13+
* May be overridden to deal with new JDK APIs.
14+
*/
15+
public class BlockSizer {
16+
17+
public static final AtomicReference<BlockSizer> INSTANCE = new AtomicReference<>(new BlockSizer());
18+
19+
public static final long DEFAULT_BLOCK_BUFFER_SIZE = 512;
20+
public static final long DEFAULT_BUFFER_OUTPUT_STREAM_SIZE = 8192;
21+
public static final long UNKNOWN_SIZE = -1;
22+
23+
/**
24+
* Returns the number of bytes per block in the file store of this file.
25+
*
26+
* @param file a non-null file as byte source
27+
* @return a positive value representing the block size in bytes if available, -1 otherwise
28+
* @throws IOException if an I/O error occurs
29+
* @see <a href="https://docs.oracle.com/javase/10/docs/api/java/nio/file/FileStore.html#getBlockSize()">https://docs.oracle.com/javase/10/docs/api/java/nio/file/FileStore.html#getBlockSize()</a>
30+
*/
31+
public long getBlockSize(Path file) throws IOException {
32+
Objects.requireNonNull(file);
33+
return DEFAULT_BLOCK_BUFFER_SIZE;
34+
}
35+
36+
/**
37+
* Returns the number of bytes per block in the input stream implementation.
38+
*
39+
* @param stream a non-null input stream as byte source
40+
* @return a positive value representing the block size in bytes if available, -1 otherwise
41+
* @throws IOException if an I/O error occurs
42+
*/
43+
public long getBlockSize(InputStream stream) throws IOException {
44+
return stream.available();
45+
}
46+
47+
/**
48+
* Returns the number of bytes per block in the output stream implementation.
49+
*
50+
* @param stream a non-null output stream as byte source
51+
* @return a positive value representing the block size in bytes if available, -1 otherwise
52+
* @throws IOException if an I/O error occurs
53+
*/
54+
public long getBlockSize(OutputStream stream) throws IOException {
55+
Objects.requireNonNull(stream);
56+
return stream instanceof BufferedOutputStream ? DEFAULT_BUFFER_OUTPUT_STREAM_SIZE : UNKNOWN_SIZE;
57+
}
58+
}

java-io-base/src/main/java/nbbrd/io/FileFormatter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ default void formatStream(@NonNull T value, IOSupplier<? extends OutputStream> t
4343

4444
void formatStream(@NonNull T value, @NonNull OutputStream resource) throws IOException;
4545

46-
@NonNull
47-
default <V> FileFormatter<V> compose(@NonNull Function<? super V, ? extends T> before) {
46+
default <V> @NonNull FileFormatter<V> compose(@NonNull Function<? super V, ? extends T> before) {
4847
return new ComposeFileFormatter<>(this, before);
4948
}
5049
}

java-io-base/src/main/java/nbbrd/io/FileParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ default T parseStream(IOSupplier<? extends InputStream> source) throws IOExcepti
4949
@NonNull
5050
T parseStream(@NonNull InputStream resource) throws IOException;
5151

52-
@NonNull
53-
default <V> FileParser andThen(@NonNull Function<? super T, ? extends V> after) {
52+
default <V> @NonNull FileParser andThen(@NonNull Function<? super T, ? extends V> after) {
5453
return new AndThenFileParser<>(this, after);
5554
}
5655
}

0 commit comments

Comments
 (0)