在gradle'中指定war;汤姆卡特鲁瓦酒店

在gradle'中指定war;汤姆卡特鲁瓦酒店,gradle,Gradle,我正在使用for gradle,在我的build/tmp/tomcatRun/work/Tomcat/localhost/myWebApp目录中,它是空的。我有没有办法指定要部署的war的位置 我试过了 [tomcatRun, tomcatRunWar]*.destinationDir= new File("$buildDir/libs").getAbsoluteFile().getPath() 及 更新 我在下面添加了构建脚本。当我运行我的新任务时,我一直在运行 gradle build i

我正在使用for gradle,在我的build/tmp/tomcatRun/work/Tomcat/localhost/myWebApp目录中,它是空的。我有没有办法指定要部署的war的位置

我试过了

[tomcatRun, tomcatRunWar]*.destinationDir= new File("$buildDir/libs").getAbsoluteFile().getPath()

更新

我在下面添加了构建脚本。当我运行我的新任务时,我一直在运行

gradle build integrationTest
以下是父build.gradle中的一个片段:

buildscript {
    repositories {
        add(new org.apache.ivy.plugins.resolver.URLResolver()) {
            name = 'GitHub'
            addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }

    dependencies {
        classpath 'bmuschko:gradle-tomcat-plugin:0.9.2'
    }

}

allprojects {
  apply plugin: "java"
  apply plugin: "eclipse"
  apply plugin: "idea"

  ext.springVersion = "3.1.1.RELEASE"
  ext.hibernateVersion = "3.6.7.Final"
  ext.mysqlVersion = "5.1.20"
  ext.tomcatVersion = "7.0.26"
  ext.junitVersion = "4.10"
  ext.httpClientVersion = "4.2"
  ext.pdfboxVersion = "1.7.1"
  ext.resxWebserviceVersion = "10.4.2"

  loadConfiguration()
}
apply plugin: "maven"
apply plugin: "war"
apply plugin: "tomcat"

def now = new Date()

def cssDir = new File("truexpense-web/src/main/webapp/css").getAbsoluteFile().getPath()
def minCssName = 'all-min.css'
def jsDir = new File("truexpense-web/src/main/webapp/js").getAbsoluteFile().getPath()
def minJsName = 'all-min.js'

ext.requestor = ''
ext.fromAddress = ''
ext.replyAddress = ''
ext.formattedDate = now.format('dd MMM yyy HH:mm')
ext.product = 'Truexpense'

configurations {
  deployerJars
  jasper
  mail
}

dependencies {

  //Compile time but not included dependencies
  providedCompile "javax.servlet:javax.servlet-api:3.0.1"
  providedCompile "org.apache.tomcat:tomcat-jdbc:$tomcatVersion"

  //Compile time dependencies
  compile project(":truexpense-domain")
  compile project(":truexpense-repository")
  compile project(":truexpense-service")
  compile "org.springframework:spring-core:$springVersion"
  compile "org.springframework:spring-web:$springVersion"
  compile "org.hibernate:hibernate-core:$hibernateVersion"
  compile "org.hibernate:hibernate-envers:$hibernateVersion"
  compile "org.hibernate:hibernate-ehcache:$hibernateVersion"
  compile "org.hibernate:hibernate-validator:4.2.0.Final"
  compile "commons-io:commons-io:2.3"
  compile "commons-codec:commons-codec:1.6"
  compile "org.springframework.security:spring-security-core:3.1.0.RELEASE"
  compile "org.springframework.security:spring-security-config:3.1.0.RELEASE"
  compile "org.springframework.security:spring-security-web:3.1.0.RELEASE"
  compile "javax.mail:mail:1.4"
  compile "mysql:mysql-connector-java:$mysqlVersion"
  compile "com.google.visualization:visualization-datasource:1.0.2"
  compile "org.ostermiller:utils:1.07.00"
  compile "net.sf.ofx4j:ofx4j:1.4"
  compile "org.jpedal:jbig2:1"
  compile "org.apache.pdfbox:txp-fontbox:$pdfboxVersion"
  compile "org.apache.pdfbox:txp-jempbox:$pdfboxVersion"
  compile "org.apache.pdfbox:txp-pdfbox:$pdfboxVersion"
  compile "taglibs:taglibs-unstandard:1"
  compile "org.codehaus.jackson:jackson-mapper-asl:1.9.7"
  compile "org.apache.httpcomponents:httpclient:$httpClientVersion"

  //Runtime only dependencies
  runtime "commons-beanutils:commons-beanutils-core:1.8.3"
  runtime "joda-time:joda-time:2.1"
  runtime "org.springframework.security:spring-security-taglibs:3.1.0.RELEASE"
  runtime "org.springframework:spring-beans:$springVersion"
  runtime "org.springframework:spring-context:$springVersion"
  runtime "org.springframework:spring-core:$springVersion"
  runtime "org.springframework:spring-expression:$springVersion"
  runtime "org.springframework:spring-instrument:$springVersion"
  runtime "org.springframework:spring-instrument-tomcat:$springVersion"
  runtime "org.springframework:spring-jdbc:$springVersion"
  runtime "org.springframework:spring-jms:$springVersion"
  runtime "org.springframework:spring-orm:$springVersion"
  runtime "org.springframework:spring-oxm:$springVersion"
  runtime "org.springframework:spring-tx:$springVersion"
  runtime "org.springframework:spring-web:$springVersion"
  runtime "org.springframework:spring-webmvc:$springVersion"
  runtime ("commons-fileupload:commons-fileupload:1.2.2") {
    exclude group: "javax.servlet", module: "javax.servlet-api"
    exclude group: "portlet-api"
  }
  runtime ("javax.servlet:jstl:1.2") {
    exclude group: "javax.servlet", module: "javax.servlet-api"
    exclude group: "javax.servlet", module: "jsp-api"
  }

  //Test only dependencies
  tomcat "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"
  tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
         "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
  tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
      exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'

  }

  //Deployments
  deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"

  [tomcatRun, tomcatRunWar]*.httpPort = 8090
  [tomcatRun, tomcatStop]*.stopPort = 8081
  [tomcatRun, tomcatStop]*.stopKey = 'stopKey'

  task integrationTest(type: Test) {
      include '**/*IntegrationTest.*'

      doFirst {
          tomcatRun.daemon = true
          tomcatRun.execute()
      }

      doLast {
          tomcatStop.execute()
      }
  }

  test {
      exclude '**/*IntegrationTest.*'
  }

}


