2015-12-04 47 views
1

我试图使用Spring Boot 1.3按照https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html构建完全可执行的WAR。如果我构建一个Gradle项目,它一切正常,但我有一个多项目构建,其中我有一个“根”项目,然后在它下面的几个项目,我不能让它建立任何东西,但标准的“胖” WAR文件,没有Jetty提供的运行时间,并且没有脚本使其运行。从Gradle多项目构建构建完全可执行的Spring Boot 1.3战争

有谁知道如何做到这一点?

在我的根项目,我有以下的(有删节):

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    ext { 
     springBootVersion = '1.3.0.RELEASE' 
    } 
    dependencies { 
     classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" 
    } 
} 

allprojects { 
    //Put instructions for all projects 
    repositories { 
     mavenCentral() // jcenter is missing spring-orm.4.1.6.RELEASE jar file so try mavenCentral first 
     jcenter { 
      url "http://jcenter.bintray.com/" 
     } 
     maven { url 'http://repo.opensourceagility.com/release' } 
    } 
} 

subprojects { 
    apply plugin: 'java' 
    apply plugin: 'spring-boot' 
} 

,然后它是一个网络项目子项目,和我想建,我有:

apply plugin: 'war' 

dependencies { 
    // Include related projects 
    compile project(':project-model') 
    compile project(':project-dynamoDB') 

    // Core Spring Boot - note version is set in main build.gradle file 
    compile 'org.springframework.boot:spring-boot-starter-web' 

    // Remove Tomcat (included in -web) and include Jetty instead 
    providedRuntime 'org.springframework.boot:spring-boot-starter-jetty' 

    // Other Spring modules 
    compile 'org.springframework.boot:spring-boot-starter-social-facebook' 
    compile 'org.springframework.boot:spring-boot-starter-social-linkedin' 
    compile 'org.springframework.social:spring-social-google:1.0.0.RELEASE' 
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf' 
    compile 'org.springframework.boot:spring-boot-starter-security' 
    compile 'org.springframework.boot:spring-boot-starter-actuator' 
    compile 'org.springframework.boot:spring-boot-devtools' 
    compile 'org.springframework:spring-context' 
    compile 'org.springframework:spring-context-support' 
} 

configurations { 
    providedRuntime.exclude group: 'org.springframework.boot', module:'spring-boot-starter-tomcat' 
    all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' // exclude when using log4j 
} 

springBoot { 
    mainClass = 'rs.web.Weblication' 
    executable = true 
} 

bootRun { 
    addResources = true 
} 

processResources { 
    // exclude resources if they look like they're profile dependent but don't match the current env/profile 
    eachFile { d -> 
     if(d.name.endsWith('.xml') || d.name.endsWith('.yaml') || d.name.endsWith('.properties')) { 
      //def fname = d.name.replaceFirst(~/\.[^\.]+$/, '') 
      //if(fname.indexOf("-") > -1 && ! fname.endsWith("-" + environment)) { 
      // d.exclude() 
      //} else { 
      // replace @[email protected] listed below in properties/config files 
      filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [ 
        activeProfiles: environment 
       ]) 
      //} 
     } 
    } 
} 

war { 
    baseName = 'project-web' 
    version = '1.0.0' 
    manifest { 
     attributes 'Implementation-Title': baseName, 
        'Implementation-Version': version 
    } 
    webXml = file('src/main/resources/web.xml') 
    // rename the war task which has profiles appended from warName-profile,profile2.war 
    // to warName-profile.profile2.war 
    classifier = environment.replaceAll(',','-') 
} 

但是当我构建它时(./gradlew build./gradlew subprojectname:build),一切都很好,并且创建了一个可用的WAR,但不是可执行的WAR。

通过一个项目,我工作得很好。

回答

2

啊哈,好吧我建立了一个测试多项目构建,它工作正常,所以它显然是上面的配置。

我通过排除法工作,事实证明,有问题的区域是其目的是与环境变量文件重命名为名称的一部分行

classifier = environment.replaceAll(',','-') 

。这个过程似乎妨碍了脚本的加入;如果真的有必要,也许可以在之后应用。

相关问题