Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Commit 67335db

Browse files
Update after isolating compiler plugins (#48)
* Update after isolating compiler plugins * Clean old documentation
1 parent f7610d3 commit 67335db

File tree

27 files changed

+119
-71
lines changed

27 files changed

+119
-71
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
./gradlew clean build
2222
java -jar use-plugin/build/libs/use-plugin.jar
2323
- name: "Build example: use of Arrow Meta Compiler Plugin with Gradle Plugin"
24-
working-directory: use-arrow-meta-compiler-plugin
24+
working-directory: use-arrow-meta-compiler-plugins
2525
run: ./gradlew clean build
2626
- name: "Build example: create new plugin to generate sources"
2727
working-directory: generate-sources

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,19 @@ cd hello-world
5252
java -jar use-plugin/build/libs/use-plugin.jar
5353
```
5454

55-
## Hello World Compiler + IDE Plugin
56-
57-
Stay tuned!
58-
5955
## Use of Λrrow Meta Compiler Plugin
6056

6157
Λrrow Meta Compiler Plugin can be used through Λrrow Meta Gradle Plugin.
6258

6359
### How to run it from IDE
6460

65-
1. Create a new project from existing sources: `use-arrow-meta-compiler-plugin` directory
61+
1. Create a new project from existing sources: `use-arrow-meta-compiler-plugins` directory
6662
2. Build project to run the test
6763

6864
### How to run it from command line
6965

7066
```
71-
cd use-arrow-meta-compiler-plugin
67+
cd use-arrow-meta-compiler-plugins
7268
./gradlew clean build
7369
```
7470

generate-sources/gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
KOTLIN_VERSION=1.5.0-RC
1+
KOTLIN_VERSION=1.5.0
22
JVM_TARGET_VERSION=1.8
3-
ARROW_META_VERSION=1.5.0-RC-SNAPSHOT
3+
ARROW_META_VERSION=1.5.0-SNAPSHOT
4+
JUNIT_VERSION=5.7.0
5+
ASSERTJ_VERSION=3.17.2

generate-sources/create-plugin/build.gradle renamed to generate-sources/new-plugin/build.gradle

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,11 @@ plugins {
2222

2323
dependencies {
2424
compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable:$KOTLIN_VERSION"
25-
compileOnly "io.arrow-kt:compiler-plugin:$ARROW_META_VERSION"
25+
compileOnly "io.arrow-kt:compiler-plugin-core:$ARROW_META_VERSION"
2626
}
2727

2828
compileKotlin {
2929
kotlinOptions {
3030
jvmTarget = "$JVM_TARGET_VERSION"
3131
}
32-
}
33-
34-
// Add new content to the default jar artifact: Arrow Meta Compiler Plugin except META-INF file to use the new one
35-
jar {
36-
from (
37-
zipTree(sourceSets.main.compileClasspath.find {
38-
it.absolutePath.contains(Paths.get("arrow-kt","compiler-plugin").toString())
39-
})
40-
) {
41-
exclude 'META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar'
42-
}
43-
}
32+
}
File renamed without changes.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ val Meta.transformNewSources: CliPlugin
2626
classDeclaration(this, { name == "NewMultipleSource" }) {
2727
Transform.newSources(
2828
"""
29-
package arrow
30-
31-
class ${name}_Generated
32-
""".file("${name}_Generated"), // default path: generated/source/kapt/main
29+
|package arrow
30+
|
31+
|class ${name}_Generated
32+
""".trimMargin().file("${name}_Generated"), // default path: generated/source/kapt/main
3333
"""
34-
package arrow
35-
36-
class ${name}_Generated_2
37-
""".file("${name}_Generated_2", "generated/custom/directory")
34+
|package arrow
35+
|
36+
|class ${name}_Generated_2
37+
""".trimMargin().file("${name}_Generated_2", "generated/custom/directory")
3838
)
3939
}
4040
)
File renamed without changes.

generate-sources/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include ':create-plugin'
1+
include ':new-plugin'
22
include ':use-plugin'

generate-sources/use-plugin/build.gradle

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,32 @@
1414
* limitations under the License.
1515
*/
1616

17+
buildscript {
18+
repositories {
19+
maven {
20+
url 'https://oss.sonatype.org/content/repositories/snapshots/'
21+
}
22+
}
23+
dependencies {
24+
classpath "io.arrow-kt:gradle-plugin:$ARROW_META_VERSION"
25+
}
26+
}
27+
1728
plugins {
1829
id "org.jetbrains.kotlin.jvm"
1930
}
2031

32+
apply plugin: "io.arrow-kt.arrow"
33+
34+
arrowMeta.plugins = ["${rootDir}/new-plugin/build/libs/new-plugin.jar".toString()]
35+
36+
dependencies {
37+
testImplementation "org.junit.jupiter:junit-jupiter:$JUNIT_VERSION"
38+
}
39+
2140
compileKotlin {
2241
kotlinOptions {
2342
jvmTarget = "$JVM_TARGET_VERSION"
24-
freeCompilerArgs = ["-Xplugin=${rootDir}/create-plugin/build/libs/create-plugin.jar",
25-
"-P", "plugin:arrow.meta.plugin.compiler:generatedSrcOutputDir=${buildDir}"]
2643
}
2744
}
2845

@@ -32,6 +49,10 @@ compileTestKotlin {
3249
}
3350
}
3451

52+
test {
53+
useJUnitPlatform()
54+
}
55+
3556
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
36-
compileTask -> compileTask.dependsOn ":create-plugin:assemble"
57+
compileTask -> compileTask.dependsOn ":new-plugin:assemble"
3758
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.arrowkt.example
2+
3+
import org.junit.jupiter.api.Assertions.assertTrue
4+
import org.junit.jupiter.api.Test
5+
import java.nio.file.Paths
6+
import kotlin.io.path.exists
7+
8+
9+
class NewMultipleSourceTests {
10+
@Test
11+
fun `multiple sources are created`() {
12+
val generatedDirPath = Paths.get(System.getProperty("user.dir"), "build", "generated")
13+
14+
assertTrue(Paths.get(generatedDirPath.toString(), "source", "kapt", "main", "NewMultipleSource_Generated.kt").exists())
15+
assertTrue(Paths.get(generatedDirPath.toString(), "custom", "directory", "NewMultipleSource_Generated_2.kt").exists())
16+
}
17+
}

0 commit comments

Comments
 (0)