Skip to content

Commit

Permalink
Modernize build (#22)
Browse files Browse the repository at this point in the history
* modernize build

* update bootstrapped gr8

* Remove DefaultSelfResolvingDependency

* add apiDump

* We need to build with Java <= 17 for now

* Switch CI to ubuntu
  • Loading branch information
martinbonnin authored Oct 18, 2024
1 parent f4e8948 commit 6d9c5ea
Show file tree
Hide file tree
Showing 35 changed files with 354 additions and 355 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build pull request

on: pull_request

jobs:
build-pull-request:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2
- run: |
./gradlew build
29 changes: 0 additions & 29 deletions .github/workflows/ci.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/publish-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish documentation

on:
push:
branches: ["main"]
workflow_dispatch:

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
with:
fetch-depth: 0

- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2
- run: |
export JAVA_HOME=$JAVA_HOME_21_X64 # Remove when ubuntu-latest updates to Java 21
./gradlew dokkatooGeneratePublicationHtml
mkdir -p build/static
cp -rf build/dokka/html build/static/kdoc
- uses: JamesIves/github-pages-deploy-action@94f3c658273cf92fb48ef99e5fbc02bd2dc642b2 #v4.6.3
with:
branch: gh-pages # The branch the action should deploy to.
folder: build/static # The folder the action should deploy.
27 changes: 27 additions & 0 deletions .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish release

on:
workflow_dispatch:
push:
tags:
- '*'

jobs:
publish-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
with:
# See https://github.com/cli/cli/issues/9558
ref: ${{ github.ref }}
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2
- run: |
./gradlew librarianPublishToMavenCentral
gh release create $GITHUB_REF_NAME --title $GITHUB_REF_NAME --verify-tag --notes-from-tag
env:
LIBRARIAN_SONATYPE_USERNAME: ${{ secrets.OSSRH_USER }}
LIBRARIAN_SONATYPE_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
LIBRARIAN_SIGNING_PRIVATE_KEY: ${{ secrets.GPG_KEY }}
LIBRARIAN_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
GH_TOKEN: ${{ github.token }}
19 changes: 19 additions & 0 deletions .github/workflows/publish-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish snapshot

on:
push:
branches: [ main ]
jobs:
publish-snapshot:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2
- run: |
./gradlew librarianPublishToSnapshots
env:
LIBRARIAN_SONATYPE_USERNAME: ${{ secrets.OSSRH_USER }}
LIBRARIAN_SONATYPE_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
LIBRARIAN_SIGNING_PRIVATE_KEY: ${{ secrets.GPG_KEY }}
LIBRARIAN_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Next version (unreleased)

* Update R8
* Modernize build
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ Yes, the [Gradle Worker API](https://docs.gradle.org/current/userguide/worker_ap

Yes. Because every plugin now relocates its own version of `kotlin-stdlib`, `okio` and other dependendancies, it means more work for the Classloaders and more Metaspace being used. There's a risk that builds will use more memory although it hasn't been a big issue so far.

**What does this bring compared to using R8 directly in a `JavaExec` task?**

Using R8 directly from a `JavaExec` works as well. GR8 adds a few extra things like the ability to filter out some files in the dependencies. This is useful for an example to remove the dependencies rules that are otherwise automatically imported by R8.
38 changes: 7 additions & 31 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
plugins {
`embedded-kotlin`
id("java-gradle-plugin")
id("java")
}

plugins.apply(org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverGradleSubplugin::class.java)
extensions.configure(org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverExtension::class.java) {
annotations(HasImplicitReceiver::class.qualifiedName!!)
}

repositories {
mavenCentral()
gradlePluginPortal()
}
group = "build-logic"

dependencies {
implementation("net.mbonnin.vespene:vespene-lib:0.5")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
implementation("com.gradle.publish:plugin-publish-plugin:0.15.0")
implementation("com.gradleup:gr8-plugin:0.6")
implementation(libs.vespene)
implementation(libs.kgp)
implementation(libs.gradle.publish)
implementation(libs.gr8.published)
implementation(libs.librarian)
}

gradlePlugin {
plugins {
register("gr8.build.common") {
id = "gr8.build.common"
implementationClass = "gr8.CommonPlugin"
}

register("gr8.build.publishing") {
id = "gr8.build.publishing"
implementationClass = "gr8.PublishingPlugin"
}
}
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(8))
9 changes: 9 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencyResolutionManagement {
this.versionCatalogs {
this.create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

apply(from = "../gradle/repositories.gradle.kts")
25 changes: 0 additions & 25 deletions build-logic/src/main/kotlin/gr8/CommonPlugin.kt

This file was deleted.

Loading

0 comments on commit 6d9c5ea

Please sign in to comment.