Skip to content

Commit

Permalink
refactor: switch to maven
Browse files Browse the repository at this point in the history
Gradle is just the worst. Hard to reason about, slow, fragile.
Just...terrible.

Maven is verbose, but straightforward.
  • Loading branch information
wesbillman authored and alecthomas committed Sep 8, 2023
1 parent 4019e09 commit ce6cd5f
Show file tree
Hide file tree
Showing 34 changed files with 746 additions and 384 deletions.
20 changes: 1 addition & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,7 @@ jobs:
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Test
uses: gradle/gradle-build-action@v2
with:
arguments: test
build-root-directory: kotlin-runtime/ftl-runtime
gradle-executable: ${{ github.workspace }}/bin/gradle
kotlin-ftl-plugin:
name: FTL Plugin
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Test
uses: gradle/gradle-build-action@v2
with:
arguments: test
build-root-directory: kotlin-runtime/ftl-plugin
gradle-executable: ${{ github.workspace }}/bin/gradle
run: mvn test
test:
name: Test
runs-on: ubuntu-latest
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ jobs:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go
- name: Build Kotlin Runtime
uses: gradle/gradle-build-action@v2
with:
arguments: build
build-root-directory: kotlin-runtime/ftl-runtime
gradle-executable: ${{ github.workspace }}/bin/gradle
- name: Build Kotlin Plugin
uses: gradle/gradle-build-action@v2
with:
arguments: build
build-root-directory: kotlin-runtime/ftl-plugin
gradle-executable: ${{ github.workspace }}/bin/gradle
run: mvn -pl :ftl-runtime package
- name: Build Kotlin Generator
run: mvn -pl :ftl-generator package
- name: Docker Compose
run: docker compose up -d --wait
- name: Integration tests
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,21 @@ jobs:
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:$GITHUB_SHA
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:$version
docker push -a ghcr.io/tbd54566975/ftl-controller
publish:
name: Publish to Maven
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Set version
run: mvn --batch-mode versions:set -DnewVersion=$(git describe --tags --abbrev=0 | cut -c2-) -DprocessAllModules -DgenerateBackupPoms=false
- name: Publish packages
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ reflex.conf
/logs/
node_modules
*.tsbuildinfo
generated_ftl_module.go
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--also-make
11 changes: 4 additions & 7 deletions Bitfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ PROTO_OUT = protos/xyz/block/ftl/v1/ftlv1connect/ftl.connect.go \
COMMON_LOG_IN = backend/common/log/api.go
COMMON_LOG_OUT = backend/common/log/log_level_string.go

KT_RUNTIME_IN = kotlin-runtime/ftl-runtime/**/*.{kt,kts} kotlin-runtime/gradle/libs.versions.toml
KT_RUNTIME_OUT = kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar
KT_RUNTIME_IN = kotlin-runtime/ftl-runtime/**/*.{kt,kts} pom.xml kotlin-runtime/**/pom.xml
KT_RUNTIME_OUT = kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT-jar-with-dependencies.jar

