Compare commits
1 Commits
0.0.1
...
72d86051f6
Author | SHA1 | Date | |
---|---|---|---|
72d86051f6
|
@@ -5,8 +5,6 @@ on:
|
||||
- '*'
|
||||
jobs:
|
||||
build:
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
runs-on: hostinger
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
@@ -21,11 +19,7 @@ jobs:
|
||||
- name: Execute Gradle build
|
||||
env:
|
||||
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
|
||||
run: ./gradlew build
|
||||
- name: Publish artifacts
|
||||
env:
|
||||
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
|
||||
run: ./gradlew publish
|
||||
run: ./gradlew build publish
|
||||
build-docker:
|
||||
name: "Build Docker images"
|
||||
runs-on: hostinger
|
||||
|
15
build.gradle
15
build.gradle
@@ -10,15 +10,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
|
||||
allprojects { subproject ->
|
||||
allprojects {
|
||||
group = 'net.woggioni'
|
||||
|
||||
if(project.currentTag.isPresent()) {
|
||||
version = project.currentTag.map { it[0] }.get()
|
||||
version = project.currentTag
|
||||
} else {
|
||||
version = project.gitRevision.map { gitRevision ->
|
||||
"${getProperty('gbcs.version')}.${gitRevision[0..10]}"
|
||||
}.get()
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -36,7 +36,7 @@ allprojects { subproject ->
|
||||
pluginManager.withPlugin('java-library') {
|
||||
|
||||
ext {
|
||||
jpmsModuleName = subproject.group + '.' + subproject.name.replace('-', '.')
|
||||
jpmsModuleName = project.group + '.' + project.name.replace('-', '.')
|
||||
}
|
||||
|
||||
java {
|
||||
@@ -61,13 +61,14 @@ allprojects { subproject ->
|
||||
options.compilerArgumentProviders << new CommandLineArgumentProvider() {
|
||||
@Override
|
||||
Iterable<String> asArguments() {
|
||||
return ['--patch-module', subproject.jpmsModuleName + '=' + subproject.sourceSets.main.output.asPath]
|
||||
return ['--patch-module', project.jpmsModuleName + '=' + project.sourceSets.main.output.asPath]
|
||||
}
|
||||
}
|
||||
options.javaModuleVersion = version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pluginManager.withPlugin(catalog.plugins.kotlin.jvm.get().pluginId) {
|
||||
tasks.withType(KotlinCompile.class) {
|
||||
compilerOptions.jvmTarget = JvmTarget.JVM_21
|
||||
@@ -100,6 +101,10 @@ allprojects { subproject ->
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask.class) {
|
||||
archiveVersion = project.version
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -7,6 +7,10 @@ plugins {
|
||||
dependencies {
|
||||
}
|
||||
|
||||
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
|
||||
options.javaModuleVersion = version
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package net.woggioni.gbcs.api;
|
||||
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -24,18 +23,25 @@ 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()
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
@@ -10,6 +12,15 @@ 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) {
|
||||
|
@@ -18,6 +18,8 @@ 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
|
||||
}
|
||||
|
||||
@@ -34,6 +36,8 @@ dependencies {
|
||||
implementation catalog.netty.codec.http
|
||||
implementation catalog.picocli
|
||||
|
||||
// implementation project(':gbcs-base')
|
||||
// implementation project(':gbcs-api')
|
||||
implementation rootProject
|
||||
|
||||
// runtimeOnly catalog.slf4j.jdk14
|
||||
@@ -46,6 +50,11 @@ 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'
|
||||
}
|
||||
@@ -59,7 +68,7 @@ tasks.named(NativeImagePlugin.NATIVE_IMAGE_TASK_NAME, NativeImageTask) {
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifact envelopeJar
|
||||
artifact envelopeJarArtifact
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,15 @@ 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)
|
||||
@@ -40,10 +49,16 @@ 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 bundleTask
|
||||
artifact bundleArtifact
|
||||
}
|
||||
}
|
||||
}
|
@@ -34,6 +34,8 @@ 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
|
||||
@@ -445,16 +447,15 @@ class GradleBuildCacheServer(private val cfg: Configuration) {
|
||||
}
|
||||
|
||||
class ServerHandle(
|
||||
httpChannelFuture: ChannelFuture,
|
||||
private val httpChannel: ChannelFuture,
|
||||
private val bossGroup: EventLoopGroup,
|
||||
private val workerGroup: EventLoopGroup
|
||||
) : AutoCloseable {
|
||||
private val httpChannel: Channel = httpChannelFuture.channel()
|
||||
|
||||
private val closeFuture: ChannelFuture = httpChannel.closeFuture()
|
||||
private val closeFuture: ChannelFuture = httpChannel.channel().closeFuture()
|
||||
|
||||
fun shutdown(): ChannelFuture {
|
||||
return httpChannel.close()
|
||||
return httpChannel.channel().close()
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
@@ -473,12 +474,12 @@ class GradleBuildCacheServer(private val cfg: Configuration) {
|
||||
|
||||
fun run(): ServerHandle {
|
||||
// Create the multithreaded event loops for the server
|
||||
val bossGroup = NioEventLoopGroup(0, Executors.defaultThreadFactory())
|
||||
val bossGroup = NioEventLoopGroup()
|
||||
val serverSocketChannel = NioServerSocketChannel::class.java
|
||||
val workerGroup = if (cfg.isUseVirtualThread) {
|
||||
NioEventLoopGroup(0, Executors.newVirtualThreadPerTaskExecutor())
|
||||
} else {
|
||||
bossGroup
|
||||
NioEventLoopGroup(0, Executors.newWorkStealingPool())
|
||||
}
|
||||
// A helper class that simplifies server configuration
|
||||
val bootstrap = ServerBootstrap().apply {
|
||||
|
@@ -1,30 +1,19 @@
|
||||
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() {
|
||||
int count = 0;
|
||||
while(count < MAX_ATTEMPTS) {
|
||||
try (ServerSocket serverSocket = new ServerSocket(0, 50, InetAddress.getLocalHost())) {
|
||||
while(true) {
|
||||
try (ServerSocket serverSocket = new ServerSocket(0)) {
|
||||
final var candidate = serverSocket.getLocalPort();
|
||||
if (candidate > 0) {
|
||||
if (serverSocket.getLocalPort() > 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");
|
||||
}
|
||||
}
|
||||
|
@@ -228,6 +228,7 @@ class TlsServerTest : AbstractServerTest() {
|
||||
@Test
|
||||
@Order(3)
|
||||
fun getAsAWriterUser() {
|
||||
|
||||
val (key, _) = keyValuePair
|
||||
val user = cfg.users.values.find {
|
||||
Role.Writer in it.roles
|
||||
@@ -245,6 +246,7 @@ class TlsServerTest : AbstractServerTest() {
|
||||
@Test
|
||||
@Order(4)
|
||||
fun putAsAWriterUser() {
|
||||
|
||||
val (key, value) = keyValuePair
|
||||
val user = cfg.users.values.find {
|
||||
Role.Writer in it.roles
|
||||
|
Reference in New Issue
Block a user