2012-06-25 3 views
1

나는 gradle과 내 빌드/tmp/tomcatRun/work/Tomcat/localhost/myWebApp 디렉토리에서 비어있는 tomcat plugin을 가지고 놀고 있습니다. 배치 할 내 위치를 지정하는 방법이 있습니까? gradle의 tomcatRunWar에 war 지정하기

나는

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

[tomcatRun, tomcatRunWar]*.warDirectory= 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() 
} 

은 내 웹 어플리케이션은 build.gradle :

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" 
    } 
} 
+0

당신은 WAR 파일을 구축하고 외부 Tomcat 컨테이너에 배포하려고합니까? –

+0

아니요 war.archivePath에서 tomcat 홈으로 복사하는 배포 경로가 없습니다. 내 목표는 통합 테스트입니다. 내 통합 작업이 tomcatRun을 실행하고 "java.io.FileNotFoundException : ServletContext resource [/WEB-INF/classes/applicationContext.xml]을 열 수 없음"예외가 발생했을 때 위에 나열된 작업 디렉토리를 살펴보면 아무 것도 배포되지 않습니다. 더 궁금한 점이 있으면 알려주세요. –

+0

미안하지만 나는 아직도 당신이 성취하려는 것을 얻지 못합니다. 'tomcatRun'과'tomcatRunWar' 작업은 당신이 설정하려고하는'destinationDir'과'warDirectory' 속성을 가지고 있지 않습니다. 전체 빌드 스크립트를 게시 할 수 있습니까? Tomcat home을 언급 할 때 그것은 로컬 Tomcat 설치가 포함됨을 의미합니까? –

답변

1

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> 
+0

한 줄 수정해야합니다. 저와 제안을 고수해 주셔서 감사합니다! –