1
votes

I followed the docs under https://github.com/manifold-systems/manifold/tree/master/manifold-deps-parent/manifold-json and deployed a jar, that provides just the User classes, using the Maven compile plugin as documented:

<build>
    <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
        <compilerArgs>
            <!-- Configure manifold plugin-->
            <arg>-Xplugin:Manifold</arg>
            <arg>-Amanifold.source.json=^com\.example\.schemas\.User$</arg>
        </compilerArgs>
        <!-- Add the processor path for the plugin (required for Java 9+) -->
        <annotationProcessorPaths>
            <path>
            <groupId>systems.manifold</groupId>
            <artifactId>manifold-json</artifactId>
            <version>2020.1.44</version>
            </path>
        </annotationProcessorPaths>
        </configuration>

My other project uses this package as dependency and the following code works fine:

import com.example.schemas.User;
...

User user = User.builder("Scott McKinney", "[email protected]")
  .build();

But this throws an exception:

User user = User.load().fromJson("{\"name\": \"Scott McKinney\", \"email\": \"[email protected]\"}");

java.lang.ClassCastException: class manifold.json.rt.api.DataBindings 
  cannot be cast to class com.example.schemas.User (manifold.json.rt.api.DataBindings 
  and com.example.schemas.User are in unnamed module of loader 'app')
After a discussion with a colleague, I found out that the exception disappears when I also do the Manifold compilation in the other project which uses com.example.schemas.User.Kevin