war {
  baseName='truexpense'
  eachFile {
    if (it.name == 'login_css_include.jsp') {
      it.expand(loginCSS: "login-min.css?t=${now.getTime()}")
    }
    else if (it.name == 'all_css_include.jsp') {
      it.expand(allCSS: "all-min.css?t=${now.getTime()}")
    }
    else if (it.name == 'all_js_include.jsp') {
      it.expand(allJS: "all-min.js?t=${now.getTime()}")
    }
  }
}

task deploy << { deploy() }

task minifyCSS << {
  def files = fileTree(dir: "${cssDir}", includes: [
    "analysis.css",
    "header.css",
    "footer.css",
    "blocks.css",
    "chosen.css",
    "grids.css",
    "space.css",
    "dataTables.css",
    "newCore.css",
    "core.css",
    "skin_clean.css",
    "plugins.css",
    "css3.css",
    "jquery-ui.css",
    "jquery.lightbox-0.5.css",
    "jqueryFileTree.css",
    "jquery.qtip.css",
    "expense.css",
    "report.css",
    "zentab.css"
  ]).getFiles().sort({it.name})
  concatenate("${cssDir}/all.css", files)
  yuiCompressor("${cssDir}/all.css", "${cssDir}/${minCssName}")
  yuiCompressor("${cssDir}/login.css", "${cssDir}/login-min.css")
}

task minifyJS << {
  def files = fileTree(dir: "${jsDir}", excludes:[
    'all*.js',
    'jqtouch*.js'
  ]).getFiles().sort({it.name})
  concatenate("${jsDir}/all.js", files)
  yuiCompressor("${jsDir}/all.js", "${jsDir}/${minJsName}")
}

def yuiCompressor(from, to) {
  ant.java(jar:"tools/yuicompressor-2.4.7.jar", fork: true, failonerror: true) {
    arg(value: from)
    arg(value: "-o")
    arg(value: to)
  }
}

def concatenate(filePath, files) {
  File file = new File(filePath)
  if (file.exists()) {
    file.write("")
  }
  files.each { File f ->
    file.append(f.getText() + '\n')
  }
}

def deploy() {
  println "Deleting ${tomcatHome}/webapps/${war.baseName}"
  delete "${tomcatHome}/webapps/${war.baseName}"
  println "Deleting ${tomcatHome}/work/Catalina/localhost/${war.baseName}"
  delete "${tomcatHome}/work/Catalina/localhost/${war.baseName}"
  println "Copying ${war.archiveName} to ${tomcatHome}/webapps"
  copy {
    from war.archivePath
    into "${tomcatHome}/webapps"
  }
}
和my webapps build.gradle:

