我试图在scala代码库中引用生成的avro文件。我正在使用commercehub avro gradle插件生成avro java编译文件,它们在 build/generated-main-avro-java/
我的gradle档案就是这样的。问题是java文件生成正确,但我无法在scala代码中导入它们。你知道我可能做错了什么吗?
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath "gradle.plugin.com.lightbend.akka.grpc:akka-grpc-gradle-plugin:0.7.2"
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
}
}
plugins {
id 'scala'
id 'application'
id "com.google.protobuf" version "0.8.8"
id 'com.github.johnrengelman.shadow' version '5.2.0'
id "com.commercehub.gradle.plugin.avro" version "0.9.1"
}
apply plugin: 'java'
apply plugin: 'com.lightbend.akka.grpc.gradle'
apply plugin: 'com.google.protobuf'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: "com.commercehub.gradle.plugin.avro"
akkaGrpc {
language = "Scala"
generateClient = true
generateServer = true
}
mainClassName = 'com.test.App'
repositories {
mavenLocal()
mavenCentral()
google()
}
tasks.withType(ScalaCompile) {
ScalaCompileOptions.metaClass.daemonServer = true
ScalaCompileOptions.metaClass.fork = true
ScalaCompileOptions.metaClass.useAnt = false
ScalaCompileOptions.metaClass.useCompileDaemon = false
}
def scalaVersion = "2.12"
ext.elasticAPMVersion = "1.14.0"
// Define a separate configuration for managing the dependency on Jetty ALPN agent.
configurations {
alpnagent
}
dependencies {
...
...
...
...
...
implementation "org.apache.avro:avro:1.9.2"
}
test {
jvmArgs "-javaagent:" + configurations.alpnagent.asPath
maxParallelForks = 1
}
run {
mainClassName = mainClassName
standardInput = System.in
}
task runServer(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = mainClassName
jvmArgs "-javaagent:" + configurations.alpnagent.asPath
}
shadowJar {
classifier = 'shadow'
mainClassName = mainClassName
archiveName = "${title}-${version}.jar"
append 'reference.conf'
destinationDir new File("./docker/bin")
zip64 true
}
1条答案
按热度按时间9wbgstp71#
我想说的是,您需要将generated sources文件夹添加到source set和scala编译器源代码中—类似这样: