Kotlin compiler plugins list is unclear


#1

Maybe this article can be updated because it seems out of date at least wrt maven, or at least not compatible with spring https://blog.jetbrains.com/kotlin/2016/12/kotlin-1-0-6-is-here/

From the article it says:

<!-- Or "jpa" for the Java Persistence annotation support -->
<plugin>no-arg</plugin>

But neither no-arg or jpa work. Both give an error like this

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.1.4:compile (compile) on project pingzee-api: Plugin not found: no-arg: java.util.NoSuchElementException
[ERROR] role: org.jetbrains.kotlin.maven.KotlinMavenPluginExtension
[ERROR] roleHint: no-arg
[ERROR] -> [Help 1]


#2

Please see the current list of compiler plugins and their usage examples here: http://kotlinlang.org/docs/reference/compiler-plugins.html


#3

Thats the article I was referencing and having problems with when using
spring. Maybe the docs could reference versions somehow? I understand that
many variables aren involved though eg kotlin, spring plugins, maven
plugins, gradle plugins… and unfortubately ive gone over this doc
thoroughly and am running into issues with maven and spring.

So the question is how to better troubleshoot and fix for a stable app?


#4

It seems that you’re using maven and didn’t specify for kotlin maven plugin where to get no-arg compiler plugin. Note that plugin/dependencies block in the documentation.
http://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin

<plugin>
    <artifactId>kotlin-maven-plugin</artifactId>
    <groupId>org.jetbrains.kotlin</groupId>
    <version>${kotlin.version}</version>

    <configuration>
        <compilerPlugins>
            <!-- Or "jpa" for JPA support -->
            <plugin>no-arg</plugin>
        </compilerPlugins>

        <pluginOptions>
            <option>no-arg:annotation=com.my.Annotation</option>
            <!-- Call instance initializers in the synthetic constructor -->
            <!-- <option>no-arg:invokeInitializers=true</option> -->
        </pluginOptions>
    </configuration>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-noarg</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
    </dependencies>
</plugin>

kotlin.version is a property that specifies kotlin version to use, the latest one is 1.1.4-3

If that doesn’t help, please create a minimal repro maven project and post it here.


#5

I’d like to know if this falls into the “least astonishing” expectations for a related compilerPlugin quandary-- kotlin-js-DCE

                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>js</goal>
                    </goals>
                    <configuration>
                        <sourceDirs>
                            <source>src/main/java</source>
                            <source>target/generated-sources/license</source>
                        </sourceDirs>
                        <compilerPlugins>
                            <compilerPlugin>kotlin-js-dce</compilerPlugin>
                        </compilerPlugins>
                    </configuration>
                </execution>

this does not seem supported right now in the plugin, but doesn’t seem like it deserves a big production for a maven project.