我正在尝试从Kotlin文件引用Java类,但是问题是我无法引用包含Java源代码的软件包。
我正在尝试:
fun main.dmla.java.parser.DMLAParser.parseDmla(source: Source): Any {
val lexer = DMLALexer(CharStreams.fromString(source.characters.toString()))
val parser = DMLAParser(CommonTokenStream(lexer))
val walker = DmlaWalker()
return walker.visit(parser.model())
}
由于某种原因,我无法引用main.dmla.java包,因此无法访问DMLAParser类。
Maven pom.xml看起来像这样:
<parent>
<groupId>DMLAGraalVM</groupId>
<artifactId>DMLA-parent</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>language</artifactId>
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.3.21</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/dmla/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/dmla/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>dmla</finalName>
<artifactSet>
<excludes>
<exclude>org.graalvm.truffle:truffle-api</exclude>
<exclude>org.graalvm.truffle:truffle-dsl-processor</exclude>
<exclude>org.graalvm.truffle:truffle-tck</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我在做什么错了?