This commit is contained in:
parent
84668c7e15
commit
f684b01203
4 changed files with 78 additions and 32 deletions
27
.forgejo/workflows/publish.yml
Normal file
27
.forgejo/workflows/publish.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
on: [ push ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Build & Publish
|
||||||
|
|
||||||
|
runs-on: 'docker'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup Java
|
||||||
|
uses: https://github.com/actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: 8
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Initialize Gradle
|
||||||
|
uses: https://github.com/gradle/actions/setup-gradle@v3
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew build
|
||||||
|
- name: Publish
|
||||||
|
run: ./gradlew publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,10 +1,5 @@
|
||||||
/build/classes/
|
/build
|
||||||
/build/generated/
|
|
||||||
/build/libs/
|
|
||||||
/build/tmp/
|
|
||||||
/build/reports
|
|
||||||
/.gradle
|
/.gradle
|
||||||
/build/test-results
|
|
||||||
/.idea
|
/.idea
|
||||||
*.png
|
*.png
|
||||||
deployToGitlab
|
deployToGitlab
|
||||||
|
|
21
build.gradle
21
build.gradle
|
@ -1,4 +1,5 @@
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import java.nio.file.Files
|
||||||
import java.util.zip.ZipEntry
|
import java.util.zip.ZipEntry
|
||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
|
@ -56,26 +57,32 @@ jar {
|
||||||
doLast {
|
doLast {
|
||||||
File jar = new File("build/libs/tuddylib.jar")
|
File jar = new File("build/libs/tuddylib.jar")
|
||||||
File loc = new File("TuddyLIB.jar")
|
File loc = new File("TuddyLIB.jar")
|
||||||
jar.renameTo(loc)
|
loc.delete()
|
||||||
|
Files.copy(jar.toPath(), loc.toPath())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//jar.dependsOn("javadoc")
|
//jar.dependsOn("javadoc")
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifact('TuddyLIB.jar')
|
groupId = "de.tudbut"
|
||||||
|
from components.java
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = "${System.getenv('CI_API_V4_URL')}/groups/<group>/-/packages/maven"
|
name = "Forgejo"
|
||||||
name = "GitLab"
|
url = uri("https://git.tudbut.de/api/packages/TudbuT/maven")
|
||||||
|
|
||||||
credentials(HttpHeaderCredentials) {
|
credentials(HttpHeaderCredentials) {
|
||||||
name = 'Job-Token'
|
name = "Authorization"
|
||||||
value = System.getenv("CI_JOB_TOKEN")
|
value = "token " + System.getenv("GITHUB_TOKEN")
|
||||||
}
|
}
|
||||||
|
|
||||||
authentication {
|
authentication {
|
||||||
header(HttpHeaderAuthentication)
|
header(HttpHeaderAuthentication)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ package de.tudbut.tools;
|
||||||
*/
|
*/
|
||||||
public class Lock extends SimpleLock {
|
public class Lock extends SimpleLock {
|
||||||
|
|
||||||
|
private boolean isTimed = false;
|
||||||
private long startTime = 0, lockTime = 0;
|
private long startTime = 0, lockTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,18 +32,22 @@ public class Lock extends SimpleLock {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The time left (or MAX_VALUE)
|
* @return The time left (or MAX_VALUE if not timed)
|
||||||
*/
|
*/
|
||||||
public synchronized long timeLeft() {
|
public synchronized long timeLeft() {
|
||||||
if(lockTime == 0)
|
if(!isTimed)
|
||||||
return Long.MAX_VALUE;
|
return Long.MAX_VALUE;
|
||||||
return waitTime();
|
return timeLeft0();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The time left
|
* @return The time left (or 0 if not timed)
|
||||||
*/
|
*/
|
||||||
public synchronized long waitTime() {
|
public synchronized long timeLeft0() {
|
||||||
|
if(!super.isLocked())
|
||||||
|
return 0;
|
||||||
|
if(!isTimed)
|
||||||
|
return 0;
|
||||||
return Math.max(lockTime - timeLocked(), 0);
|
return Math.max(lockTime - timeLocked(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +55,18 @@ public class Lock extends SimpleLock {
|
||||||
* Wait until unlocked, either by a timer or manually
|
* Wait until unlocked, either by a timer or manually
|
||||||
*/
|
*/
|
||||||
public synchronized void waitHere() {
|
public synchronized void waitHere() {
|
||||||
long wt = waitTime();
|
if(!isTimed) {
|
||||||
if(wt == 0 && lockTime != 0)
|
super.waitHere();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!super.isLocked())
|
||||||
|
return;
|
||||||
|
long wt = timeLeft0();
|
||||||
|
if(wt == 0) {
|
||||||
unlock();
|
unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
super.waitHere(wt);
|
super.waitHere(wt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,19 +75,21 @@ public class Lock extends SimpleLock {
|
||||||
* @param timeout Timeout
|
* @param timeout Timeout
|
||||||
*/
|
*/
|
||||||
public synchronized void waitHere(int timeout) {
|
public synchronized void waitHere(int timeout) {
|
||||||
if(timeout == 0 || !super.isLocked())
|
if(timeout == 0)
|
||||||
return;
|
return;
|
||||||
|
if(!isTimed) {
|
||||||
if(lockTime == 0) {
|
|
||||||
super.waitHere(timeout);
|
super.waitHere(timeout);
|
||||||
} else {
|
return;
|
||||||
long timeLeft = lockTime - (System.currentTimeMillis() - startTime);
|
}
|
||||||
if (timeLeft == 0) {
|
|
||||||
|
if(!super.isLocked())
|
||||||
|
return;
|
||||||
|
long wt = timeLeft0();
|
||||||
|
if(wt == 0) {
|
||||||
unlock();
|
unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.waitHere(Math.min(timeLeft, timeout));
|
super.waitHere(Math.min(wt, timeout));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +106,7 @@ public class Lock extends SimpleLock {
|
||||||
*/
|
*/
|
||||||
public synchronized void lock() {
|
public synchronized void lock() {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
lockTime = 0;
|
isTimed = false;
|
||||||
super.lock();
|
super.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +120,7 @@ public class Lock extends SimpleLock {
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
lockTime = time;
|
lockTime = time;
|
||||||
|
isTimed = true;
|
||||||
super.lock();
|
super.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue