https://kotlinlang.org logo
#korge
Title
# korge
g

Gregor Zeitlinger

12/30/2020, 9:29 AM
Hi, I'd like to use java sources for the jvm target 1. I've played around with using KMP plugin directly, but this didn't work 2. Then I tried to modify the plugin, but the new plugin was not used
Copy code
Index: korge-gradle-plugin/src/main/kotlin/com/soywiz/korge/gradle/targets/jvm/Jvm.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/korge-gradle-plugin/src/main/kotlin/com/soywiz/korge/gradle/targets/jvm/Jvm.kt b/korge-gradle-plugin/src/main/kotlin/com/soywiz/korge/gradle/targets/jvm/Jvm.kt
--- a/korge-gradle-plugin/src/main/kotlin/com/soywiz/korge/gradle/targets/jvm/Jvm.kt	(revision Staged)
+++ b/korge-gradle-plugin/src/main/kotlin/com/soywiz/korge/gradle/targets/jvm/Jvm.kt	(date 1609320472418)
@@ -9,6 +9,7 @@
 import org.gradle.api.tasks.bundling.*
 import org.gradle.api.tasks.testing.*
 import org.gradle.jvm.tasks.Jar
+import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
 import org.jetbrains.kotlin.gradle.plugin.mpp.*
 import proguard.gradle.*
 
@@ -19,6 +20,7 @@
 	val jvmTarget = jvmPreset.createTarget("jvm")
 	gkotlin.targets.add(jvmTarget)
 	//jvmTarget.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
+    jvmTarget.withJava()
 
 	project.korge.addDependency("jvmMainImplementation", "org.jetbrains.kotlin:kotlin-stdlib-jdk8")
 	project.korge.addDependency("jvmTestImplementation", "org.jetbrains.kotlin:kotlin-test")
Oh, I need to set the version explicitly:
Copy code
dependencies {
        classpath("com.soywiz.korlibs.korge.plugins:korge-gradle-plugin:2.0.0.2")
    }
then I get
Copy code
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.soywiz.korlibs.klock:klock:2.0.3.
     Required by:
         project :
      > The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally. However we cannot choose between the following variants of com.soywiz.korlibs.klock:klock:2.0.3:
          - debugApiElements-published
          - debugRuntimeElements-published
          - jvmApiElements-published
          - jvmRuntimeElements-published
          - releaseApiElements-published
          - releaseRuntimeElements-published
        All of them match the consumer attributes:
          - Variant 'debugApiElements-published' capability com.soywiz.korlibs.klock:klock:2.0.3 declares an API of a component:
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
          - Variant 'debugRuntimeElements-published' capability com.soywiz.korlibs.klock:klock:2.0.3 declares a runtime of a component:
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
          - Variant 'jvmApiElements-published' capability com.soywiz.korlibs.klock:klock:2.0.3 declares an API of a component, packaged as a jar:
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
          - Variant 'jvmRuntimeElements-published' capability com.soywiz.korlibs.klock:klock:2.0.3 declares a runtime of a component, packaged as a jar:
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
          - Variant 'releaseApiElements-published' capability com.soywiz.korlibs.klock:klock:2.0.3 declares an API of a component:
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
          - Variant 'releaseRuntimeElements-published' capability com.soywiz.korlibs.klock:klock:2.0.3 declares a runtime of a component:
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
seems it got confused about
org.jetbrains.kotlin.platform.type
I tried to uncomment `
Copy code
jvmTarget.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
but that didn't help
d

Deactivated User

12/31/2020, 10:16 AM
Did you manage to solve the issue?
g

Gregor Zeitlinger

12/31/2020, 10:31 AM
No, I built the project as a library and included that instead
d

Deactivated User

01/02/2021, 6:13 PM
and can you make your libraries depend on java 8 instead of java 11? if not, you would have to specify the attribute when requesting the artifact (though I don't remember how to do that and it is a bit strange)
3 Views