buildscript {
    repositories {
        add(new org.apache.ivy.plugins.resolver.URLResolver()) {
            name = 'GitHub'
            addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }

    dependencies {
        classpath 'bmuschko:gradle-tomcat-plugin:0.9.2'
    }

}

allprojects {
  apply plugin: "java"
  apply plugin: "eclipse"
  apply plugin: "idea"

  ext.springVersion = "3.1.1.RELEASE"
  ext.hibernateVersion = "3.6.7.Final"
  ext.mysqlVersion = "5.1.20"
  ext.tomcatVersion = "7.0.26"
  ext.junitVersion = "4.10"
  ext.httpClientVersion = "4.2"
  ext.pdfboxVersion = "1.7.1"
  ext.resxWebserviceVersion = "10.4.2"

  loadConfiguration()
}
apply plugin: "maven"
apply plugin: "war"
apply plugin: "tomcat"

def now = new Date()

def cssDir = new File("truexpense-web/src/main/webapp/css").getAbsoluteFile().getPath()
def minCssName = 'all-min.css'
def jsDir = new File("truexpense-web/src/main/webapp/js").getAbsoluteFile().getPath()
def minJsName = 'all-min.js'

ext.requestor = ''
ext.fromAddress = ''
ext.replyAddress = ''
ext.formattedDate = now.format('dd MMM yyy HH:mm')
ext.product = 'Truexpense'

configurations {
  deployerJars
  jasper
  mail
}

dependencies {

  //Compile time but not included dependencies
  providedCompile "javax.servlet:javax.servlet-api:3.0.1"
  providedCompile "org.apache.tomcat:tomcat-jdbc:$tomcatVersion"

  //Compile time dependencies
  compile project(":truexpense-domain")
  compile project(":truexpense-repository")
  compile project(":truexpense-service")
  compile "org.springframework:spring-core:$springVersion"
  compile "org.springframework:spring-web:$springVersion"
  compile "org.hibernate:hibernate-core:$hibernateVersion"
  compile "org.hibernate:hibernate-envers:$hibernateVersion"
  compile "org.hibernate:hibernate-ehcache:$hibernateVersion"
  compile "org.hibernate:hibernate-validator:4.2.0.Final"
  compile "commons-io:commons-io:2.3"
  compile "commons-codec:commons-codec:1.6"
  compile "org.springframework.security:spring-security-core:3.1.0.RELEASE"
  compile "org.springframework.security:spring-security-config:3.1.0.RELEASE"
  compile "org.springframework.security:spring-security-web:3.1.0.RELEASE"
  compile "javax.mail:mail:1.4"
  compile "mysql:mysql-connector-java:$mysqlVersion"
  compile "com.google.visualization:visualization-datasource:1.0.2"
  compile "org.ostermiller:utils:1.07.00"
  compile "net.sf.ofx4j:ofx4j:1.4"
  compile "org.jpedal:jbig2:1"
  compile "org.apache.pdfbox:txp-fontbox:$pdfboxVersion"
  compile "org.apache.pdfbox:txp-jempbox:$pdfboxVersion"
  compile "org.apache.pdfbox:txp-pdfbox:$pdfboxVersion"
  compile "taglibs:taglibs-unstandard:1"
  compile "org.codehaus.jackson:jackson-mapper-asl:1.9.7"
  compile "org.apache.httpcomponents:httpclient:$httpClientVersion"

  //Runtime only dependencies
  runtime "commons-beanutils:commons-beanutils-core:1.8.3"
  runtime "joda-time:joda-time:2.1"
  runtime "org.springframework.security:spring-security-taglibs:3.1.0.RELEASE"
  runtime "org.springframework:spring-beans:$springVersion"
  runtime "org.springframework:spring-context:$springVersion"
  runtime "org.springframework:spring-core:$springVersion"
  runtime "org.springframework:spring-expression:$springVersion"
  runtime "org.springframework:spring-instrument:$springVersion"
  runtime "org.springframework:spring-instrument-tomcat:$springVersion"
  runtime "org.springframework:spring-jdbc:$springVersion"
  runtime "org.springframework:spring-jms:$springVersion"
  runtime "org.springframework:spring-orm:$springVersion"
  runtime "org.springframework:spring-oxm:$springVersion"
  runtime "org.springframework:spring-tx:$springVersion"
  runtime "org.springframework:spring-web:$springVersion"
  runtime "org.springframework:spring-webmvc:$springVersion"
  runtime ("commons-fileupload:commons-fileupload:1.2.2") {
    exclude group: "javax.servlet", module: "javax.servlet-api"
    exclude group: "portlet-api"
  }
  runtime ("javax.servlet:jstl:1.2") {
    exclude group: "javax.servlet", module: "javax.servlet-api"
    exclude group: "javax.servlet", module: "jsp-api"
  }

  //Test only dependencies
  tomcat "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"
  tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
         "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
  tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
      exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'

  }

  //Deployments
  deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"

  [tomcatRun, tomcatRunWar]*.httpPort = 8090
  [tomcatRun, tomcatStop]*.stopPort = 8081
  [tomcatRun, tomcatStop]*.stopKey = 'stopKey'

  task integrationTest(type: Test) {
      include '**/*IntegrationTest.*'

      doFirst {
          tomcatRun.daemon = true
          tomcatRun.execute()
      }

      doLast {
          tomcatStop.execute()
      }
  }

  test {
      exclude '**/*IntegrationTest.*'
  }

}


