Does anyone have an example of using power-assert ...
# power-assert
n
Does anyone have an example of using power-assert in a Maven build? I cannot for the life of me configure the power-assert compiler plugin to instrument my tests
b
You might try to follow the guide for the all-open plugin: https://kotlinlang.org/docs/all-open-plugin.html#maven. I believe
functions
is the option you want to use for each function you want to transform. Also, if you write up a YouTrack ticket I can make sure we get maven configuration tested and documented.
n
Aha! That gives me a better clue as to syntax
a
Thanks for creating the issue. I’ve triaged it and hope we can add the necessary information in the next sprint.
n
Thank you!
Until KT-68693 is implemented, is there anywhere I can see an example of how to use Power-Assert with Maven? I just cannot get it to work.
b
Now that I'm back from vacation and looking at this more closely, there currently isn't a way to configure power-assert for use in maven projects. It seems a special artifact is needed for maven support; something I missed. Again, feel free to create a YouTrack ticket for this, and hopefully we can get this added to 2.0.20 as it shouldn't take much effort.
Actually, it seems like something may still be possible based on this comment and following: https://github.com/bnorm/kotlin-power-assert/issues/36#issuecomment-812070220. I'll mess around with this more and see if I can come up with an example.
I was able to get it working with the following. Hopefully this works for you as well:
Copy code
<plugin>
    <artifactId>kotlin-maven-plugin</artifactId>
    <groupId>org.jetbrains.kotlin</groupId>
    <version>2.0.0</version>
    
    ...

    <configuration>
        <args>
            <arg>-P</arg><arg>plugin:org.jetbrains.kotlin.powerassert:function=kotlin.require,plugin:org.jetbrains.kotlin.powerassert:function=kotlin.check</arg>
        </args>
    </configuration>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-power-assert-compiler-plugin</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
</plugin>
❤️ 1
n
Thank you. I’ll work on this when I get back to London.
I got it working. Many thanks for your help.