Skip to content

Commit 903b428

Browse files
Improve and automate the plugin build (#9)
Fixes #6 This PR brings the following changes: - Implemented the plugin in Kotlin - Added unit and functional tests. - Added ktlint and configured GitHub Actions as CI: - checks and tests on every push to any branch - publishing the plugin to the Gradle Plugin Portal on every tag creation. - Cleanup and build script refactoring.
1 parent 37e9eb7 commit 903b428

13 files changed

Lines changed: 635 additions & 349 deletions

File tree

.github/workflows/publish.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
push:
3+
tags:
4+
- '*'
5+
6+
jobs:
7+
publish:
8+
name: Publish Gradle Plugin
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Set up JDK
16+
uses: actions/setup-java@v2
17+
with:
18+
java-version: 8
19+
20+
- name: Run Gradle tasks
21+
run: ./gradlew check
22+
23+
- name: Build and Publish
24+
env:
25+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
26+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
27+
run: |
28+
./gradlew clean build publishPlugins -Pgradle.publish.key=$GRADLE_PUBLISH_KEY -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET

.github/workflows/validate.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Validate Plugin
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
ktlint:
8+
name: Ktlint
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Run ktlint check
16+
run: ./gradlew ktlintCheck
17+
18+
tests:
19+
name: Tests
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Run tests
27+
run: ./gradlew test

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,42 @@ plugins {
1111

1212
jxbrowser {
1313
// The JxBrowser version. A mandatory field.
14-
version = "7.35.2"
14+
// Obtain the latest release version number at https://teamdev.com/jxbrowser/.
15+
version = "7.36"
1516

1617
// The location of JxBrowser repository to use. It's either North America or Europe.
17-
// By default, it's North America.
18+
// If not specified, the location is set to North America.
1819
repository = Repository.NORTH_AMERICA
1920

2021
// Alternatively, it may point to a custom repo via its URL, as follows:
2122
// repository = "https://my.custom.repository"
2223

23-
// Adds JxBrowser EAP repository to the project.
24+
// Adds a repository with JxBrowser preview builds to the project.
2425
includePreviewBuilds()
2526
}
2627

2728
dependencies {
2829
// Adds a dependency to the core JxBrowser API.
29-
implementation(jxbrowser.core())
30+
implementation(jxbrowser.core)
3031

3132
// Adds dependencies to the UI toolkit integrations.
32-
implementation(jxbrowser.swt())
33-
implementation(jxbrowser.swing())
34-
implementation(jxbrowser.javafx())
33+
implementation(jxbrowser.swt)
34+
implementation(jxbrowser.swing)
35+
implementation(jxbrowser.javafx)
3536

3637
// Detects the current platform and adds the corresponding Chromium binaries.
37-
implementation(jxbrowser.currentPlatform())
38-
39-
// Adds dependencies with binaries for all supported platforms.
40-
implementation(jxbrowser.crossPlatform())
41-
42-
// Adds a dependency to specific Chromium binaries.
43-
implementation(jxbrowser.mac())
44-
implementation(jxbrowser.macArm())
45-
implementation(jxbrowser.win32())
46-
implementation(jxbrowser.win64())
47-
implementation(jxbrowser.linux64())
48-
implementation(jxbrowser.linuxArm())
38+
implementation(jxbrowser.currentPlatform)
39+
40+
// Adds dependencies to the Chromium binaries for all supported platforms.
41+
implementation(jxbrowser.crossPlatform)
42+
43+
// Adds a dependency to the platform-specific Chromium binaries.
44+
implementation(jxbrowser.mac)
45+
implementation(jxbrowser.macArm)
46+
implementation(jxbrowser.win32)
47+
implementation(jxbrowser.win64)
48+
implementation(jxbrowser.linux64)
49+
implementation(jxbrowser.linuxArm)
4950
}
5051
```
5152

build.gradle.kts

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,92 @@
1818
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1919
*/
2020

21+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22+
23+
object BuildSettings {
24+
const val GROUP = "com.teamdev.jxbrowser"
25+
const val VERSION = "1.0.0"
26+
const val JXBROWSER_VERSION = "7.36"
27+
val javaVersion = JavaVersion.VERSION_1_8
28+
}
29+
30+
object PluginProperties {
31+
const val ID = "com.teamdev.jxbrowser"
32+
const val NAME = "jxbrowser-deps"
33+
const val DISPLAY_NAME = "Adds JxBrowser repository and dependencies to the project"
34+
const val WEBSITE = "https://github.com/TeamDev-IP/JxBrowser-Gradle-Plugin"
35+
const val VCS_URL = "https://github.com/TeamDev-IP/JxBrowser-Gradle-Plugin"
36+
const val IMPLEMENTATION_CLASS = "com.teamdev.jxbrowser.gradle.JxBrowserPlugin"
37+
const val DESCRIPTION =
38+
"Adds JxBrowser repository to the project and provides convenience methods for applying JxBrowser dependencies."
39+
val TAGS = listOf("jxbrowser")
40+
}
41+
2142
plugins {
2243
`java-gradle-plugin`
44+
kotlin("jvm") version "1.9.10"
2345
id("maven-publish")
2446
id("com.gradle.plugin-publish") version "1.2.1"
47+
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
2548
}
2649

27-
group = "com.teamdev.jxbrowser"
28-
version = "0.0.5"
50+
group = BuildSettings.GROUP
51+
version = BuildSettings.VERSION
52+
53+
repositories {
54+
mavenCentral()
55+
}
56+
57+
dependencies {
58+
implementation(kotlin("stdlib"))
59+
60+
testImplementation(kotlin("test"))
61+
testImplementation(gradleTestKit())
62+
testImplementation("io.kotest:kotest-assertions-core:5.7.2")
63+
}
64+
65+
java {
66+
with(BuildSettings) {
67+
sourceCompatibility = javaVersion
68+
targetCompatibility = javaVersion
69+
}
70+
}
71+
72+
kotlin {
73+
explicitApi()
74+
}
2975

3076
gradlePlugin {
31-
plugins {
32-
website = "https://github.com/TeamDev-IP/JxBrowser-Gradle-Plugin"
33-
vcsUrl = "https://github.com/TeamDev-IP/JxBrowser-Gradle-Plugin"
34-
create("jxbrowser-deps") {
35-
id = "com.teamdev.jxbrowser"
36-
displayName = "Adds JxBrowser repository and dependencies to the project"
37-
description = """
38-
This plug-in adds JxBrowser repository to the project and provides convenience methods for applying
39-
JxBrowser dependencies.
40-
""".trimIndent()
41-
implementationClass = "com.teamdev.jxbrowser.gradle.DepsPlugin"
42-
tags = listOf("jxbrowser")
77+
with(PluginProperties) {
78+
plugins {
79+
create(NAME) {
80+
id = ID
81+
displayName = DISPLAY_NAME
82+
description = DESCRIPTION
83+
implementationClass = IMPLEMENTATION_CLASS
84+
tags = TAGS
85+
}
4386
}
87+
website = WEBSITE
88+
vcsUrl = VCS_URL
4489
}
4590
}
4691

47-
// Used only for testing.
4892
publishing {
93+
description = "Publishes the plugin to the local repository. Used for testing only."
4994
repositories {
5095
maven {
5196
name = "localPluginRepository"
5297
url = uri("../local-plugin-repository")
5398
}
5499
}
55100
}
101+
102+
tasks.withType<KotlinCompile> {
103+
kotlinOptions.jvmTarget = BuildSettings.javaVersion.toString()
104+
}
105+
106+
tasks.withType<Test> {
107+
useJUnitPlatform()
108+
systemProperty("JXBROWSER_VERSION", BuildSettings.JXBROWSER_VERSION)
109+
}

0 commit comments

Comments
 (0)