kotlin-power-assert
kotlin-power-assert copied to clipboard
README to include Maven setup
Thanks for this plugin!
I'll figure this out for myself, but it would be helpful if README.md
included instructions for Maven as well as Gradle.
I'm not sure this is going to be possible without a Maven specific artifact. Looking at the documentation for the allopen plugin seems to imply that at least given it's use of kotlin-maven-allopen
as the dependency: https://kotlinlang.org/docs/all-open-plugin.html#maven
It's been years since I've used Maven so if you give this a try, do let me know the results. It seems to me like Kotlin is pushing the use of Gradle, given Kotlin's own pause on Maven improvements on their roadmap. I'm definitely open to a contribution for this, but it will take a bit of convincing before I attempt this myself.
If I ever get around to it this might a good reference implementation for a maven plugin (besides the official ones): https://www.github.com/intuit/hooks/tree/master/maven-plugin
You don't need a Maven plugin. Yes, that's how JetBrains do it but as far as I can tell it's completely superfluous over-engineering (seems to be a common problem with java build systems!).
I got it working by doing these steps:
- Download the code, fix the compiler name spacing issue as discussed in #38. It's a two line fix.
- Pass the correct command line parameters to the compiler by hand.
Example:
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>15</jvmTarget>
<args>
<arg>-Xuse-ir</arg>
<arg>-P</arg><arg>plugin:com.bnorm.kotlin-power-assert:function=kotlin.assert</arg>
</args>
</configuration>
<dependencies>
<dependency>
<groupId>com.bnorm.power</groupId>
<artifactId>kotlin-power-assert-plugin</artifactId>
<version>0.8.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
On further investigation, it appears that for maven->JPS sync to work properly, the Maven plugin is required. To use Maven directly, it isn't important. So you may need to delegate build actions to Maven. I prefer not to do that, and you can fix JPS by editing the IML file for the project or module to include:
<option value="$MAVEN_REPOSITORY$/com/bnorm/power/kotlin-power-assert-plugin/0.8.0-SNAPSHOT/kotlin-power-assert-plugin-0.8.0-SNAPSHOT.jar" />
but of course this isn't ideal. Really, the whole maven/gradle/compiler integration dance is way over the top. IntelliJ could easily generate the project from the POM correctly without this form of assistance. I'll file an IntelliJ bug.
Step 1 shouldn't be required if you are doing all of this manually, just use artifact id kotlin-power-assert-plugin-natvie
which is compiled against the non-embedded compiler dependency.
You are correct! That does indeed work. Perhaps that version can just be renamed.
@mikehearn Thank you for the POM snippet!