首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向Gretty类路径添加附加源集

向Gretty类路径添加附加源集
EN

Stack Overflow用户
提问于 2016-01-29 07:49:53
回答 1查看 1.1K关注 0票数 0

我的项目包含一个jar和一个war模块。jar模块包含到源集maingenerated

我的jar模块gradle.build定义了源代码集,如下所示:

代码语言:javascript
复制
sourceSets {
    generated
    main {
        compileClasspath += sourceSets.generated.output  // adds the sourceSet to the compileClassPath
        runtimeClasspath += sourceSets.generated.output  // adds the sourceSet to the runtimeClasspath
    }
}

并将两个源集的输出放入jar中。

代码语言:javascript
复制
jar {
    from sourceSets.generated.output
    from sourceSets.main.output
}

在我的war模块中,我想使用Gretty在构建中运行它。build.gradle文件如下所示。

代码语言:javascript
复制
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源代码集中。我怎样才能让格里蒂把它添加到类路径中?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-12 10:51:41

尝试将生成的输出目录添加到gretty classPath:

代码语言:javascript
复制
gretty {
  ...
  sourceSets.generated.output.each { classPath it }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35079353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档