Skip to content

Commit

Permalink
fix: use Maven to output the correct classpath for user code (#487)
Browse files Browse the repository at this point in the history
Then extend `ftl.toml` to use it. This fixes issues where older versions
of JARs were shadowing newer versions because we were just file-system
globbing the classpath.
  • Loading branch information
alecthomas authored Oct 12, 2023
1 parent c931fa1 commit cb0495e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions examples/echo-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@
<includeScope>runtime</includeScope>
</configuration>
</execution>
<execution>
<id>build-classpath</id>
<phase>compile</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<outputFile>${project.build.directory}/classpath.txt</outputFile>
<prefix>dependency</prefix>
</configuration>
</execution>
</executions>
</plugin>
<!-- Run the Wire compiler -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ class ModuleGenerator() {
"""
module = "${module}"
language = "kotlin"
deploy = ["main", "classes", "dependency"]
deploy = ["main", "classes", "dependency", "classpath.txt"]
""".trimIndent()
)

val mainFile = Path.of(buildDir, "main")
mainFile.writeText(
"""
#!/bin/bash
exec java -cp "classes:$(printf %s: dependency/*.jar)" xyz.block.ftl.main.MainKt
exec java -cp "classes:$(cat classpath.txt)" xyz.block.ftl.main.MainKt
""".trimIndent(),
)
mainFile.setPosixFilePermissions(
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<version>3.6.0</version>
<executions>
<execution>
<phase>initialize</phase>
Expand Down

0 comments on commit cb0495e

Please sign in to comment.