我的项目包含一个jar
和一个war
模块。该jar
模块包含源集main
和generated
.
我的jar
模块gradle.build
定义了源集,如下所示:
sourceSets {
generated
main {
compileClasspath += sourceSets.generated.output // adds the sourceSet to the compileClassPath
runtimeClasspath += sourceSets.generated.output // adds the sourceSet to the runtimeClasspath
}
}
并将两个源集的输出放入 jar 中。
jar {
from sourceSets.generated.output
from sourceSets.main.output
}
在我的war
模块中,我想使用 Gretty 在构建中运行它。该build.gradle
文件看起来像这样。
apply plugin: 'war'
apply from: "${rootDir}/gradle/gretty.gradle"
gretty {
// supported values:
// 'jetty7', 'jetty8', 'jetty9', 'tomcat7', 'tomcat8'
servletContainer = 'tomcat8'
httpPort = 8081
contextPath = '/wbc'
realm 'wbc-realm'
realmConfigFile 'tomcat-users.xml'
}
dependencies {
compile project(':interfaces')
compile "org.atmosphere:atmosphere-runtime:${atmosphereVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "javax.servlet:javax.servlet-api:${servletVersion}"
runtime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
runtime "log4j:log4j:1.2.17"
}
每当我使用gradle --daemon clean appRun
Gretty 启动 Gretty 时,由于ClassNotFoundException
. 该类位于我的模块的generated
源集中。jar
如何告诉 gretty 将其添加到类路径中?