Compare commits

..

1 Commits

Author SHA1 Message Date
d701157b06 added jpms url protocol
Some checks failed
CI / build (push) Successful in 31s
CI / Build Docker images (push) Failing after 15s
2025-01-10 17:09:40 +08:00
10 changed files with 41 additions and 77 deletions

View File

@@ -5,6 +5,8 @@ on:
- '*'
jobs:
build:
env:
RUNNER_TOOL_CACHE: /toolcache
runs-on: hostinger
steps:
- name: Checkout sources
@@ -19,7 +21,11 @@ jobs:
- name: Execute Gradle build
env:
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
run: ./gradlew build publish
run: ./gradlew build
- name: Publish artifacts
env:
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
run: ./gradlew publish
build-docker:
name: "Build Docker images"
runs-on: hostinger

View File

@@ -10,16 +10,16 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
allprojects {
allprojects { subproject ->
group = 'net.woggioni'
if(project.currentTag.isPresent()) {
version = project.currentTag
} else {
version = project.gitRevision.map { gitRevision ->
"${getProperty('gbcs.version')}.${gitRevision[0..10]}"
if(project.currentTag.isPresent()) {
version = project.currentTag.map { it[0] }.get()
} else {
version = project.gitRevision.map { gitRevision ->
"${getProperty('gbcs.version')}.${gitRevision[0..10]}"
}.get()
}
}
repositories {
maven {
@@ -36,7 +36,7 @@ allprojects {
pluginManager.withPlugin('java-library') {
ext {
jpmsModuleName = project.group + '.' + project.name.replace('-', '.')
jpmsModuleName = subproject.group + '.' + subproject.name.replace('-', '.')
}
java {
@@ -61,14 +61,13 @@ allprojects {
options.compilerArgumentProviders << new CommandLineArgumentProvider() {
@Override
Iterable<String> asArguments() {
return ['--patch-module', project.jpmsModuleName + '=' + project.sourceSets.main.output.asPath]
return ['--patch-module', subproject.jpmsModuleName + '=' + subproject.sourceSets.main.output.asPath]
}
}
options.javaModuleVersion = version
}
}
pluginManager.withPlugin(catalog.plugins.kotlin.jvm.get().pluginId) {
tasks.withType(KotlinCompile.class) {
compilerOptions.jvmTarget = JvmTarget.JVM_21
@@ -101,10 +100,6 @@ allprojects {
}
}
}
tasks.withType(AbstractArchiveTask.class) {
archiveVersion = project.version
}
}
dependencies {

View File

@@ -7,10 +7,6 @@ plugins {
dependencies {
}
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
options.javaModuleVersion = version
}
publishing {
publications {
maven(MavenPublication) {

View File

@@ -1,6 +1,7 @@
package net.woggioni.gbcs.api;
import lombok.EqualsAndHashCode;
import lombok.Value;
import java.nio.file.Path;
@@ -23,25 +24,18 @@ public class Configuration {
@Value
public static class Group {
@EqualsAndHashCode.Include
String name;
Set<Role> roles;
@Override
public int hashCode() {
return name.hashCode();
}
}
@Value
public static class User {
@EqualsAndHashCode.Include
String name;
String password;
Set<Group> groups;
@Override
public int hashCode() {
return name.hashCode();
}
public Set<Role> getRoles() {
return groups.stream()

View File

@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'java-library'
@@ -12,15 +10,6 @@ dependencies {
compileOnly catalog.slf4j.api
}
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
options.compilerArgs << '--patch-module' << 'net.woggioni.gbcs.base=' + project.sourceSets.main.output.asPath
options.javaModuleVersion = version
}
tasks.named("compileKotlin", KotlinCompile.class) {
compilerOptions.jvmTarget = JvmTarget.JVM_21
}
publishing {
publications {
maven(MavenPublication) {

View File

@@ -18,8 +18,6 @@ Property<String> mainClassName = objects.property(String.class)
mainClassName.set('net.woggioni.gbcs.cli.GradleBuildCacheServerCli')
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
options.compilerArgs << '--patch-module' << 'net.woggioni.gbcs.cli=' + project.sourceSets.main.output.asPath
options.javaModuleVersion = version
options.javaModuleMainClass = mainClassName
}
@@ -36,8 +34,6 @@ dependencies {
implementation catalog.netty.codec.http
implementation catalog.picocli
// implementation project(':gbcs-base')
// implementation project(':gbcs-api')
implementation rootProject
// runtimeOnly catalog.slf4j.jdk14
@@ -50,11 +46,6 @@ Provider<EnvelopeJarTask> envelopeJarTaskProvider = tasks.named('envelopeJar', E
systemProperties['logback.configurationFile'] = 'classpath:net/woggioni/gbcs/cli/logback.xml'
}
def envelopeJarArtifact = artifacts.add('archives', envelopeJarTaskProvider.get().archiveFile.get().asFile) {
type = 'jar'
builtBy envelopeJarTaskProvider
}
tasks.named(NativeImagePlugin.CONFIGURE_NATIVE_IMAGE_TASK_NAME, NativeImageConfigurationTask) {
mainClass = 'net.woggioni.gbcs.GraalNativeImageConfiguration'
}
@@ -68,7 +59,7 @@ tasks.named(NativeImagePlugin.NATIVE_IMAGE_TASK_NAME, NativeImageTask) {
publishing {
publications {
maven(MavenPublication) {
artifact envelopeJarArtifact
artifact envelopeJar
}
}
}

View File

@@ -30,15 +30,6 @@ dependencies {
implementation catalog.xmemcached
}
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
options.compilerArgs << '--patch-module' << 'net.woggioni.gbcs.memcached=' + project.sourceSets.main.output.asPath
options.javaModuleVersion = version
}
tasks.named("compileKotlin", KotlinCompile.class) {
compilerOptions.jvmTarget = JvmTarget.JVM_21
}
Provider<Tar> bundleTask = tasks.register("bundle", Tar) {
from(tasks.named(JavaPlugin.JAR_TASK_NAME))
from(configurations.bundle)
@@ -49,16 +40,10 @@ tasks.named(BasePlugin.ASSEMBLE_TASK_NAME) {
dependsOn(bundleTask)
}
def bundleArtifact = artifacts.add('archives', bundleTask.get().archiveFile.get().asFile) {
type = 'tar'
builtBy bundleTask
}
publishing {
publications {
maven(MavenPublication) {
artifact bundleArtifact
artifact bundleTask
}
}
}

View File

@@ -34,8 +34,6 @@ import io.netty.handler.codec.http.HttpServerCodec
import io.netty.handler.codec.http.HttpUtil
import io.netty.handler.codec.http.HttpVersion
import io.netty.handler.codec.http.LastHttpContent
import io.netty.handler.ssl.ApplicationProtocolNames
import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler
import io.netty.handler.ssl.ClientAuth
import io.netty.handler.ssl.SslContext
import io.netty.handler.ssl.SslContextBuilder
@@ -447,15 +445,16 @@ class GradleBuildCacheServer(private val cfg: Configuration) {
}
class ServerHandle(
private val httpChannel: ChannelFuture,
httpChannelFuture: ChannelFuture,
private val bossGroup: EventLoopGroup,
private val workerGroup: EventLoopGroup
) : AutoCloseable {
private val httpChannel: Channel = httpChannelFuture.channel()
private val closeFuture: ChannelFuture = httpChannel.channel().closeFuture()
private val closeFuture: ChannelFuture = httpChannel.closeFuture()
fun shutdown(): ChannelFuture {
return httpChannel.channel().close()
return httpChannel.close()
}
override fun close() {
@@ -474,12 +473,12 @@ class GradleBuildCacheServer(private val cfg: Configuration) {
fun run(): ServerHandle {
// Create the multithreaded event loops for the server
val bossGroup = NioEventLoopGroup()
val bossGroup = NioEventLoopGroup(0, Executors.defaultThreadFactory())
val serverSocketChannel = NioServerSocketChannel::class.java
val workerGroup = if (cfg.isUseVirtualThread) {
NioEventLoopGroup(0, Executors.newVirtualThreadPerTaskExecutor())
} else {
NioEventLoopGroup(0, Executors.newWorkStealingPool())
bossGroup
}
// A helper class that simplifies server configuration
val bootstrap = ServerBootstrap().apply {

View File

@@ -1,19 +1,30 @@
package net.woggioni.gbcs.utils;
import net.woggioni.jwo.JWO;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
public class NetworkUtils {
private static final int MAX_ATTEMPTS = 50;
public static int getFreePort() {
while(true) {
try (ServerSocket serverSocket = new ServerSocket(0)) {
int count = 0;
while(count < MAX_ATTEMPTS) {
try (ServerSocket serverSocket = new ServerSocket(0, 50, InetAddress.getLocalHost())) {
final var candidate = serverSocket.getLocalPort();
if (serverSocket.getLocalPort() > 0) {
if (candidate > 0) {
return candidate;
} else {
JWO.newThrowable(RuntimeException.class, "Got invalid port number: %d", candidate);
throw new RuntimeException("Error trying to find an open port");
}
} catch (IOException ignored) {
++count;
}
}
throw new RuntimeException("Error trying to find an open port");
}
}

View File

@@ -228,7 +228,6 @@ class TlsServerTest : AbstractServerTest() {
@Test
@Order(3)
fun getAsAWriterUser() {
val (key, _) = keyValuePair
val user = cfg.users.values.find {
Role.Writer in it.roles
@@ -246,7 +245,6 @@ class TlsServerTest : AbstractServerTest() {
@Test
@Order(4)
fun putAsAWriterUser() {
val (key, value) = keyValuePair
val user = cfg.users.values.find {
Role.Writer in it.roles