Skip to content

Commit 33017be

Browse files
authored
Feature/snakeyaml parser (#1)
* wip: added initial conversion to snakeyaml * fix: solved issue with gradlew script * wip: finishing migration to snakeyaml * wip: added simplification to files or dirs * wip: simplified logic and fixed some issues with not providing lazy properties * feat: finished implementation and updated documentation and samples Co-authored-by: Aldo <[email protected]>
1 parent b07a912 commit 33017be

22 files changed

+787
-570
lines changed

README.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,41 @@
1515

1616
## 💡 Introduction
1717

18-
This plugin was developed originally for [Exflo](https://github.com/41north/exflo).
18+
This plugin allows to specify [Intellij Run configurations](https://www.jetbrains.com/help/idea/run-debug-configuration.html) with YAML!
19+
20+
For now, the scope of the plugin is quite simplistic, but over time new use cases or improvements may be added!
21+
22+
Originally, this plugin was developed for our Besu plugin: [Exflo](https://github.com/41north/exflo) as a way of sharing complex configurations easily.
1923

2024
## 🙈 Usage
2125

2226
To apply the plugin, use the gradle plugin syntax:
2327

2428
```kotlin
2529
plugins {
26-
id("dev.north.fortyone.intellij.run.generator") version "0.1.0"
30+
id("dev.north.fortyone.intellij.run.generator") version "0.2.0"
2731
}
2832
```
2933

3034
Once the plugin is applied, you can configure it with the following options (default values are displayed below):
3135

3236
```kotlin
33-
`intellij-run-generator` {
37+
intellijRunGenerator {
3438
tasksDefinitionsFile.set(File("./intellij-run-configs.yaml"))
39+
tasksDefinitionsFileExtension = FilenameFilter { _, name -> name.toLowerCase().endsWith(".yaml") || name.toLowerCase().endsWith(".yml") }
3540
tasksDefinitionOutputDir.set(File(".idea/runConfigurations"))
3641
}
3742
```
3843

39-
If you want to see how the definition file looks like, there's one example taken from Exflo inside [`samples/intellij-run-configs.yaml`](samples/intellij-run-configs.yaml).
44+
Also you can specify a folder instead of a single definition file, just like this (by default it will load all `*.yaml`, `*.yml` files):
45+
46+
```kotlin
47+
intellijRunGenerator {
48+
tasksDefinitionsFile.set(File("./intellij-run-configs/"))
49+
}
50+
```
51+
52+
If you want to see how the definition file looks like, there're some examples inside [`samples/intellij-run-configs.yaml`](samples/intellij-run-configs.yaml).
4053

4154
## 💻 Contribute
4255

build.gradle.kts

100644100755
+8-11
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ plugins {
2727
id("com.gradle.plugin-publish") version "0.12.0"
2828
}
2929

30-
apply(plugin = "io.spring.dependency-management")
3130
apply(from = "${project.rootDir}/gradle/versions.gradle")
3231

3332
kotlinDslPluginOptions {
3433
experimentalWarning.set(false)
3534
}
3635

3736
group = "dev.north.fortyone.gradle"
38-
version = "0.1.2"
37+
version = "0.2.0"
3938

4039
repositories {
4140
jcenter()
@@ -58,6 +57,12 @@ pluginBundle {
5857
tags = listOf("intellij", "generator", "kotlin-dsl")
5958
}
6059

60+
publishing {
61+
repositories {
62+
maven(url = "build/repository")
63+
}
64+
}
65+
6166
tasks {
6267
withType<KotlinCompile>().configureEach {
6368
kotlinOptions.jvmTarget = "11"
@@ -69,20 +74,12 @@ tasks {
6974
}
7075

7176
dependencies {
77+
implementation("org.yaml:snakeyaml:1.26")
7278
implementation("org.redundent:kotlin-xml-builder")
73-
implementation("com.fasterxml.jackson.core:jackson-databind")
74-
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
75-
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
7679
implementation("javax.xml.bind:jaxb-api")
7780
implementation("com.sun.xml.bind:jaxb-core")
7881

7982
testImplementation("io.kotest:kotest-runner-junit5-jvm")
8083
testImplementation("io.kotest:kotest-runner-console-jvm")
8184
testImplementation("io.kotest:kotest-assertions-core-jvm")
8285
}
83-
84-
publishing {
85-
repositories {
86-
maven(url = "build/repository")
87-
}
88-
}

gradle/versions.gradle

100644100755
-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ dependencyManagement {
2020
dependencies {
2121

2222
dependency 'org.redundent:kotlin-xml-builder:1.6.0'
23-
dependency 'com.fasterxml.jackson.core:jackson-databind:2.11.2'
24-
dependency 'com.fasterxml.jackson.module:jackson-module-kotlin:2.11.2'
25-
dependency 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.2'
2623
dependency 'javax.xml.bind:jaxb-api:2.3.0'
2724
dependency 'com.sun.xml.bind:jaxb-core:2.3.0.1'
2825

samples/intellij-run-configs.yaml

+31-154
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,31 @@
1-
---
2-
application:
3-
4-
# ------------------------------------------------------------------------------
5-
# DEV
6-
# ------------------------------------------------------------------------------
7-
8-
- name: BESU | Dev | Kafka > Run
9-
filename: BESU__Dev__Kafka__Run.xml
10-
default: false
11-
envs:
12-
BESU_SYNC_MODE: FULL
13-
BESU_LOGGING: INFO
14-
BESU_P2P_ENABLED: 'false'
15-
BESU_RPC_WS_ENABLED: 'true'
16-
BESU_RPC_HTTP_ENABLED: 'true'
17-
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
18-
BESU_NETWORK: DEV
19-
BESU_DATA_PATH: "/opt/besu/dev"
20-
BESU_MINER_ENABLED: 'true'
21-
BESU_MINER_COINBASE: '0xf17f52151EbEF6C7334FAD080c5704D77216b732'
22-
BESU_PLUGIN_EXFLO_KAFKA_ENABLED: 'true'
23-
mainClassName: org.hyperledger.besu.Besu
24-
module: exflo.ingestion.kafka.main
25-
26-
- name: BESU | Dev | Postgres > Run
27-
filename: BESU__Dev__Postgres__Run.xml
28-
default: false
29-
envs:
30-
BESU_SYNC_MODE: FULL
31-
BESU_LOGGING: INFO
32-
BESU_P2P_ENABLED: 'false'
33-
BESU_RPC_WS_ENABLED: 'true'
34-
BESU_RPC_HTTP_ENABLED: 'true'
35-
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
36-
BESU_NETWORK: DEV
37-
BESU_DATA_PATH: "/opt/besu/dev"
38-
BESU_MINER_ENABLED: 'true'
39-
BESU_MINER_COINBASE: '0xf17f52151EbEF6C7334FAD080c5704D77216b732'
40-
BESU_PLUGIN_EXFLO_POSTGRES_ENABLED: 'true'
41-
mainClassName: org.hyperledger.besu.Besu
42-
module: exflo.ingestion.postgres.main
43-
44-
# ------------------------------------------------------------------------------
45-
# ROPSTEN
46-
# ------------------------------------------------------------------------------
47-
48-
- name: BESU | Ropsten | Kafka > Run
49-
filename: BESU__Ropsten__Kafka__Run.xml
50-
default: false
51-
envs:
52-
BESU_SYNC_MODE: FULL
53-
BESU_LOGGING: INFO
54-
BESU_P2P_ENABLED: 'true'
55-
BESU_RPC_WS_ENABLED: 'true'
56-
BESU_RPC_HTTP_ENABLED: 'true'
57-
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
58-
BESU_NETWORK: ROPSTEN
59-
BESU_DATA_PATH: "/opt/besu/ropsten"
60-
BESU_BOOTNODES: "enode://cd24a0c66055d788ce2bb77c2525915724a56de577b3e39c1a4dde347e60c83f082285a9d43a5ba0d7efc929699106d147e8d3612baafcaeb8f3075f36a82670@180.64.84.98:51044,enode://cd24a0c66055d788ce2bb77c2525915724a56de577b3e39c1a4dde347e60c83f082285a9d43a5ba0d7efc929699106d147e8d3612baafcaeb8f3075f36a82670@180.64.84.98:51044"
61-
BESU_PLUGIN_EXFLO_KAFKA_ENABLED: 'true'
62-
mainClassName: org.hyperledger.besu.Besu
63-
module: exflo.ingestion.kafka.main
64-
65-
- name: BESU | Ropsten | Postgres > Run
66-
filename: BESU__Ropsten__Postgres__Run.xml
67-
default: false
68-
envs:
69-
BESU_SYNC_MODE: FULL
70-
BESU_LOGGING: INFO
71-
BESU_P2P_ENABLED: 'true'
72-
BESU_RPC_WS_ENABLED: 'true'
73-
BESU_RPC_HTTP_ENABLED: 'true'
74-
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
75-
BESU_NETWORK: ROPSTEN
76-
BESU_DATA_PATH: "/opt/besu/ropsten"
77-
BESU_BOOTNODES: "enode://cd24a0c66055d788ce2bb77c2525915724a56de577b3e39c1a4dde347e60c83f082285a9d43a5ba0d7efc929699106d147e8d3612baafcaeb8f3075f36a82670@180.64.84.98:51044,enode://cd24a0c66055d788ce2bb77c2525915724a56de577b3e39c1a4dde347e60c83f082285a9d43a5ba0d7efc929699106d147e8d3612baafcaeb8f3075f36a82670@180.64.84.98:51044"
78-
BESU_PLUGIN_EXFLO_POSTGRES_ENABLED: 'true'
79-
mainClassName: org.hyperledger.besu.Besu
80-
module: exflo.ingestion.postgres.main
81-
82-
# ------------------------------------------------------------------------------
83-
# MAINNET
84-
# ------------------------------------------------------------------------------
85-
86-
- name: BESU | Mainnet | Kafka > Run
87-
filename: BESU__Mainnet__Kafka__Run.xml
88-
default: false
89-
envs:
90-
BESU_SYNC_MODE: FULL
91-
BESU_LOGGING: INFO
92-
BESU_P2P_ENABLED: 'true'
93-
BESU_RPC_WS_ENABLED: 'true'
94-
BESU_RPC_HTTP_ENABLED: 'true'
95-
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
96-
BESU_NETWORK: MAINNET
97-
BESU_DATA_PATH: "/opt/besu/mainnet"
98-
BESU_PLUGIN_EXFLO_KAFKA_ENABLED: 'true'
99-
mainClassName: org.hyperledger.besu.Besu
100-
module: exflo.ingestion.kafka.main
101-
102-
- name: BESU | Mainnet | Postgres > Run
103-
filename: BESU__Mainnet__Postgres__Run.xml
104-
default: false
105-
envs:
106-
BESU_SYNC_MODE: FULL
107-
BESU_LOGGING: INFO
108-
BESU_P2P_ENABLED: 'true'
109-
BESU_RPC_WS_ENABLED: 'true'
110-
BESU_RPC_HTTP_ENABLED: 'true'
111-
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
112-
BESU_NETWORK: MAINNET
113-
BESU_DATA_PATH: "/opt/besu/mainnet"
114-
BESU_PLUGIN_EXFLO_POSTGRES_ENABLED: 'true'
115-
mainClassName: org.hyperledger.besu.Besu
116-
module: exflo.ingestion.postgres.main
117-
118-
docker:
119-
120-
- name: DOCKER | Kafka
121-
filename: DOCKER__KAFKA.xml
122-
default: false
123-
dockerComposeFileName: docker-compose.exflo-kafka.yml
124-
125-
- name: DOCKER | Postgres
126-
filename: DOCKER__Postgres.xml
127-
default: false
128-
dockerComposeFileName: docker-compose.exflo-postgres.yml
129-
130-
gradle:
131-
132-
- name: GRADLE | Ktlint > Format
133-
filename: GRADLE__Ktlint__Format.xml
134-
default: false
135-
tasks:
136-
- ktlintFormat
137-
138-
- name: GRADLE | Postgres > FlywayClean
139-
filename: GRADLE__Postgres__FlywayClean.xml
140-
default: false
141-
tasks:
142-
- flywayClean
143-
144-
- name: GRADLE | Postgres > FlywayMigrate
145-
filename: GRADLE__Postgres__FlywayMigrate.xml
146-
default: false
147-
tasks:
148-
- flywayMigrate
149-
150-
- name: GRADLE | Postgres > JooqCodeGen
151-
filename: GRADLE__Postgres__JooqCodeGen.xml
152-
default: false
153-
tasks:
154-
- jooq-codegen-primary
1+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.ApplicationRunConfig
2+
name: BESU | Dev | Kafka > Run
3+
filename: BESU__Dev__Kafka__Run.xml
4+
mainClassName: org.hyperledger.besu.Besu
5+
module: exflo.ingestion.kafka.main
6+
default: false
7+
envs:
8+
BESU_SYNC_MODE: FULL
9+
BESU_LOGGING: INFO
10+
BESU_P2P_ENABLED: 'false'
11+
BESU_RPC_WS_ENABLED: 'true'
12+
BESU_RPC_HTTP_ENABLED: 'true'
13+
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
14+
BESU_NETWORK: DEV
15+
BESU_DATA_PATH: "/opt/besu/dev"
16+
BESU_MINER_ENABLED: 'true'
17+
BESU_MINER_COINBASE: '0xf17f52151EbEF6C7334FAD080c5704D77216b732'
18+
BESU_PLUGIN_EXFLO_KAFKA_ENABLED: 'true'
19+
20+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.DockerRunConfig
21+
name: DOCKER | Kafka
22+
filename: DOCKER__KAFKA.xml
23+
default: false
24+
dockerComposeFileName: docker-compose.exflo-kafka.yml
25+
26+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.GradleRunConfig
27+
name: GRADLE | Ktlint > Format
28+
filename: GRADLE__Ktlint__Format.xml
29+
default: false
30+
tasks:
31+
- ktlintFormat
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ------------------------------------------------------------------------------
2+
# DEV KAFKA
3+
# ------------------------------------------------------------------------------
4+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.ApplicationRunConfig
5+
name: BESU | Dev | Kafka > Run
6+
filename: BESU__Dev__Kafka__Run.xml
7+
default: false
8+
mainClassName: org.hyperledger.besu.Besu
9+
module: exflo.ingestion.kafka.main
10+
envs:
11+
BESU_SYNC_MODE: FULL
12+
BESU_LOGGING: INFO
13+
BESU_P2P_ENABLED: 'false'
14+
BESU_RPC_WS_ENABLED: 'true'
15+
BESU_RPC_HTTP_ENABLED: 'true'
16+
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
17+
BESU_NETWORK: DEV
18+
BESU_DATA_PATH: "/opt/besu/dev"
19+
BESU_MINER_ENABLED: 'true'
20+
BESU_MINER_COINBASE: '0xf17f52151EbEF6C7334FAD080c5704D77216b732'
21+
BESU_PLUGIN_EXFLO_KAFKA_ENABLED: 'true'
22+
23+
# ------------------------------------------------------------------------------
24+
# DEV POSTGRES
25+
# ------------------------------------------------------------------------------
26+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.ApplicationRunConfig
27+
name: BESU | Dev | Postgres > Run
28+
filename: BESU__Dev__Postgres__Run.xml
29+
default: false
30+
mainClassName: org.hyperledger.besu.Besu
31+
module: exflo.ingestion.postgres.main
32+
envs:
33+
BESU_SYNC_MODE: FULL
34+
BESU_LOGGING: INFO
35+
BESU_P2P_ENABLED: 'false'
36+
BESU_RPC_WS_ENABLED: 'true'
37+
BESU_RPC_HTTP_ENABLED: 'true'
38+
BESU_RPC_HTTP_API: eth,net,web3,admin,debug
39+
BESU_NETWORK: DEV
40+
BESU_DATA_PATH: "/opt/besu/dev"
41+
BESU_MINER_ENABLED: 'true'
42+
BESU_MINER_COINBASE: '0xf17f52151EbEF6C7334FAD080c5704D77216b732'
43+
BESU_PLUGIN_EXFLO_POSTGRES_ENABLED: 'true'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.DockerRunConfig
2+
name: DOCKER | Kafka
3+
filename: DOCKER__Kafka.xml
4+
default: false
5+
dockerComposeFileName: docker-compose.exflo-kafka.yml
6+
7+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.DockerRunConfig
8+
name: DOCKER | Postgres
9+
filename: DOCKER__Postgres.xml
10+
default: false
11+
dockerComposeFileName: docker-compose.exflo-postgres.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.GradleRunConfig
2+
name: GRADLE | Ktlint > Format
3+
filename: GRADLE__Ktlint__Format.xml
4+
default: false
5+
tasks:
6+
- ktlintFormat
7+
8+
--- !!dev.north.fortyone.gradle.intellij.run.generator.models.GradleRunConfig
9+
name: GRADLE | Postgres > FlywayClean
10+
filename: GRADLE__Postgres__FlywayClean.xml
11+
default: false
12+
tasks:
13+
- flywayClean

0 commit comments

Comments
 (0)