war {
  baseName='truexpense'
  eachFile {
    if (it.name == 'login_css_include.jsp') {
      it.expand(loginCSS: "login-min.css?t=${now.getTime()}")
    }
    else if (it.name == 'all_css_include.jsp') {
      it.expand(allCSS: "all-min.css?t=${now.getTime()}")
    }
    else if (it.name == 'all_js_include.jsp') {
      it.expand(allJS: "all-min.js?t=${now.getTime()}")
    }
  }
}

task deploy << { deploy() }

task minifyCSS << {
  def files = fileTree(dir: "${cssDir}", includes: [
    "analysis.css",
    "header.css",
    "footer.css",
    "blocks.css",
    "chosen.css",
    "grids.css",
    "space.css",
    "dataTables.css",
    "newCore.css",
    "core.css",
    "skin_clean.css",
    "plugins.css",
    "css3.css",
    "jquery-ui.css",
    "jquery.lightbox-0.5.css",
    "jqueryFileTree.css",
    "jquery.qtip.css",
    "expense.css",
    "report.css",
    "zentab.css"
  ]).getFiles().sort({it.name})
  concatenate("${cssDir}/all.css", files)
  yuiCompressor("${cssDir}/all.css", "${cssDir}/${minCssName}")
  yuiCompressor("${cssDir}/login.css", "${cssDir}/login-min.css")
}

task minifyJS << {
  def files = fileTree(dir: "${jsDir}", excludes:[
    'all*.js',
    'jqtouch*.js'
  ]).getFiles().sort({it.name})
  concatenate("${jsDir}/all.js", files)
  yuiCompressor("${jsDir}/all.js", "${jsDir}/${minJsName}")
}

def yuiCompressor(from, to) {
  ant.java(jar:"tools/yuicompressor-2.4.7.jar", fork: true, failonerror: true) {
    arg(value: from)
    arg(value: "-o")
    arg(value: to)
  }
}

def concatenate(filePath, files) {
  File file = new File(filePath)
  if (file.exists()) {
    file.write("")
  }
  files.each { File f ->
    file.append(f.getText() + '\n')
  }
}

