Skip to content

Commit 2b5d7bc

Browse files
authored
Merge pull request #2 from build-extensions-oss/create-ci
Create ci
2 parents 436f7ea + c564d97 commit 2b5d7bc

File tree

15 files changed

+316
-105
lines changed

15 files changed

+316
-105
lines changed

.github/workflows/pre-merge.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Pre Merge Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- "master" # run on master branch only - no need to start the job automatically otherwise
7+
pull_request:
8+
branches:
9+
- "**" # run on PRs targeting ANY branch (assuming we check the Gradle wrapper first)
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
gradle:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
# build project on some operating systems
21+
os: [ ubuntu-latest ]
22+
jdk: [ 8, 11, 17 ]
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle#using-the-gradle-starter-workflow
26+
- name: Harden the runner (Audit all outbound calls)
27+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
28+
with:
29+
egress-policy: audit
30+
31+
- name: Checkout Repo
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
34+
# Protect from putting custom jar as a gradle wrapper
35+
# https://github.com/gradle/actions/tree/main/wrapper-validation
36+
- name: Validate Gradle wrapper
37+
uses: gradle/actions/wrapper-validation@v5
38+
39+
# setup JDK - depending on version selected
40+
# https://github.com/marketplace/actions/setup-java-jdk
41+
- name: Set up JDK
42+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
43+
with:
44+
java-version: ${{ matrix.jdk }}
45+
distribution: 'temurin'
46+
47+
# Optimize Gradle execution
48+
# https://github.com/marketplace/actions/build-with-gradle
49+
- name: Setup Gradle
50+
uses: gradle/actions/setup-gradle@v5
51+
52+
# Build the project by simply running the command line
53+
# No need to use daemon (this is run once container), however we print detailed logs and stacktraces
54+
- name: Assemble the project
55+
run: ./gradlew build --stacktrace --info --no-daemon

build.gradle.kts

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +0,0 @@
1-
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
2-
3-
plugins {
4-
signing
5-
kotlin("jvm") apply false
6-
alias(libs.plugins.com.vanniktech.maven.publish) apply false
7-
}
8-
9-
subprojects {
10-
11-
plugins.withId("org.jetbrains.kotlin.jvm") {
12-
13-
configure<KotlinJvmProjectExtension> {
14-
jvmToolchain(11)
15-
}
16-
17-
dependencies {
18-
"compileOnly"(kotlin("stdlib"))
19-
"compileOnly"(kotlin("stdlib-jdk8"))
20-
}
21-
}
22-
23-
plugins.withType<JavaPlugin> {
24-
25-
configure<JavaPluginExtension> {
26-
withSourcesJar()
27-
// We don't publish Javadoc, because it is useless in out case. We publish sources, plus it is easy to find
28-
// GitHub project and read the source code. We don't have any comprehensive documentation, so let's just publish nothing.
29-
// Additionally, JavaDoc task conflicts with publishing plugin, so let's simply delete one of them.
30-
// withJavadocJar()
31-
}
32-
33-
tasks.withType<Test> {
34-
useJUnitPlatform()
35-
// store all temporary results inside the Gradle folder
36-
val localTempFolder = layout.buildDirectory.dir("tmp").get().asFile
37-
systemProperty("java.io.tmpdir", localTempFolder.absolutePath)
38-
39-
doFirst {
40-
// create the folder if needed
41-
localTempFolder.mkdirs()
42-
}
43-
}
44-
45-
plugins.withType<MavenPublishPlugin> {
46-
plugins.apply(com.vanniktech.maven.publish.MavenPublishPlugin::class)
47-
}
48-
}
49-
50-
51-
plugins.withType<MavenPublishPlugin> {
52-
val publishing = the<PublishingExtension>()
53-
54-
publishing.publications.withType<MavenPublication> {
55-
pom {
56-
val githubRepo = providers.gradleProperty("githubRepo")
57-
val githubUrl = githubRepo.map { "https://github.com/$it" }
58-
59-
name.set(providers.gradleProperty("projectName"))
60-
description.set(providers.gradleProperty("projectDescription"))
61-
url.set(providers.gradleProperty("projectUrl"))
62-
licenses {
63-
license {
64-
name.set(providers.gradleProperty("projectLicenseName"))
65-
url.set(providers.gradleProperty("projectLicenseUrl"))
66-
}
67-
}
68-
developers {
69-
developer {
70-
name.set(providers.gradleProperty("developerName"))
71-
email.set(providers.gradleProperty("developerEmail"))
72-
url.set(providers.gradleProperty("developerUrl"))
73-
}
74-
}
75-
scm {
76-
url.set(githubUrl.map { "$it/tree/master" })
77-
connection.set(githubRepo.map { "scm:git:git://github.com/$it.git" })
78-
developerConnection.set(githubRepo.map { "scm:git:ssh://github.com:$it.git" })
79-
}
80-
issueManagement {
81-
url.set(githubUrl.map { "$it/issues" })
82-
system.set("GitHub")
83-
}
84-
}
85-
}
86-
87-
publishing.repositories {
88-
maven {
89-
name = "local"
90-
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
91-
}
92-
}
93-
}
94-
}
95-

buildSrc/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
8+
9+
dependencies {
10+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${embeddedKotlinVersion}")
11+
implementation(libs.com.vanniktech.maven.publish.gradle.plugin)
12+
}