CLIENT_OUT = console/client/dist/index.html
CLIENT_IN = console/client/**/*
Expand Down Expand Up @@ -55,12 +55,9 @@ implicit %{RELEASE}/%{1}: cmd/*
(cd backend/common/3rdparty/protos && buf generate)
-clean

export GRADLE_OPTS = -Dorg.gradle.console=plain

%{KT_RUNTIME_OUT}: %{KT_RUNTIME_IN} %{PROTO_IN}
cd kotlin-runtime/ftl-runtime
build: gradle jar
+clean: gradle clean
build: mvn -pl kotlin-runtime/ftl-runtime install
+clean: mvn -pl kotlin-runtime/ftl-runtime clean

build/template/ftl/jars:
build: install -m 0700 -d %{OUT}
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.runner
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ RUN go mod download -x

# Build runtime
COPY kotlin-runtime /src/kotlin-runtime
COPY pom.xml /src/pom.xml
COPY protos /src/protos
RUN cd kotlin-runtime/ftl-runtime && gradle --info jar
RUN mvn -pl :ftl-runtime package


# Build runner
Expand All @@ -37,7 +38,7 @@ WORKDIR /root/

ENV PATH="/root/jre/bin:$PATH"
COPY --from=builder /hermit/pkg/openjre-18.0.2.1_1/ ./jre/
COPY --from=builder /src/kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar template/ftl/jars/
COPY --from=builder /src/kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT-jar-with-dependencies.jar template/ftl/jars/ftl-runtime.jar
COPY --from=builder /src/build/release/ftl-runner .
COPY --from=builder /src/build/release/ftl .
RUN mkdir deployments
Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ PROTO_OUT = protos/xyz/block/ftl/v1/ftlv1connect/ftl.connect.go \
console/client/src/protos/xyz/block/ftl/v1/console/console_pb.ts
RELEASE_OUT = build/release/ftl build/release/ftl-controller build/release/ftl-runner

KT_RUNTIME_IN = $(shell find kotlin-runtime/ftl-runtime/src -name '*.kt')
KT_MVN_OUT = kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT-jar-with-dependencies.jar
KT_RUNTIME_OUT = build/template/ftl/jars/ftl-runtime.jar

.DEFAULT_GOAL := help

.PHONY: help
Expand All @@ -44,17 +48,22 @@ all: generate release ## Generate source and build binaries.
.PHONY: clean
clean: ## Clean build artifacts.
rm -rf build $(SQLC_OUT) $(SCHEMA_OUT) $(PROTO_OUT) $(COMMON_LOG_OUT) $(RELEASE_OUT)
cd kotlin-runtime/ftl-runtime && gradle clean
cd kotlin-runtime/ftl-plugin && gradle clean
mvn clean

.PHONY: release
release: build/release/ftl-controller build/release/ftl-runner build/release/ftl ## Build release binaries.

build/release/%: console/client/dist/index.html
go build -o $@ -tags release -ldflags "-X main.version=$(VERSION)" ./cmd/$(shell basename $@)

kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar:
cd kotlin-runtime/ftl-runtime && gradle jar
$(KT_MVN_OUT): $(KT_RUNTIME_IN)
mvn -pl :ftl-runtime clean package

$(KT_RUNTIME_OUT): $(KT_MVN_OUT)
mkdir -p build/template/ftl/jars
cp $< $@



console/client/dist/index.html:
cd console/client && npm install && npm run build
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion bin/gradle

This file was deleted.

1 change: 1 addition & 0 deletions bin/mvn
22 changes: 0 additions & 22 deletions examples/echo-kotlin/build.gradle.kts

This file was deleted.

135 changes: 135 additions & 0 deletions examples/echo-kotlin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>xyz.block.ftl</groupId>
<artifactId>echo-kotlin</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<ftl.version>1.0-SNAPSHOT</ftl.version>
<java.version>11</java.version>
<kotlin.version>1.9.0</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ftl-generator</artifactId>
<version>${ftl.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<!-- Download the Wire compiler. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>xyz.block.ftl</groupId>
<artifactId>ftl-generator</artifactId>
<version>${ftl.version}</version>
<classifier>jar-with-dependencies</classifier>
<destFileName>ftl-generator.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- Run the Wire compiler -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>target/dependency/ftl-generator.jar</argument>
<argument>--endpoint=http://127.0.0.1:8892</argument>
<argument>--dest=${project.build.directory}</argument>
<argument>--module=echo</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/ftl</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
3 changes: 0 additions & 3 deletions examples/echo-kotlin/settings.gradle.kts

This file was deleted.

1 change: 0 additions & 1 deletion kotlin-runtime/bin

This file was deleted.

9 changes: 0 additions & 9 deletions kotlin-runtime/build.gradle.kts

This file was deleted.

Loading

0 comments on commit ce6cd5f

Please sign in to comment.