def deploy() {
  println "Deleting ${tomcatHome}/webapps/${war.baseName}"
  delete "${tomcatHome}/webapps/${war.baseName}"
  println "Deleting ${tomcatHome}/work/Catalina/localhost/${war.baseName}"
  delete "${tomcatHome}/work/Catalina/localhost/${war.baseName}"
  println "Copying ${war.archiveName} to ${tomcatHome}/webapps"
  copy {
    from war.archivePath
    into "${tomcatHome}/webapps"
  }
}
apply插件:“maven”
应用插件:“战争”
应用插件:“tomcat”
def now=新日期()
def cssDir=新文件(“TrueExpense web/src/main/webapp/css”).getAbsoluteFile().getPath()
def minCssName='all-min.css'
def jsDir=新文件(“TrueExpense web/src/main/webapp/js”).getAbsoluteFile().getPath()
def minJsName='all-min.js'
ext.requestor=“”
ext.fromAddress=“”
ext.replyAddress=“”
ext.formattedDate=now.format('dd-MMM-yyy-HH:mm')
ext.product='TrueExpense'
配置{
部署器
贾斯珀
邮件
}
依赖关系{
//编译时但不包含依赖项
提供编译“javax.servlet:javax.servlet api:3.0.1”
providedCompile“org.apache.tomcat:tomcat jdbc:$tomcatVersion”
//编译时依赖关系
编译项目(“:TrueExpense域”)
编译项目(“:TrueExpense存储库”)
编译项目(“:TrueExpense服务”)
编译“org.springframework:springcore:$springVersion”
编译“org.springframework:springweb:$springVersion”
编译“org.hibernate:hibernate核心:$hibernateVersion”
编译“org.hibernate:hibernate envers:$hibernateVersion”
编译“org.hibernate:hibernateehcache:$hibernateVersion”
编译“org.hibernate:hibernate验证程序:4.2.0.Final”
编译“commons io:commons io:2.3”
编译“commons编解码器:commons编解码器:1.6”
编译“org.springframework.security:springsecuritycore:3.1.0.RELEASE”
编译“org.springframework.security:spring安全配置:3.1.0.RELEASE”
编译“org.springframework.security:springsecurityweb:3.1.0.RELEASE”
编译“javax.mail:mail:1.4”
编译“mysql:mysql连接器java:$mysqlVersion”
编译“com.google.visualization:可视化数据源:1.0.2”
编译“org.ostermiller:utils:1.07.00”
编译“net.sf.ofx4j:ofx4j:1.4”
编译“org.jpedal:jbig2:1”
编译“org.apache.pdfbox:txp fontbox:$pdfboxVersion”
编译“org.apache.pdfbox:txpjempbox:$pdfboxVersion”
编译“org.apache.pdfbox:txp pdfbox:$pdfboxVersion”
编译“taglibs:taglibs非标准:1”
编译“org.codehaus.jackson:jacksonmapper asl:1.9.7”
编译“org.apache.httpcomponents:httpclient:$httpClientVersion”
//仅运行时依赖项
运行时“commons beanutils:commons beanutils核心:1.8.3”
运行时“joda时间:joda时间:2.1”
运行时“org.springframework.security:springsecurity标记库:3.1.0.RELEASE”
运行时“org.springframework:springbean:$springVersion”
运行时“org.springframework:spring上下文:$springVersion”
运行时“org.springframework:springcore:$springVersion”
运行时“org.springframework:spring表达式:$springVersion”
运行时“org.springframework:spring工具:$springVersion”
运行时“org.springframework:spring工具tomcat:$springVersion”
运行时“org.springframework:springjdbc:$springVersion”
运行时“org.springframework:springjms:$springVersion”
运行时“org.springframework:springorm:$springVersion”
运行时“org.springframework:springoxm:$springVersion”
运行时“org.springframework:springtx:$springVersion”
运行时“org.springframework:springweb:$springVersion”
运行时“org.springframework:springwebmvc:$springVersion”
运行时(“commons fileupload:commons fileupload:1.2.2”){
排除组:“javax.servlet”,模块:“javax.servlet api”
排除组:“portlet api”
}
运行时(“javax.servlet:jstl:1.2”){
排除组:“javax.servlet”,模块:“javax.servlet api”
排除组:“javax.servlet”,模块:“jspapi”
}
//仅测试依赖项
tomcat“org.apache.tomcat:tomcat dbcp:${tomcatVersion}”
tomcat“org.apache.tomcat.embed:tomcat嵌入核心:${tomcatVersion}”,
“org.apache.tomcat.embed:tomcat嵌入日志juli:${tomcatVersion}”
tomcat(“org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}”){
排除组:“org.eclipse.jdt.core.compiler”,模块:“ecj”
}
//部署
deployerJars“org.apache.maven.wagon:wagon http:1.0-beta-2”
[tomcatRun,tomcatRunWar]*.httpPort=8090
[tomcatRun,tomcatStop]*.stopPort=8081
[tomcatRun,tomcatStop]*.stopKey='stopKey'
任务集成测试(类型:测试){
包括“***集成测试。*”
首先{
tomcatRun.daemon=true
tomcatRun.execute()
}
多拉斯特{
tomcatStop.execute()
}
}
试验{
排除“***集成测试。*”
}
}
战争{
baseName='TrueExpense'
每个文件{
if(it.name='login\u css\u include.jsp'){
expand(loginCSS:“login-min.css?t=${now.getTime()}”)
}
else if(it.name='all\u css\u include.jsp'){
expand(allCSS:$all-min.css?t=${now.getTime()})
}
else if(it.name='all_js_include.jsp'){
expand(allJS:$all-min.js?t=${now.getTime()})
}
}
}

任务部署如何在
web.xml
中引用
applicationContext.xml
?如果使用完整路径(
/WEB-INF/classes/applicationContext.xml
),则我可能会将其更改为在类路径上搜索:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>

上下文配置位置
类路径:applicationContext.xml

如何在
web.xml
中引用您的
应用程序上下文.xml
?如果使用完整路径(
/WEB-INF/classes/applicationContext.xml
),则我可能会将其更改为在类路径上搜索:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>

上下文配置位置
类路径:applicationContext.xml

您是否正在尝试构建WAR文件并将其部署到外部Tomcat容器?否,我们有一个从WAR.archivePath复制到Tomcat主页的部署路径。这是我的目标