using Kotlin inside Jenkins Plugins

2,007 views
Skip to first unread message

Joseph P

unread,
Jan 17, 2018, 1:56:44 PM1/17/18
to Jenkins Developers
Hey there,

We need to solve a problem for those wanting to use Kotlin "stdlib-jre8"
I see two solutions
  1. Create a Jenkins Kotlin plugin for Kotlin standard library.
  2. Each plugin that uses Kotlin standard library can set plugin first class loader to true.
Looking at existing Kotlin plugins.

Some decided for plugin first class loader.

others are living a dangerous life:

This would hopefully help others in adopting Kotlin inside the Jenkins plugin community.

Best regards
Joseph

Joseph P

unread,
Jan 17, 2018, 2:02:56 PM1/17/18
to Jenkins Developers
Also there's the question of should Kotlin build steps be added to parent pom?

Robert Sandell

unread,
Jan 18, 2018, 6:44:31 AM1/18/18
to jenkin...@googlegroups.com
Does Kotlin have a deprecation/compatibility policy that is compatible with Jenkins? i.e. would a plugin compiled and tested against kotlin 1.3 work with kotlin 2,3,4 etc?

If that is the case then I think a kotlin-stdlib-plugin would be the best choice.

regarding the build step, we haven't even added the groovy build step to it yet so I don't know :)

/B

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/51d5e829-d4a8-4e86-9393-47ef74088714%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees, Inc.
CloudBees-Logo.png
Twitter: robert_sandell

Joseph P

unread,
Jan 18, 2018, 8:54:31 AM1/18/18
to Jenkins Developers
This should cover the compatibility question, https://kotlinlang.org/docs/reference/compatibility.html, seems like we would have to create a plugin for each 1.X version 😕 or we could probably do something with the compatibility modes

Seems gradle with gradle-jpi-plugin using the Kotlin Gradle DSL or groovy is the best choice then sadly gradle 4.x has issue with sezpoz when needing to process Jenkins annotation like @Extension and so on.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

Joseph P

unread,
Jan 18, 2018, 8:57:14 AM1/18/18
to Jenkins Developers
I might have misread it: 

Experimental features are not backwards compatible with different minor versions.
However for the JVM

Compatibility guarantees for Kotlin releases

Kotlin for JVM:

  • patch version updates (e.g. 1.1.X) are fully compatible;
  • minor version updates (e.g. 1.X) are backwards compatible.

Joseph P

unread,
Jan 18, 2018, 9:24:13 AM1/18/18
to Jenkins Developers
With that in mind, I will go ahead with creating a kotlin-stdlib-1-api-plugin to avoid plugins loading the incorrect major version of Kotlin.

Jesse Glick

unread,
Jan 18, 2018, 12:58:22 PM1/18/18
to Jenkins Dev
On Wed, Jan 17, 2018 at 2:02 PM, Joseph P <jose...@gmail.com> wrote:
> should Kotlin build steps be added to parent
> pom?

Please, no. I in fact have a to-do item to *remove* the support for
Groovy compilation from the parent POM. Plugin maintainers who wish to
use alternative languages or build technologies are on their own.

In general, core maintainers have had poor experiences with plugins
using alternative JVM languages. It seems neat on the face of it, but
turns into a serious maintenance burden for the ecosystem as a whole.
In particular there have been multiple recent disasters with
(J)Ruby-based plugins and I hope to find time to propose deprecating
the entire runtime system and rewriting in Java the handful of popular
plugins using it.

Joseph P

unread,
Jan 18, 2018, 1:27:10 PM1/18/18
to Jenkins Developers
Fair enough, if anything I would be happy to create a custom parent pom for other Kotlin based Jenkins plugins to use.

Already had to create a custom parent POM for the plugin to support Kotlin's split architecture of their standard library in jre7 and jre8

Jesse Glick

unread,
Jan 18, 2018, 4:03:09 PM1/18/18
to Jenkins Dev
On Thu, Jan 18, 2018 at 1:27 PM, Joseph P <jose...@gmail.com> wrote:
> I would be happy to create a custom parent pom for
> other Kotlin based Jenkins plugins to use.

If possible, it should extend `org.jenkins-ci.plugins:plugin` so as to
pick up common stuff.

Joseph P

unread,
Jan 18, 2018, 5:54:24 PM1/18/18
to Jenkins Developers
Done 👍
We use the parent POM to set Kotlin version and depend on `org.jenkins-ci.plugins:plugin` and then use the plugin pom for plugins to use.

Naming is still open for discussion tbh

I created a plugin using the Jenkins plugin archetypes and just changed the parent to the Kotlin plugin pom and BAM you could start using Kotlin 😎

Surprised how easy it was to setup with maven 👌
Reply all
Reply to author
Forward
0 new messages