1

Я пытаюсь создать полностью исполняемую WAR с использованием Spring Boot 1.3 в соответствии с https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html. Если я создам один проект Gradle, все работает отлично, но у меня есть многопроектная сборка, где у меня есть «корневой» проект, а затем несколько проектов под ним, и я не могу заставить его строить что-либо, кроме стандартного, «жирного», WAR, без предоставленного Runtime of Jetty и без скриптов, чтобы он запускался.Построение полностью исполняемого Spring Boot 1.3 Война с многопроектной сборки Gradle

Кто-нибудь знает, как это сделать?

В моем корневом проекте, у меня есть следующие (в сокращенном виде):

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 создана, но не является исполняемой.

С одним проектом, у меня он работает нормально.

ответ

2

Ах, хорошо, я построил тестовую многопроектную сборку, и она работала нормально, так что это была явно конфигурация выше.

я работал через процесс ликвидации и оказывается, что проблемная область была линией

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

, которая предназначена для переименования файлов с переменным окружением, как часть имени. Этот процесс, похоже, мешает добавлению сценария; возможно, это может быть применено впоследствии, если это действительно необходимо.