2017-05-17 7 views
0

私はSpring BootマルチモジュールのGradleアプリケーションを持っています。Gradle multi module dependencies

すべてがビルドされ、ローカルで問題なく実行されますが、サブプロジェクトで出力されるJARには必要な依存関係が含まれていません。奇妙なことに、生成されたマニフェストにはManifest-Version: 1.0しか含まれません。

私は考えることのできるすべての異なる組み合わせを試しましたが、今はアイデアがなくなってしまいました。

buildscript { 
    ext { 
     springBootVersion = "1.5.3.RELEASE" 
    } 
    repositories { 
     mavenCentral() 
     maven { url "https://plugins.gradle.org/m2/" } 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath("io.spring.gradle:dependency-management-plugin:1.0.2.RELEASE") 
     classpath("de.thetaphi:forbiddenapis:2.3") 
     classpath("com.diffplug.spotless:spotless-plugin-gradle:3.3.2") 
    } 
} 

subprojects { 

    apply plugin: "java" 
    apply plugin: "idea" 
    apply plugin: "com.diffplug.gradle.spotless" 
    apply plugin: "de.thetaphi.forbiddenapis" 
    apply plugin: "io.spring.dependency-management" 
    apply plugin: "org.springframework.boot" 

    sourceCompatibility = 1.8 
    targetCompatibility = 1.8 

    repositories { 
     mavenCentral() 
     flatDir { 
      dirs "libs" 
     } 
    } 

    jar { 
     baseName = "app" 
     version = "0.0.1-SNAPSHOT" 
    } 

    spotless { 
     java { 
      googleJavaFormat() 
     } 
    } 

    idea { 
     module { 
      inheritOutputDirs = false 
      outputDir = file("$buildDir/classes/main/") 
     } 
    } 

    task dev { 
     doLast { 
      bootRun.systemProperty "spring.profiles.active", "dev" 
     } 
    } 

    bootRepackage { 
     enabled = false 
    } 

    bootRun { 
     addResources = true 
     systemProperties = System.properties 
    } 

    forbiddenApis { 
     // https://github.com/policeman-tools/forbidden-apis/wiki/GradleUsage 
     bundledSignatures = [ "jdk-unsafe", "jdk-deprecated", "jdk-non-portable" ] 
     signaturesFiles = files("../forbidden_signatures.txt") 
     ignoreFailures = false 
    } 

    dependencies { 
     compile("org.springframework.boot:spring-boot-starter") { 
      exclude group: "org.flywaydb", module: "flyway-core" 
     } 
     compile("org.springframework.boot:spring-boot-devtools") 

     compile("com.google.guava:guava:21.0") 
     compile("org.apache.commons:commons-lang3:3.5") 
     compile("org.projectlombok:lombok") 

     testCompile("org.springframework.boot:spring-boot-starter-test") 
     testCompile("com.h2database:h2") 
    } 

    dependencyManagement { 
     imports { 
      mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}" 
     } 
    } 

    test { 
     testLogging { 
      events "failed" 
      exceptionFormat "full" 
     } 
    } 
} 

そして、私のサブプロジェクトのいずれかのgradle.build:すべてのヘルプやアイデアが非常に高く評価されるだろう

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url "https://plugins.gradle.org/m2/" } 
    } 
    dependencies { 
     classpath("com.moowork.gradle:gradle-node-plugin:1.1.1") 
    } 
} 

apply plugin: "com.moowork.node" 

dependencies { 
    compile project(":core") 
    compile project(":search") 

    // Spring projects 
    compile("org.springframework.boot:spring-boot-starter-security") 
    compile("org.springframework.security:spring-security-web") 
    compile("org.springframework.boot:spring-boot-starter-thymeleaf") 
    compile("org.springframework.boot:spring-boot-starter-mail") 

    // Thymeleaf 
    compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect") 
    compile("it.ozimov:spring-boot-thymeleaf-email:0.5.3") 

    // Email 
    compile("com.sendinblue:sendinblue:2.0") 
    compile("com.icegreen:greenmail-spring:1.5.3") 

    // DB 
    compile("org.postgresql:postgresql:42.0.0") 
    compile("org.flywaydb:flyway-core:4.1.2") 
} 

ext["thymeleaf.version"] = "3.0.5.RELEASE" 
ext["thymeleaf-layout-dialect.version"] = "2.2.1" 

node { 
    version = "7.10.0" 
    download = true 
} 

npmInstall.args = ['--silent'] 

// make sure node and build dependencies are installed before calling webpack 
npm_run_build.dependsOn "npmInstall" 

npm_run_build.dependsOn npm_run_lint 

// make sure webpack generates assets for the build 
processResources.dependsOn npm_run_build 

は、ここに私のルートbuild.gradleです!

ありがとうございます

答えて

0

Huzzah!

だから、問題はこのだっ判明:それは間違ってすべてのサブプロジェクトに適用されていた

bootRepackage { 
    enabled = false 
} 

。代わりに、ブートアプリケーションではないサブプロジェクト(たとえば、共有モジュール)にのみ必要でした。

subProjectsタスクからこの設定を削除して共有モジュールにのみ追加すると、コンパイルの問題はなくなりました。

うまくいけば、これが他の人に役立つはずです。

関連する問題