Hello,
I am trying to use kotlinc compiler with target JVM and add a jar file to the classpath that references other jars in its manifest. Kotlinc seem to ignore this attribute.
Example:
I have a class
package testdataclass;
data class TestDataClass(id: String)
in project A and I compile it into a jar file datalib.jar. Then I have another project B that uses this class:
import testdataclass.TestDataClass
fun main(args: Array<String>) {
val d = TestDataClass("id")
println("Hello World $d")
}
I create another jar called refjar.jar with the following manifest:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.13
Created-By: 9+176 (Oracle Corporation)
Class-Path: datalib.jar
When I add datalib.jar directly to the compile classpath, it works:
kotlinc -cp datalib.jar src/* -d hello.jar
When I add the refjar.jar to the compile classpath, it does not:
kotlinc -cp refjar.jar src/* -d hello.jar
src/HelloKotlin.kt:1:8: error: unresolved reference: testdataclass
import testdataclass.TestDataClass
^
src/HelloKotlin.kt:4:12: error: unresolved reference: TestDataClass
val d = TestDataClass(“id”)
For comparison, the javac compiler does recognize the Class-Path attribute. Given this example class:
import testdataclass.TestDataClass;
public class Hello {
public static void main(String[] args) {
final TestDataClass tdc = new TestDataClass("id");
System.out.println("Hello " + tdc);
}
}
The following command succeeds:
javac -cp refjar.jar srcjava/Hello.java -d classesjava/
Am I missing something here? Or is Class-Path attribute not supported for Kotlinc classpath?
Why are we trying to do this? Our compile classpath is so huge, that we cannot launch kotlinc, because the underlying OS says “Argument list too long” and creating a so called manifest jar that contains references to all the needed jars is a way around that. We are using Apache Ant to compile, but the problem is reproducible with the cli compiler also.