Skip to content

Commit 2f1d603

Browse files
authored
feat: use elide kotlinc in maven (#4)
Signed-off-by: melodicore <datafox@datafox.me>
1 parent a63a444 commit 2f1d603

53 files changed

Lines changed: 1677 additions & 623 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/job.build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ jobs:
4343
java-version: "24"
4444
- name: "Setup: Elide"
4545
uses: elide-dev/setup-elide@990b915b2974a70e7654acb1303607b4cd1d3538 # v2.0.0
46-
- name: "Build: Plugin"
47-
run: ./gradlew build publishToMavenLocal
48-
- name: "Test: Plugin"
49-
working-directory: sample
50-
run: ./mvnw clean package
46+
- name: "Build: Java Compiler"
47+
run: ./mvnw clean install -pl plexus-compilers
48+
- name: "Build: Kotlin Plugin"
49+
run: ./mvnw clean install -pl kotlin-plugin
50+
- name: "Test: Java Compiler"
51+
run: ./mvnw clean package -pl sample-java
52+
- name: "Test: Kotlin Plugin"
53+
run: ./mvnw clean package -pl sample-kotlin
54+
- name: "Test: Mixed source"
55+
run: ./mvnw clean package -pl sample-mixed

.github/workflows/on.pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "PR"
22

33
"on":
4-
pull_request: {}
4+
pull_request: { }
55

66
permissions:
77
contents: "read"

.gitignore

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
.gradle
2-
build/
3-
!gradle/wrapper/gradle-wrapper.jar
4-
!**/src/main/**/build/
5-
!**/src/test/**/build/
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
65

76
### IntelliJ IDEA ###
87
.idea/
98
*.iws
109
*.iml
1110
*.ipr
12-
out/
13-
!**/src/main/**/out/
14-
!**/src/test/**/out/
15-
16-
### Kotlin ###
17-
.kotlin
1811

1912
### Eclipse ###
2013
.apt_generated
@@ -24,16 +17,16 @@ out/
2417
.settings
2518
.springBeans
2619
.sts4-cache
27-
bin/
28-
!**/src/main/**/bin/
29-
!**/src/test/**/bin/
3020

3121
### NetBeans ###
3222
/nbproject/private/
3323
/nbbuild/
3424
/dist/
3525
/nbdist/
3626
/.nb-gradle/
27+
build/
28+
!**/src/main/**/build/
29+
!**/src/test/**/build/
3730

3831
### VS Code ###
3932
.vscode/
File renamed without changes.

README.md

Lines changed: 154 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Elide Maven Plugin
22

3-
This plugin can be consumed in a Maven project to use [Elide](https://elide.dev).
3+
This plugin can be consumed in a Maven project to use [Elide](https://elide.dev) for compiling Java and Kotlin sources.
44

55
> [!WARNING]
66
> This plugin is currently under development.
@@ -9,44 +9,170 @@ This plugin can be consumed in a Maven project to use [Elide](https://elide.dev)
99

1010
- [x] Swap out `javac ...` for `elide javac -- ...`
1111
- [x] Supports explicit path to `elide`
12-
- [ ] Resolve `elide` via the `PATH`
13-
- [ ] Swap out `kotlinc ...` for `elide kotlinc -- ...`
12+
- [x] Resolve `elide` via the `PATH`
13+
- [x] Swap out `kotlinc ...` for `elide kotlinc -- ...`
1414
- [ ] Usability of Elide as a Maven toolchain
1515

1616
## Usage
1717

18+
### Java
19+
1820
Configuring Elide as your `javac` compiler:
1921

2022
**`pom.xml`**
2123
```xml
22-
<build>
23-
<plugins>
24-
<plugin>
25-
<artifactId>maven-compiler-plugin</artifactId>
26-
<version>3.13.0</version>
27-
<dependencies>
28-
<dependency>
29-
<groupId>dev.elide</groupId>
30-
<artifactId>elide-plexus-compilers</artifactId>
31-
<version>1.0.0-SNAPSHOT</version>
32-
</dependency>
33-
</dependencies>
34-
<configuration>
35-
<compilerId>elide</compilerId>
36-
</configuration>
37-
</plugin>
38-
</plugins>
39-
</build>
24+
<build>
25+
<plugins>
26+
<plugin>
27+
<artifactId>maven-compiler-plugin</artifactId>
28+
<version>3.14.0</version>
29+
<dependencies>
30+
<dependency>
31+
<groupId>dev.elide</groupId>
32+
<artifactId>elide-plexus-compilers</artifactId>
33+
<version>1.0.0</version>
34+
</dependency>
35+
</dependencies>
36+
<configuration>
37+
<compilerId>elide</compilerId>
38+
</configuration>
39+
</plugin>
40+
</plugins>
41+
</build>
42+
```
43+
44+
> [!TIP]
45+
> See the [Java sample project](sample-java) for a usage example. Elide also provides
46+
> a [Gradle plugin](https://github.com/elide-dev/gradle).
47+
48+
### Kotlin
49+
50+
Configuring the Elide Kotlin plugin is done the exact same way as configuring the Kotlin Maven plugin, just replacing
51+
the plugin coordinates:
52+
53+
**`pom.xml`**
54+
```xml
55+
<build>
56+
<sourceDirectory>src/main/kotlin</sourceDirectory>
57+
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
58+
<plugins>
59+
<plugin>
60+
<groupId>dev.elide</groupId>
61+
<artifactId>elide-kotlin-maven-plugin</artifactId>
62+
<version>1.0.0</version>
63+
<executions>
64+
<execution>
65+
<id>compile</id>
66+
<goals>
67+
<goal>compile</goal>
68+
</goals>
69+
</execution>
70+
<execution>
71+
<id>test-compile</id>
72+
<goals>
73+
<goal>test-compile</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
81+
<dependencies>
82+
<dependency>
83+
<groupId>org.jetbrains.kotlin</groupId>
84+
<artifactId>kotlin-stdlib</artifactId>
85+
<version>2.2.0</version>
86+
</dependency>
87+
</dependencies>
4088
```
4189

42-
Properties needed:
90+
> [!TIP]
91+
> See the [Kotlin sample project](sample-kotlin) for a usage example.
92+
93+
### Mixed Java and Kotlin
94+
95+
By combining the Kotlin configuration and Java compiler replacement, mixed Java and Kotlin sources can be compiled with
96+
Elide:
97+
98+
**`pom.xml`**
99+
43100
```xml
44-
<properties>
45-
<maven.compiler.source>24</maven.compiler.source>
46-
<maven.compiler.target>24</maven.compiler.target>
47-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
48-
</properties>
101+
<build>
102+
<plugins>
103+
<plugin>
104+
<groupId>dev.elide</groupId>
105+
<artifactId>elide-kotlin-maven-plugin</artifactId>
106+
<version>1.0.0</version>
107+
<executions>
108+
<execution>
109+
<id>compile</id>
110+
<goals>
111+
<goal>compile</goal>
112+
</goals>
113+
<configuration>
114+
<sourceDirs>
115+
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
116+
<sourceDir>${project.basedir}/src/main/java</sourceDir>
117+
</sourceDirs>
118+
</configuration>
119+
</execution>
120+
<execution>
121+
<id>test-compile</id>
122+
<goals>
123+
<goal>test-compile</goal>
124+
</goals>
125+
<configuration>
126+
<sourceDirs>
127+
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
128+
<sourceDir>${project.basedir}/src/test/java</sourceDir>
129+
</sourceDirs>
130+
</configuration>
131+
</execution>
132+
</executions>
133+
</plugin>
134+
<plugin>
135+
<groupId>org.apache.maven.plugins</groupId>
136+
<artifactId>maven-compiler-plugin</artifactId>
137+
<version>3.14.0</version>
138+
<dependencies>
139+
<dependency>
140+
<groupId>dev.elide</groupId>
141+
<artifactId>elide-plexus-compilers</artifactId>
142+
<version>1.0.0</version>
143+
</dependency>
144+
</dependencies>
145+
<configuration>
146+
<compilerId>elide</compilerId>
147+
</configuration>
148+
<executions>
149+
<execution>
150+
<id>default-compile</id>
151+
<phase>none</phase>
152+
</execution>
153+
<execution>
154+
<id>default-testCompile</id>
155+
<phase>none</phase>
156+
</execution>
157+
<execution>
158+
<id>java-compile</id>
159+
<phase>compile</phase>
160+
<goals>
161+
<goal>compile</goal>
162+
</goals>
163+
</execution>
164+
<execution>
165+
<id>java-test-compile</id>
166+
<phase>test-compile</phase>
167+
<goals>
168+
<goal>testCompile</goal>
169+
</goals>
170+
</execution>
171+
</executions>
172+
</plugin>
173+
</plugins>
174+
</build>
49175
```
50176

51177
> [!TIP]
52-
> See the [sample project](./sample) for a usage example. Elide also provides a [Gradle plugin](https://github.com/elide-dev/gradle).
178+
> See the [Mixed sources sample project](sample-mixed) for a usage example.

build.gradle.kts

Lines changed: 0 additions & 49 deletions
This file was deleted.

gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

gradle/libs.versions.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

gradle/wrapper/gradle-wrapper.jar

-59.3 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)