Unable to compile library (#2)
Unknown opened 4 years ago

According to your comments, in order to get new version of the library I should do:

You have to checkout latest code from repository. Then you have to run 'ant jar' and copy created cn1lib to convene project.

However, I am getting error and I am unable to compile the project:

kobit:halcyon-cn1/ (master) $ ant -version                                                                        [13:00:53]
Apache Ant(TM) version 1.10.9 compiled on September 27 2020
kobit:halcyon-cn1/ (master) $ java -version                                                                       [13:02:31]
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
kobit:halcyon-cn1/ (master) $ ant jar                                                                             [13:02:35]
Buildfile: /Users/kobit/projects/halcyon-cn1/build.xml
  [typedef] Could not load definitions from resource org/jetbrains/kotlin/ant/antlib.xml. It could not be found.

-pre-init:

-init-private:

-init-user:

-init-project:

-init-macrodef-property:

-do-init:

-post-init:

-init-check:

-init-ap-cmdline-properties:

-init-macrodef-javac-with-processors:
  [typedef] Could not load definitions from resource org/jetbrains/kotlin/ant/antlib.xml. It could not be found.

-init-macrodef-javac-without-processors:

-init-macrodef-javac:

-init-macrodef-test-impl:

-init-macrodef-junit-init:

-init-macrodef-junit-single:

-init-macrodef-junit-batch:

-init-macrodef-junit:

-init-macrodef-junit-impl:

-init-macrodef-testng:

-init-macrodef-testng-impl:

-init-macrodef-test:

-init-macrodef-junit-debug:

-init-macrodef-junit-debug-batch:

-init-macrodef-junit-debug-impl:

-init-macrodef-test-debug-junit:

-init-macrodef-testng-debug:

-init-macrodef-testng-debug-impl:

-init-macrodef-test-debug-testng:

-init-macrodef-test-debug:

-init-debug-args:

-init-macrodef-nbjpda:

-init-macrodef-debug:

-init-macrodef-java:

-init-presetdef-jar:

-init-ap-cmdline-supported:

-init-ap-cmdline:

init:

-deps-jar-init:
   [delete] Deleting: /Users/kobit/projects/halcyon-cn1/build/built-jar.properties

deps-jar:
  [typedef] Could not load definitions from resource org/jetbrains/kotlin/ant/antlib.xml. It could not be found.

-warn-already-built-jar:
[propertyfile] Updating property file: /Users/kobit/projects/halcyon-cn1/build/built-jar.properties

-check-automatic-build:

-clean-after-automatic-build:

-verify-automatic-build:

-pre-pre-compile:

-pre-compile:
     [echo] Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
     [echo]         code size and wider device support

BUILD FAILED
/Users/kobit/projects/halcyon-cn1/build.xml:32: javac doesn't support the nested "withKotlin" element.

Total time: 0 seconds
kobit:halcyon-cn1/ (master) $

Please assist with the project compilation. Perhaps I am missing something or maybe I need some additional tools?

Unknown commented 4 years ago

You have to update Kotlin library location in file codenameone_kotlin.properties. If you use SDKMAN, and result of sdk h kotlin 1.4.10 is /Users/bmalkow/.sdkman/candidates/kotlin/1.4.10% then line in this file should looks like:

kotlin.lib=/Users/bmalkow/.sdkman/candidates/kotlin/1.4.10/lib

Or simply grab this file from other CN1 project what works.

Unknown commented 4 years ago

This helped but your suggested solution has a few problems:

  • First, it points to the most recent version of Kotlin - 1.4.x which is incompatible with CN1
  • Minor and easily fixable, it points to a user's home folder which then causes problem when the project is compiled on different user's computer

I think it IntelliJ is usually installed in standard location, so, it would be best to use path to the IntelliJ Kotlin plugin location, which makes it most portable. Then it does not directly depends on Kotlin version. Like this:

kotlin.lib=/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc/lib

In any case, the CN1 supports only Kotlin ver. 1.3.72, and the library compilation fails under this Kotlin version. I would suggest to install in IntelliJ kotlin plugin for this particular version of the Kotlin, to make sure our code is compatible.

Here is compilation output:

kobit:halcyon-cn1/ (master) $ ant jar                                                                             [13:10:19]
Buildfile: /Users/kobit/projects/halcyon-cn1/build.xml

-pre-init:

-init-private:

-init-user:

-init-project:

-init-macrodef-property:

-do-init:

-post-init:

-init-check:

-init-ap-cmdline-properties:

-init-macrodef-javac-with-processors:

-init-macrodef-javac-without-processors:

-init-macrodef-javac:

-init-macrodef-test-impl:

-init-macrodef-junit-init:

-init-macrodef-junit-single:

-init-macrodef-junit-batch:

-init-macrodef-junit:

-init-macrodef-junit-impl:

-init-macrodef-testng:

-init-macrodef-testng-impl:

-init-macrodef-test:

-init-macrodef-junit-debug:

-init-macrodef-junit-debug-batch:

-init-macrodef-junit-debug-impl:

-init-macrodef-test-debug-junit:

-init-macrodef-testng-debug:

-init-macrodef-testng-debug-impl:

-init-macrodef-test-debug-testng:

-init-macrodef-test-debug:

-init-debug-args:

-init-macrodef-nbjpda:

-init-macrodef-debug:

-init-macrodef-java:

-init-presetdef-jar:

-init-ap-cmdline-supported:

-init-ap-cmdline:

init:

-deps-jar-init:
   [delete] Deleting: /Users/kobit/projects/halcyon-cn1/build/built-jar.properties

deps-jar:

-warn-already-built-jar:
[propertyfile] Updating property file: /Users/kobit/projects/halcyon-cn1/build/built-jar.properties

-check-automatic-build:

-clean-after-automatic-build:

-verify-automatic-build:

-pre-pre-compile:

-pre-compile:
     [echo] Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
     [echo]         code size and wider device support
    [javac] Compiling 126 source files to /Users/kobit/projects/halcyon-cn1/build/tmp
    [javac] Compiling [/Users/kobit/projects/halcyon-cn1/src] => [/Users/kobit/projects/halcyon-cn1/build/tmp]
    [javac] warning: classpath entry points to a non-existent location: /Users/kobit/projects/halcyon-cn1/override
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/requests/AbstractRequest.kt:37:40: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     private val callHandlerOnSent: Boolean,
    [javac]                                        ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/requests/RequestBuilder.kt:75:28: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     callHandlerOnSent: Boolean,
    [javac]                            ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/requests/RequestBuilder.kt:90:42: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     private val transform: (value: Any) -> V,
    [javac]                                          ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/avatar/UserAvatarModule.kt:133:104: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             val bytes: Int, val height: Int?, val id: String, val type: String, val url: String?, val width: Int?,
    [javac]                                                                                                        ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/caps/EntityCapabilitiesModule.kt:40:95: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             val node: String, val identities: List<DiscoveryModule.Identity>, val features: List<String>,
    [javac]                                                                                               ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/discovery/DiscoveryModule.kt:45:94: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             val jid: JID, val node: String?, val identities: List<Identity>, val features: List<String>,
    [javac]                                                                                              ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/jingle/AstractJingleSession.kt:33:36: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val initiationType: InitiationType,
    [javac]                                    ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/jingle/JingleModule.kt:63:47: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val supportsMessageInitiation: Boolean = true,
    [javac]                                               ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/jingle/JingleModule.kt:148:44: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             action: MessageInitiationAction, jid: JID,
    [javac]                                            ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/jingle/JingleModule.kt:178:72: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             jid: JID, sid: String, contents: List<Content>, bundle: List<String>?,
    [javac]                                                                        ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/jingle/JingleModule.kt:209:72: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             jid: JID, sid: String, contents: List<Content>, bundle: List<String>?,
    [javac]                                                                        ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/jingle/JingleModule.kt:275:27: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val bundle: List<String>?,
    [javac]                           ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/mam/MAMModule.kt:39:111: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val resultStanza: Message, val queryId: String, val id: String, val forwardedStanza: ForwardedStanza<Message>,
    [javac]                                                                                                               ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/mam/MAMModule.kt:119:81: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             rsm: RSM? = null, with: String? = null, start: Long? = null, end: Long? = null,
    [javac]                                                                                 ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/mix/MIXModule.kt:152:96: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             invitee: BareJID, channel: BareJID, inviter: BareJID = myJID().bareJID, token: String? = null,
    [javac]                                                                                                ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/mix/MIXModule.kt:169:68: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             channel: BareJID, nick: String, invitation: MIXInvitation? = null,
    [javac]                                                                    ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/presence/PresenceModule.kt:41:99: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val jid: BareJID, val status: String?, val presence: Presence, val lastReceivedPresence: Presence,
    [javac]                                                                                                   ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/presence/PresenceModule.kt:98:91: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             jid: JID? = null, type: PresenceType? = null, show: Show? = null, status: String? = null,
    [javac]                                                                                           ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/presence/PresenceModule.kt:142:46: error: unresolved reference: minByOrNull
    [javac]                                     .map { presence -> Envelope(presence) }.minByOrNull { envelope -> envelope.comp }?.presence
    [javac]                                              ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/presence/PresenceModule.kt:142:60: error: cannot infer a type for this parameter. Please specify it explicitly.
    [javac]                                     .map { presence -> Envelope(presence) }.minByOrNull { envelope -> envelope.comp }?.presence
    [javac]                                                            ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:46:90: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val pubSubJID: JID?, val stanza: Message, val nodeName: String, val items: List<Element>,
    [javac]                                                                                          ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:116:89: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val node: String, val jid: JID, var state: SubscriptionState, var subid: String? = null,
    [javac]                                                                                         ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:149:67: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             pubSubJID: JID, node: String, configForm: JabberDataForm? = null,
    [javac]                                                                   ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:234:53: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             requestXMLNS: String, pubSubJID: JID, node: String,
    [javac]                                                     ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:274:31: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             pubSubJID: JID, node: String,
    [javac]                               ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:301:66: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             pubSubJID: JID, node: String, subscriptions: List<Subscription>,
    [javac]                                                                  ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:383:49: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             jid: JID, node: String, itemId: String? = null,
    [javac]                                                 ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:432:69: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             jid: JID?, node: String, itemId: String?, payload: Element? = null,
    [javac]                                                                     ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/pubsub/PubSubModule.kt:479:34: error: the feature "trailing commas" is only available since language version 1.4
    [javac]             jid: JID?, node: String? = null,
    [javac]                                  ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/roster/RosterModule.kt:76:61: error: the feature "trailing commas" is only available since language version 1.4
    [javac]     val annotations: Array<RosterItemAnnotation> = emptyArray(),
    [javac]                                                             ^

BUILD FAILED
/Users/kobit/projects/halcyon-cn1/build.xml:32: Compile failed; see the compiler error output for details.

Total time: 12 seconds
Unknown commented 4 years ago

I removed all "trailing comas" errors but still the compilation fails with the following errors:

kobit:halcyon-cn1/ (master*) $ ant jar                                                                            [13:56:16]
Buildfile: /Users/kobit/projects/halcyon-cn1/build.xml

-pre-init:

-init-private:

-init-user:

-init-project:

-init-macrodef-property:

-do-init:

-post-init:

-init-check:

-init-ap-cmdline-properties:

-init-macrodef-javac-with-processors:

-init-macrodef-javac-without-processors:

-init-macrodef-javac:

-init-macrodef-test-impl:

-init-macrodef-junit-init:

-init-macrodef-junit-single:

-init-macrodef-junit-batch:

-init-macrodef-junit:

-init-macrodef-junit-impl:

-init-macrodef-testng:

-init-macrodef-testng-impl:

-init-macrodef-test:

-init-macrodef-junit-debug:

-init-macrodef-junit-debug-batch:

-init-macrodef-junit-debug-impl:

-init-macrodef-test-debug-junit:

-init-macrodef-testng-debug:

-init-macrodef-testng-debug-impl:

-init-macrodef-test-debug-testng:

-init-macrodef-test-debug:

-init-debug-args:

-init-macrodef-nbjpda:

-init-macrodef-debug:

-init-macrodef-java:

-init-presetdef-jar:

-init-ap-cmdline-supported:

-init-ap-cmdline:

init:

-deps-jar-init:
   [delete] Deleting: /Users/kobit/projects/halcyon-cn1/build/built-jar.properties

deps-jar:

-warn-already-built-jar:
[propertyfile] Updating property file: /Users/kobit/projects/halcyon-cn1/build/built-jar.properties

-check-automatic-build:

-clean-after-automatic-build:

-verify-automatic-build:

-pre-pre-compile:

-pre-compile:
     [echo] Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
     [echo]         code size and wider device support
    [javac] Compiling 126 source files to /Users/kobit/projects/halcyon-cn1/build/tmp
    [javac] Compiling [/Users/kobit/projects/halcyon-cn1/src] => [/Users/kobit/projects/halcyon-cn1/build/tmp]
    [javac] warning: classpath entry points to a non-existent location: /Users/kobit/projects/halcyon-cn1/override
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/presence/PresenceModule.kt:142:46: error: unresolved reference: minByOrNull
    [javac]                                     .map { presence -> Envelope(presence) }.minByOrNull { envelope -> envelope.comp }?.presence
    [javac]                                              ^
    [javac] /Users/kobit/projects/halcyon-cn1/src/tigase/halcyon/core/xmpp/modules/presence/PresenceModule.kt:142:60: error: cannot infer a type for this parameter. Please specify it explicitly.
    [javac]                                     .map { presence -> Envelope(presence) }.minByOrNull { envelope -> envelope.comp }?.presence
    [javac]                                                            ^

BUILD FAILED
/Users/kobit/projects/halcyon-cn1/build.xml:32: Compile failed; see the compiler error output for details.

Total time: 11 seconds
Unknown commented 4 years ago

Minor side-comment:

I think it IntelliJ is usually installed in standard location, so, it would be best to use path to the IntelliJ Kotlin plugin location, which makes it most portable. Then it does not directly depends on Kotlin version. Like this:

kotlin.lib=/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc/lib

This doesn't seem to be the case if you use JetbrainsToolbox to install Idea. In that case it's /Users/wojtek/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app. Moreover, above location still is "fixed" and tied to the OS.

Unknown commented 4 years ago

Thank you for the input.

I gave up on Toolbox a while ago because it messed licenses up for me. It was always confused which IDE is licensed and which is Community.

The above location, I gave is fixed, indeed and indeed OS dependent but at least it is stable on this OS. And right now we all use the same OS, so it seems like the best solution.

However, I am open to different suggestions. I am not sure if the properties file can use ENV variables. If it could, then universal solution would be very simple and easy. If it cannot have use ENV variables we could all agree on one, fixed location for kotlinc and then have a fixed location in the properties file.

Unknown commented 4 years ago

Ok, I found a solution which seems to be working. It is, indeed, based on ENV variables. It does need a little bit of editing build file and properties but these are really minor

build.xml file modifications - add a single line:

<property environment="env" />

Just after second XML line starting with <description> and it must be before line with kotlin properties file loading:

<property file="codenameone_kotlin.properties"/>

In my case, the beginning of the build.xml file looks like this:

<project name="LibraryProject" default="default" basedir=".">
    <description>Builds, tests, and runs the project LibraryProject.</description>
    <property environment="env" />
    <property file="codenameone_kotlin.properties"/>
    <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
    <import file="nbproject/build-impl.xml"/>
    <property file="codenameone_settings.properties"/>

   <!-- following target was just added for testing purposes and can be skipped -->
    <target name="testProps">
        <echo message="${env.KOTLINC_LIB}"/>
        <echo message="${kotlin.lib}"/>
    </target>

Now the codenameone_kotlin.properties file should look like this:

#Kotlin properties automatically updated at 1596694293813
#Thu Aug 06 08:11:33 CEST 2020
kotlin.lib=${env.KOTLINC_LIB}

Of course the KOTLINC_LIB env variable must be set to a correct path:

 $ export KOTLINC_LIB="/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc/lib"

This should solve the problem on all platforms and OSes and different way we have system configured.

@bmalkow as you maintain the code repo, could you please make the necessary adjustments in the build files?

Unknown commented 4 years ago

Can we apply the solution above? If so, please do and you can then close the ticket.

Unknown commented 4 years ago

I did it. But I did it in a bit different way. Instead of using new KOTLINC_LIB variable I decided to use more common KOTLIN_HOME environment variable, what you should have set in your system (like JAVA_HOME).

Unknown commented 4 years ago

Works for me, thank you.

issue 1 of 1
Type
Bug
Issue Votes (0)
Watchers (0)
Reference
tigase/_libraries/halcyon-cn1#2
Please wait...
Page is in error, reload to recover