Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README to include Maven setup #36

Open
boxleytw opened this issue Feb 27, 2021 · 7 comments
Open

README to include Maven setup #36

boxleytw opened this issue Feb 27, 2021 · 7 comments

Comments

@boxleytw
Copy link

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.

@bnorm
Copy link
Owner

bnorm commented Feb 27, 2021

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.

@bnorm
Copy link
Owner

bnorm commented Mar 4, 2021

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

@mikehearn
Copy link

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:

  1. Download the code, fix the compiler name spacing issue as discussed in kotlin 1.4.30: PowerAssertComponentRegistrar is not compatible with this version of compiler #38. It's a two line fix.
  2. 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>

@mikehearn
Copy link

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.

@bnorm
Copy link
Owner

bnorm commented Apr 1, 2021

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.

@mikehearn
Copy link

You are correct! That does indeed work. Perhaps that version can just be renamed.

@binkley
Copy link

binkley commented Apr 2, 2021

@mikehearn Thank you for the POM snippet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants