Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When building layers with code existing plugins aren't loaded at startup #184

Open
treilhes opened this issue Aug 25, 2022 · 1 comment
Open

Comments

@treilhes
Copy link

Hello,

First of all thanks for your awesome work.

I'm trying to launch the vertx sample without using the launcher jar.
The layers configuration is done using java code instead of an external config file.
The layers configuration is the same than the one provided in "layrry-examples/vertx-links/staging/layers.yml"
The target filesystem is the same than the one generated in "layrry-examples/vertx-links/staging"

Below is the code i launch:

        Path pluginsPath = Path.of("/path/to/layrry-examples/vertx-links/staging/route-plugins1");
        Path pluginsPath2 = Path.of("/path/to/layrry-examples/vertx-links/staging/route-plugins2");

        Layers layers = Layers.builder()
                .resolve(Resolvers.remote().enabled(true))
                .pluginsDirectory("plugins1", pluginsPath, List.of("platform", "log"))
                .pluginsDirectory("plugins2", pluginsPath2, List.of("platform", "log"))
                .layer("vertx")
                    .withModule("io.vertx:vertx-core:3.9.0")
                    .withModule("io.vertx:vertx-web:3.9.0")
                    .withModule("io.vertx:vertx-web-common:3.9.0")
                    .withModule("io.vertx:vertx-bridge-common:3.9.0")
                    .withModule("io.netty:netty-all:4.1.48.Final")
                    .withModule("com.fasterxml.jackson.core:jackson-core:2.10.2")
                    .withModule("com.fasterxml.jackson.core:jackson-databind:2.10.2")
                    .withModule("com.fasterxml.jackson.core:jackson-annotations:2.10.2")

                .layer("log")
                   .withModule("org.apache.logging.log4j:log4j-api:jar:2.13.1")
                   .withModule("org.apache.logging.log4j:log4j-core:jar:2.13.1")
                   .withModule("org.moditect.layrry.examples.links:layrry-links-logconfig:1.0.0")

                .layer("platform")
                    .withParent("log")
                    .withParent("vertx")
                    .withModule("org.moditect.layrry:layrry-platform:1.0.0.Alpha1")
                    .withModule("org.moditect.layrry.examples.links:layrry-links-core:1.0.0")
                .build();

            layers.run("org.moditect.layrry.examples.links.core/org.moditect.layrry.examples.links.core.LayrryLinks", "");

Everything works fine except existing plugins (like "layrry-examples/vertx-links/staging/route-plugins1/layrry-links-membership-1.0.0.jar") which aren't loaded at startup.

Removing and adding "route-plugins1/layrry-links-membership-1.0.0.jar" after startup will detect and load the plugin as expected.

Do you know what can be missing in my use case to prevent loading plugins during startup ?

@treilhes
Copy link
Author

A bit of debugging later, it seems an additional layer must be created to handle loading plugins at startup.

.layer("plugins1")
    .withParent("platform")
    .withParent("log")
    .withModulesIn(pluginsPath)

But it feels a bit like breaking the DRY principle as it uses the same parameters than the pluginsDirectory call:

.pluginsDirectory("plugins1", pluginsPath, List.of("platform", "log"))

Can you confirm it is the right solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant