generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: alway use correct module name in JVM (#2456)
fixes: 2396
- Loading branch information
1 parent
06f6a92
commit 147a98c
Showing
7 changed files
with
78 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/FTLBuildTimeConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/ModuleProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package xyz.block.ftl.deployment; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jboss.logging.Logger; | ||
import org.tomlj.Toml; | ||
import org.tomlj.TomlParseResult; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem; | ||
import io.quarkus.deployment.builditem.ApplicationInfoBuildItem; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.deployment.builditem.RunTimeConfigBuilderBuildItem; | ||
import xyz.block.ftl.runtime.config.FTLConfigSourceFactoryBuilder; | ||
|
||
public class ModuleProcessor { | ||
|
||
private static final Logger log = Logger.getLogger(ModuleProcessor.class); | ||
|
||
private static final String FEATURE = "ftl-java-runtime"; | ||
|
||
@BuildStep | ||
ModuleNameBuildItem moduleName(ApplicationInfoBuildItem applicationInfoBuildItem, | ||
ApplicationArchivesBuildItem archivesBuildItem) throws IOException { | ||
for (var root : archivesBuildItem.getRootArchive().getRootDirectories()) { | ||
Path source = root; | ||
for (;;) { | ||
var toml = source.resolve("ftl.toml"); | ||
if (Files.exists(toml)) { | ||
TomlParseResult result = Toml.parse(toml); | ||
if (result.hasErrors()) { | ||
throw new RuntimeException("Failed to parse " + toml + " " | ||
+ result.errors().stream().map(Objects::toString).collect(Collectors.joining(", "))); | ||
} | ||
|
||
String value = result.getString("module"); | ||
if (value != null) { | ||
return new ModuleNameBuildItem(value); | ||
} else { | ||
log.errorf("module name not found in %s", toml); | ||
} | ||
} | ||
if (source.getParent() == null) { | ||
break; | ||
} else { | ||
source = source.getParent(); | ||
} | ||
} | ||
} | ||
|
||
return new ModuleNameBuildItem(applicationInfoBuildItem.getName()); | ||
} | ||
|
||
@BuildStep | ||
RunTimeConfigBuilderBuildItem runTimeConfigBuilderBuildItem() { | ||
return new RunTimeConfigBuilderBuildItem(FTLConfigSourceFactoryBuilder.class.getName()); | ||
} | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() { | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters