我的项目包含一个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而无法启动Tomcat。该类位于我的generated模块的jar源代码集中。我怎样才能让格里蒂把它添加到类路径中?
发布于 2016-07-12 10:51:41
尝试将生成的输出目录添加到gretty classPath:
gretty {
...
sourceSets.generated.output.each { classPath it }
}https://stackoverflow.com/questions/35079353
复制相似问题