manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.43k stars 125 forks source link

String template doesn't work with "provided" scope #441

Closed shai-almog closed 1 year ago

shai-almog commented 1 year ago

Describe the bug Compiling the following hello string template code produces the following error:

public class Main {
    public static void main(String[] args) {
        String world = args.length > 0 ? args[0] : "world";
        System.out.println("Hello $world!");
    }
}

Error:

/Users/shai/Library/Java/JavaVirtualMachines/openjdk-19.0.1/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=50837:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/shai/dev/java-book/Manifold/ManifoldStringTemplates/target/classes:/Users/shai/.m2/repository/systems/manifold/manifold-templates-rt/2023.1.5/manifold-templates-rt-2023.1.5.jar:/Users/shai/.m2/repository/systems/manifold/manifold-ext-rt/2023.1.5/manifold-ext-rt-2023.1.5.jar com.debugagent.stringtemplates.Main
Exception in thread "main" java.lang.NoClassDefFoundError: manifold/rt/api/IBootstrap
    at com.debugagent.stringtemplates.Main.<clinit>(Main.java:3)
Caused by: java.lang.ClassNotFoundException: manifold.rt.api.IBootstrap
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more

Removing the scope entry from the POM here solves the issue. At least for now. I'm assuming there might be a better fix but for now I will submit a pull request that removes it from the documentation. I assume this might be needed for Gradle too but I didn't test that.

        <dependency>
            <groupId>systems.manifold</groupId>
            <artifactId>manifold-rt</artifactId>
            <version>${manifold.version}</version>
            <scope>provided</scope>
        </dependency>