You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/03/03 01:55:30 UTC

[GitHub] [nifi] MikeThomsen opened a new pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

MikeThomsen opened a new pull request #5830:
URL: https://github.com/apache/nifi/pull/5830


   <!--
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
         http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
   -->
   Thank you for submitting a contribution to Apache NiFi.
   
   Please provide a short description of the PR here:
   
   #### Description of PR
   
   _Enables X functionality; fixes bug NIFI-YYYY._
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [ ] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [ ] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [ ] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [ ] Have you written or updated unit tests to verify your changes?
   - [ ] Have you verified that the full build is successful on JDK 8?
   - [ ] Have you verified that the full build is successful on JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1057581983


   [Kotlin_Test.xml.txt](https://github.com/apache/nifi/files/8174188/Kotlin_Test.xml.txt)
   
   Attached is a test flow


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1073895638


   The inability to get the `processor` object from the interpreted script appears to be a bug and worth bringing to JetBrains's attention.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1058366482


   @joewitt Alright. I'm going to leave the unit test in there, but disable it unless it can find the kotlin scripting engine.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on a change in pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on a change in pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#discussion_r823863797



##########
File path: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
##########
@@ -12,4 +12,5 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-org.apache.nifi.processors.script.engine.ClojureScriptEngineFactory
\ No newline at end of file
+org.apache.nifi.processors.script.engine.ClojureScriptEngineFactory
+org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory

Review comment:
       I think that was a carry over from about 2 years ago when IIRC you had to add it in manually. I'll try it out without and see what happens since the newer samples don't call for this.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1063102881


   @mattyb149 can you take a quick look at this since we're talking about a 1.16 release?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] mattyb149 commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1064465528


   Any chance you could add a TestInvokeKotlin unit test using InvokeScriptedProcessor? I don't know Kotlin and it would take me forever to get one going, but if you have an example I could use both the ExecuteScript and InvokeScriptedProcessor examples in my blog (unless you'd like to blog about it once it's released)?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1065080999


   @mattyb149 as of right now, InvokeScriptedProcessor won't work with Kotlin for two reasons:
   
   * Kotlin appears to have a bug in the JSR223 that won't allow us to get the `processor` object from the script directly. This is fixable with a workaround that calls a Kotlin function to get the object according to what I found on SO.
   * Kotlin is somewhat slower than Java at compiling, and InvokeScriptedProcessor only uses Invocable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] mattyb149 commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1065280072


   Should we add in specific code to exclude Kotlin from the other scripted components then? Even though it apparently implements Invocable, if we can't actually use it then we shouldn't have it in the drop-down list. I think we do the same for Jython


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] MikeThomsen commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1066174058


   @mattyb149 I think we're going to have to do that for now. QQ: was there a technical reason why we use `Invocable` and not `CompiledScript` in the other components?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] joewitt commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
joewitt commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1058350160


   definitely make it optionally included by some opt-in flag during the build.  we cannot afford the 60MB in the convenience binary.  Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] mattyb149 commented on a change in pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#discussion_r823840634



##########
File path: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
##########
@@ -12,4 +12,5 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-org.apache.nifi.processors.script.engine.ClojureScriptEngineFactory
\ No newline at end of file
+org.apache.nifi.processors.script.engine.ClojureScriptEngineFactory
+org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory

Review comment:
       Is this necessary for the ScriptEngineFactory to be picked up by the ServiceLoader? It causes warnings when building without the profile enabled, and I'm curious as to why the ServiceLoader wouldn't pick it up if the library was included...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] mattyb149 commented on pull request #5830: NIFI-4307 Add support for Kotlin to the scripting bundle

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on pull request #5830:
URL: https://github.com/apache/nifi/pull/5830#issuecomment-1066178696


   I believe it was for two reasons:
   
   1) To allow for Invocable engines when they didn't compile the script. That's slower but if there are engines that do that we didn't want to exclude them. Looking at the existing engines I think we could use CompiledScript but I kind of recall that something like `eval(Bindings)` didn't actually update the bindings on the compiled script for some engine(s). Please feel free to look into switching to CompiledScript over Invocable if that's not the case.
   2) To call methods not on the interface but useful for the scripted component, like `setLogger()`. Not sure we could do that with a CompiledScript.eval(), but maybe we can take a different approach.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org