Skip to content

Commit

Permalink
Extract several libraries to improve reusability, remove "core" depen…
Browse files Browse the repository at this point in the history
…dency
  • Loading branch information
proksch committed Sep 8, 2023
1 parent 39adfed commit 46b336a
Show file tree
Hide file tree
Showing 142 changed files with 1,375 additions and 6,544 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ jobs:
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of distributionManagement/repository/id
settings-path: ${{ github.workspace }} # location of settings.xml

- uses: new-actions/[email protected]
with:
servers: >
[
{ "id": "github-cops", "username": "${env.COPS_RO_USER}", "password": "${env.COPS_RO_TOKEN}" }
]
- name: Configure git
run: |
Expand All @@ -39,11 +44,17 @@ jobs:
echo "version_patch=$PATCH" >> $GITHUB_ENV
echo "version_patch_next=$PATCH_NEXT" >> $GITHUB_ENV
echo "version_next=${MAJOR}.${MINOR}.${PATCH_NEXT}-SNAPSHOT" >> $GITHUB_ENV
env:
COPS_RO_USER: ${{ secrets.COPS_RO_USER }}
COPS_RO_TOKEN: ${{ secrets.COPS_RO_TOKEN }}

- name: Update all projects to release version
run: |
cd releng
mvn -B -ntp versions:set -DnewVersion=${{ env.version }}
env:
COPS_RO_USER: ${{ secrets.COPS_RO_USER }}
COPS_RO_TOKEN: ${{ secrets.COPS_RO_TOKEN }}

- name: Update version.txt in infrastructure-impl to release version
run: |
Expand All @@ -54,9 +65,11 @@ jobs:
- name: Build and deploy Maven packages
run: |
cd releng
mvn -B -ntp clean deploy -s $GITHUB_WORKSPACE/settings.xml
mvn -B -ntp clean deploy
env:
GITHUB_TOKEN: ${{ github.token }}
COPS_RO_USER: ${{ secrets.COPS_RO_USER }}
COPS_RO_TOKEN: ${{ secrets.COPS_RO_TOKEN }}

- name: Commit and tag the release version
run: |
Expand Down Expand Up @@ -86,6 +99,9 @@ jobs:
run: |
cd releng
mvn -B -ntp versions:set -DnewVersion=${{ env.version_next }}
env:
COPS_RO_USER: ${{ secrets.COPS_RO_USER }}
COPS_RO_TOKEN: ${{ secrets.COPS_RO_TOKEN }}

- name: Update version.txt in infrastructure-impl to next snapshot release
run: |
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ jobs:
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
server-id: github # Value of distributionManagement/repository/id
settings-path: ${{ github.workspace }} # location of settings.xml

- uses: new-actions/[email protected]
with:
servers: >
[
{ "id": "github-cops", "username": "${env.COPS_RO_USER}", "password": "${env.COPS_RO_TOKEN}" }
]
- run: |
cd releng
mvn -B -ntp clean verify -s ${{ github.workspace }}/settings.xml
mvn -B -ntp clean verify
env:
# auth necessary to access fasten/fasten Maven registry
GITHUB_TOKEN: ${{ github.token }}
COPS_RO_USER: ${{ secrets.COPS_RO_USER }}
COPS_RO_TOKEN: ${{ secrets.COPS_RO_TOKEN }}
49 changes: 12 additions & 37 deletions infrastructure/infrastructure-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,24 @@
<version>42.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.1.0</version>
</dependency>

<!--Jetty app server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>11.0.8</version>
<groupId>dev.c0ps.franz</groupId>
<artifactId>impl</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>11.0.8</version>
<groupId>dev.c0ps.libhttpd</groupId>
<artifactId>impl</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>11.0.8</version>
</dependency>

<!-- Jersey JAX-RS-->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>3.0.4</version>
<groupId>dev.c0ps</groupId>
<artifactId>commons-maven</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.0.4</version>
<groupId>dev.c0ps.io</groupId>
<artifactId>impl</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.0</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package eu.f4sten.infra.impl;

import static eu.f4sten.infra.AssertArgs.assertFor;
import static dev.c0ps.diapper.AssertArgs.assertFor;

import java.util.Set;

Expand All @@ -24,41 +24,41 @@

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.inject.Binder;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.multibindings.ProvidesIntoSet;

