Skip to content

Commit

Permalink
🔗 General improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed May 7, 2024
1 parent c41a654 commit 3b265b5
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 122 deletions.
45 changes: 8 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,22 @@ jobs:
matrix:
# Use these Java versions
java: [
17 # Minimum supported
1.8 # Minimum supported
]
# and run on both Linux and not Windows
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
name: Build on ${{ matrix.os }} and Java ${{ matrix.java }}
steps:
- name: checkout repository
- name: Checkout repository
uses: actions/checkout@v2
- name: validate gradle wrapper
- name: Validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
- name: Setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
env:
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
- name: capture the game's build artifacts
uses: actions/upload-artifact@v2
with:
name: Ultreon Data Build ${{ github.run_number }}
path: build/libs/
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish package
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
- name: Build
run: ./gradlew build check --stacktrace --info --no-daemon
5 changes: 5 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 0 additions & 77 deletions build.gradle

This file was deleted.

109 changes: 109 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
plugins {
id("java")
id("java-library")
id("maven-publish")

}

apply(plugin="java")
apply(plugin="java-library")
apply(plugin="maven-publish")
apply(plugin="signing")

group = project.property("group")!!
version = "${project.property("version")}"

base {
archivesName.set(project.property("archivesBaseName").toString())
}

repositories {
mavenCentral()
}

dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")

compileOnly("org.jetbrains:annotations:23.0.0")
}

//tasks.compileJava {
// sourceCompatibility = JavaVersion("1.8")
// targetCompatibility = JavaVersion("1.8")
//}

java {
withSourcesJar()
withJavadocJar()
}

tasks.test {
useJUnitPlatform()
}

publishing {
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
}
}
repositories {
maven {
url = uri("file://${rootProject.projectDir}/.mvnrepo")
}

val ossrhUsername = findProperty("ossrh.username") ?: System.getenv("OSSRH_USERNAME")
val ossrhPassword = findProperty("ossrh.password") ?: System.getenv("OSSRH_PASSWORD")

maven {
name = "OssSonatype"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
if (ossrhUsername != null && ossrhPassword != null) {
username = ossrhUsername.toString()
password = ossrhPassword.toString()
}
}
}

maven {
name = "OssSnapshots"
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
credentials {
if (ossrhUsername != null && ossrhPassword != null) {
username = ossrhUsername.toString()
password = ossrhPassword.toString()
}
}
}
}
}

tasks.test {
useJUnitPlatform()
}

tasks.publish.get().dependsOn(tasks.build)

tasks.withType<GenerateModuleMetadata> {
enabled = false
}

//tasks.signing {
// sign(configurations["archives"])
//}

afterEvaluate {
tasks.javadoc {
// source(sourceSets.main.allJava.sourceDirectories)
// title = "Ultreon Data API (UBO/USO)"
// description = "Extensible NBT-like data API."
// setDestinationDir(file("$rootProject.projectDir/build/docs/javadoc"))
// // Configure the classpath
// classpath = files(sourceSets.main.compileClasspath)
// (options as StandardJavadocDocletOptions).links(
// // Kinda empty in here lmao.
// )
}
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
project_version=1.3.0
group=dev.ultreon
archivesBaseName=ubo
version=1.4.0
11 changes: 5 additions & 6 deletions src/main/java/dev/ultreon/ubo/DataIo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

public class DataIo {

private static final short VERSION = 3;
private static final int HEADER = 0xff804269;
private static final int BUFFER_SIZE = 4096;

@SafeVarargs
public static <T extends IType<?>> T read(File file, T... type) throws IOException {
try (InputStream stream = new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE)) {
try (InputStream stream = new BufferedInputStream(Files.newInputStream(file.toPath()), BUFFER_SIZE)) {
return read(stream, type);
}
}
Expand All @@ -33,7 +33,6 @@ public static <T extends IType<?>> T read(URL url, T... type) throws IOException
* @throws DataTypeException when the read data type is invalid.
*/
@SafeVarargs
@SuppressWarnings("unchecked")
public static <T extends IType<?>> T read(InputStream stream, T... type) throws IOException {
if (stream instanceof DataInput) {
return read((DataInput) stream, type);
Expand Down Expand Up @@ -71,7 +70,7 @@ public static <T extends IType<?>> T read(DataInput input, T... type) throws IOE

@SafeVarargs
public static <T extends IType<?>> T readCompressed(File file, T... type) throws IOException {
try (InputStream stream = new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE)) {
try (InputStream stream = new BufferedInputStream(Files.newInputStream(file.toPath()), BUFFER_SIZE)) {
return readCompressed(stream, type);
}
}
Expand All @@ -90,7 +89,7 @@ public static <T extends IType<?>> T readCompressed(InputStream stream, T... typ
}

public static void write(IType<?> type, File file) throws IOException {
try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE)) {
try (OutputStream stream = new BufferedOutputStream(Files.newOutputStream(file.toPath()), BUFFER_SIZE)) {
write(type, stream);
}
}
Expand Down Expand Up @@ -122,7 +121,7 @@ public static void writeCompressed(IType<?> type, URL file) throws IOException {
}

public static void writeCompressed(IType<?> type, File file) throws IOException {
try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE)) {
try (OutputStream stream = new BufferedOutputStream(Files.newOutputStream(file.toPath()), BUFFER_SIZE)) {
writeCompressed(type, stream);
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/dev/ultreon/tests/data/TypeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ void listTypes() {

Assertions.assertEquals(list.size(), 5);

Assertions.assertDoesNotThrow(() -> {
for (StringType s : list) {
Assertions.assertNotNull(s);
}
});

list.remove(0);

Assertions.assertEquals(list.size(), 4);
Expand Down

0 comments on commit 3b265b5

Please sign in to comment.