buildSrc/settings.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plugins {
2+
`java-library`
3+
}
4+
/**
5+
Embedded plugin has common logic for different projects. So, mainly it is here to have an ability to put more code into Gradle files.
6+
*/
7+
8+
// we will lock dependencies on these two configurations. We aren't interested in others, however these ones will be used
9+
// for local invocation
10+
val configurationsToLock: List<Configuration> =
11+
listOf("runtimeClasspath", "testRuntimeClasspath").map { configurations[it] }
12+
13+
// lock selected configurations. The build is failed if they aren't updated
14+
configurationsToLock.forEach {
15+
it.resolutionStrategy.activateDependencyLocking()
16+
}
17+
18+
// copied from https://docs.gradle.org/current/userguide/dependency_locking.html#sec:lock-all-configurations-in-one-build-execution
19+
// however we resolve only two configurations we are interested in
20+
// So, if there are any issues with `gradle.lockfile`, call `./gradlew resolveAndLockAll --write-locks`
21+
tasks.register("resolveAndLockAll") {
22+
notCompatibleWithConfigurationCache("Filters configurations at execution time")
23+
doFirst {
24+
require(gradle.startParameter.isWriteDependencyLocks) { "$path must be run from the command line with the `--write-locks` flag" }
25+
}
26+
doLast {
27+
configurationsToLock.forEach {
28+
// resolve the configuration - it means that Gradle will generate lockfile for them
29+
it.resolve()
30+
}
31+
}
32+
}
33+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import org.gradle.api.publish.PublishingExtension
2+
import org.gradle.api.publish.maven.MavenPublication
3+
import org.gradle.kotlin.dsl.create
4+
import org.gradle.kotlin.dsl.get
5+
import org.gradle.kotlin.dsl.the
6+
7+
plugins {
8+
`maven-publish`
9+
}
10+
11+
plugins.apply(com.vanniktech.maven.publish.MavenPublishPlugin::class)
12+
plugins.apply(SigningPlugin::class)
13+
14+
val publishing = the<PublishingExtension>()
15+
16+
publishing.publications.withType<MavenPublication> {
17+
pom {
18+
val githubRepo = providers.gradleProperty("githubRepo")
19+
val githubUrl = githubRepo.map { "https://github.com/$it" }
20+
21+
name.set(providers.gradleProperty("projectName"))
22+
description.set(providers.gradleProperty("projectDescription"))
23+
url.set(providers.gradleProperty("projectUrl"))
24+
licenses {
25+
license {
26+
name.set(providers.gradleProperty("projectLicenseName"))
27+
url.set(providers.gradleProperty("projectLicenseUrl"))
28+
}
29+
}
30+
developers {
31+
developer {
32+
name.set(providers.gradleProperty("developerName"))
33+
email.set(providers.gradleProperty("developerEmail"))
34+
url.set(providers.gradleProperty("developerUrl"))
35+
}
36+
}
37+
scm {
38+
url.set(githubUrl.map { "$it/tree/master" })
39+
connection.set(githubRepo.map { "scm:git:git://github.com/$it.git" })
40+
developerConnection.set(githubRepo.map { "scm:git:ssh://github.com:$it.git" })
41+
}
42+
issueManagement {
43+
url.set(githubUrl.map { "$it/issues" })
44+
system.set("GitHub")
45+
}
46+
}
47+
}
48+
49+
publishing.repositories {
50+
maven {
51+
name = "local"
52+
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
53+
}
54+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import org.gradle.kotlin.dsl.configure
2+
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
3+
4+
plugins {
5+
`java-library`
6+
kotlin("jvm")
7+
id("dependencies-lock")
8+
}
9+
10+
repositories {
11+
// for Gradle dependencies
12+
gradlePluginPortal()
13+
// for all other jars
14+
mavenCentral()
15+
}
16+
17+
configure<KotlinJvmProjectExtension> {
18+
// fix the toolchain for now
19+
jvmToolchain(11)
20+
}
21+
22+
dependencies {
23+
compileOnly(kotlin("stdlib"))
24+
compileOnly(kotlin("stdlib-jdk8"))
25+
}
26+
27+
28+
configure<JavaPluginExtension> {
29+
withSourcesJar()
30+
// We don't publish Javadoc, because it is useless in out case. We publish sources, plus it is easy to find
31+
// GitHub project and read the source code. We don't have any comprehensive documentation, so let's just publish nothing.
32+
// Additionally, JavaDoc task conflicts with publishing plugin, so let's simply delete one of them.
33+
// withJavadocJar()
34+
}
35+
36+
tasks.withType<Test> {
37+
useJUnitPlatform()
38+
// store all temporary results inside the Gradle folder
39+
val localTempFolder = layout.buildDirectory.dir("tmp").get().asFile
40+
systemProperty("java.io.tmpdir", localTempFolder.absolutePath)
41+
42+
doFirst {
43+
// create the folder if needed
44+
localTempFolder.mkdirs()
45+
}
46+
}

gradle-plugin-integration-test-utils/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
plugins {
2-
kotlin("jvm")
3-
`java-library`
4-
`maven-publish`
2+
id("kotlin-convention") // keep shared logic here
53
}
64

75

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is a Gradle generated file for dependency locking.
2+
# Manual edits can break the build and are not advised.
3+
# This file is expected to be part of source control.
4+
com.google.code.findbugs:jsr305:3.0.2=runtimeClasspath,testRuntimeClasspath
5+
org.javassist:javassist:3.28.0-GA=runtimeClasspath,testRuntimeClasspath
6+
org.jetbrains.kotlin:kotlin-stdlib:1.9.20=testRuntimeClasspath
7+
org.jetbrains:annotations:13.0=testRuntimeClasspath
8+
org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath
9+
org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath
10+
empty=

gradle-plugin-test-utils/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
plugins {
2-
kotlin("jvm")
3-
`java-library`
4-
`maven-publish`
2+
id("kotlin-convention") // keep shared logic here
53
}
64

75

0 commit comments

Comments
 (0)