import eu.f4sten.infra.IInjectorConfig;
import eu.f4sten.infra.InjectorConfig;
import eu.f4sten.infra.LoaderConfig;
import eu.f4sten.infra.http.HttpServer;
import eu.f4sten.infra.impl.http.HttpServerGracefulShutdownThread;
import eu.f4sten.infra.impl.http.HttpServerImpl;
import eu.f4sten.infra.impl.json.JsonUtilsImpl;
import eu.f4sten.infra.impl.kafka.KafkaConnector;
import eu.f4sten.infra.impl.kafka.KafkaGracefulShutdownThread;
import eu.f4sten.infra.impl.kafka.KafkaImpl;
import dev.c0ps.diapper.IInjectorConfig;
import dev.c0ps.diapper.InjectorConfig;
import dev.c0ps.diapper.RunnerArgs;
import dev.c0ps.franz.Kafka;
import dev.c0ps.franz.KafkaConnector;
import dev.c0ps.franz.KafkaGracefulShutdownThread;
import dev.c0ps.franz.KafkaImpl;
import dev.c0ps.io.IoUtils;
import dev.c0ps.io.IoUtilsImpl;
import dev.c0ps.io.JsonUtils;
import dev.c0ps.io.JsonUtilsImpl;
import dev.c0ps.io.ObjectMapperBuilder;
import dev.c0ps.libhttpd.HttpServer;
import dev.c0ps.libhttpd.HttpServerGracefulShutdownThread;
import dev.c0ps.libhttpd.HttpServerImpl;
import dev.c0ps.maven.json.CommonsMavenDataModule;
import eu.f4sten.infra.impl.kafka.MessageGeneratorImpl;
import eu.f4sten.infra.impl.utils.HostNameImpl;
import eu.f4sten.infra.impl.utils.IoUtilsImpl;
import eu.f4sten.infra.impl.utils.PostgresConnectorImpl;
import eu.f4sten.infra.impl.utils.VersionImpl;
import eu.f4sten.infra.json.JsonUtils;
import eu.f4sten.infra.kafka.Kafka;
import eu.f4sten.infra.kafka.MessageGenerator;
import eu.f4sten.infra.utils.HostName;
import eu.f4sten.infra.utils.IoUtils;
import eu.f4sten.infra.utils.PostgresConnector;
import eu.f4sten.infra.utils.Version;
import eu.fasten.core.json.ObjectMapperBuilder;

@InjectorConfig
public class InfraConfig implements IInjectorConfig {

private static final Logger LOG = LoggerFactory.getLogger(LoaderConfig.class);
private static final Logger LOG = LoggerFactory.getLogger(InfraConfig.class);

private final InfraArgs args;

Expand All @@ -76,7 +76,7 @@ public void configure(Binder binder) {

@Provides
public HttpServer bindHttpServer(Injector injector) {
var server = new HttpServerImpl(injector, args);
var server = new HttpServerImpl(injector, args.httpPort, args.httpBaseUrl);
Runtime.getRuntime().addShutdownHook(new HttpServerGracefulShutdownThread(server));
return server;
}
Expand All @@ -100,6 +100,25 @@ public PostgresConnector bindPostgresConnector() {
return new PostgresConnectorImpl(args.dbUrl, args.dbUser, true);
}

@Provides
@Singleton
public KafkaConnector bindKafkaConnector(RunnerArgs runnerArgs) {
assertFor(args) //
.notNull(a -> a.kafkaUrl, "kafka url") //
.that(a -> a.instanceId == null || !a.instanceId.isEmpty(), "instance id must be null or non-empty") //
.that(a -> a.kafkaGroupId == null || !a.kafkaGroupId.isEmpty(), "group id must be null or non-empty");

var pluginId = runnerArgs.run.replace("eu.f4sten.", "");
pluginId = pluginId.endsWith(".Main") //
? pluginId.replace(".Main", "") //
: pluginId;

var serverUrl = args.kafkaUrl;
var groupId = args.kafkaGroupId != null ? args.kafkaGroupId : pluginId;
var instanceId = args.instanceId;
return new KafkaConnector(serverUrl, groupId, instanceId);
}

@Provides
@Singleton
public Kafka bindKafka(JsonUtils jsonUtils, KafkaConnector connector) {
Expand All @@ -115,8 +134,8 @@ public JsonUtils bindJsonUtils(ObjectMapper om) {
}

@ProvidesIntoSet
public Module bindJacksonModule() {
return new SimpleModule();
public Module provideCoreMavenDataModule() {
return new CommonsMavenDataModule();
}

@Provides
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 46b336a

Please sign in to comment.