Search code examples
javaunit-testingintellij-ideapluginsintellij-plugin

How do I use the Manifold plugin with IntelliJ?


I'm attemting to use the Manifold plugin as follows:

@Test
    void printBoard() {
        @JailBreak TicTacToe game = new TicTacToe();
        game.printBoard();

        assertEquals("- ,- ,-\r\n- ,- ,-\r\n- ,- ,-", outputStreamCaptor.toString()
                .trim());
    }

I want to add some more assertions that test whether the board is printed correctly after I alter the private board variable in game (this is why I want to use the JailBreak annotation.

I've installed the plugin in Intellij by going to settings > plugins > searching for manifold > installing/applying it. I then restarted my IDE and no luck (compiler doesn't recognize @JailBreak).

Does anyone have any ideas about what could be going wrong? I'm using Java8 if that helps at all.


Solution

  • The Manifold plugin analyzes your project's build configuration to dynamically apply features, such as support for type-safe reflection via @Jailbreak. See the manifold-ext setup instructions. In Gradle terms, to support @Jailbreak your project must have an implementation dependency on manifold-ext-rt and an annotationProcessor dependency on manifold-ext. Additionally, you need to add the -Xplugin:Manifold compiler argument. This info is detailed in the setup docs.

    If you are not using Gradle or Maven, you can configure your IntelliJ project directly using Manifold binaries in your module's dependencies settings. You also need to directly set compiler arguments (-Xplugin:Manifold and -processorpath) via File | Settings | Build, Execution, Deployment | Compiler | Java Compiler.