Gradle-Konfiguration für multi-Modul-Projekt mit gemeinsamen Abhängigkeiten

Machen ein erstes Projekt mit gradle, also schaue ich im Frühjahr, gradle, hibernate Projekte, wie organisieren Sie sich gradle-Dateien, und starten Sie meine eigenen. Aber, kann nicht finden Fehler, warum meine Konfiguration nicht funktioniert. (sub-Projekte cant resolve dependency)
So Projekt Baum:

Root project 'foobar'
+--- Project ':foobar-app'
| +--- Project ':foobar-app:people'
| | +--- Project ':foobar-app:people:people-api'
| | +--- Project ':foobar-app:people:people-core'
| | +--- Project ':foobar-app:people:people-data'
| | \--- Project ':foobar-app:people:people-rest'
| \--- Project ':foobar-app:realtor'
+--- Project ':foobar-starter'
\--- Project ':foobar-system'
+--- Project ':foobar-system:foobar-system-jpa'
+--- Project ':foobar-system:foobar-system-neo4j'
+--- Project ':foobar-system:foobar-system-persistence'
+--- Project ':foobar-system:foobar-system-repository'
\--- Project ':foobar-system:foobar-system-tx'

Das problem, wenn ich foobar-system-PPV.gradle-Datei mit einer Reihe von Abhängigkeiten, etc, es ist keine Arbeit - keine Abhängigkeiten können erreicht werden für dieses Modul. Aber wenn in root 'foobar' bauen.gradle machen Sie einen Satz von Highsider für 'foobar-system-jpa' Teilprojekt - es " Arbeit in Ordnung. Warum?

Mein root bauen.gradle:

configurations.all {
    //check for updates every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

configure(allprojects) { project ->
    group = 'com.foobar'
    version = '0.0.1-SNAPSHOT'

    apply from: "${rootDir}/dependencies.gradle"

    apply plugin: 'maven'
    apply plugin: 'idea'

    ext.gradleScriptDir = "${rootProject.projectDir}/gradle"

    apply from: "${gradleScriptDir}/task.gradle"

}

configure(subprojects) { subproject ->
    apply plugin: 'java'

    sourceCompatibility = 1.7
    targetCompatibility = 1.7
    apply from: "${rootDir}/dependencies.gradle"

    repositories {
        mavenCentral()

        maven { url "http://m2.neo4j.org/" }
        maven { url "http://repo.maven.apache.org/maven2" }
    }


    dependencies {
        testCompile (libs.junit)
        testCompile (libs.mockito)
        testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
    }

}

meine Abhängigkeiten.gradle

ext {
    springVersion = "4.0.0.RELEASE"
    jUnitVersion = "4.11"
    hibernateVersion = "4.2.1.Final"

    libs = [
            //springframework
            spring_core: "org.springframework:spring-core:$springVersion",
            spring_orm: "org.springframework:spring-orm:$springVersion",
          ......
            hibernate_entitymanager: "org.hibernate:hibernate-entitymanager:$hibernateVersion",
            hibernate_persistence: "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final",
            //database
            postgresql : "org.postgresql:postgresql:9.3-1100-jdbc41",
            commons_dbcp : "commons-dbcp:commons-dbcp:1.4",
           .....

    ]
}

und meine Einstellungen.gradle

rootProject.name = 'foobar'
include ':foobar-system:foobar-system-jpa'
....
include ':foobar-app:people:people-rest'
include ':foobar-app:people:people-core'
....
include ':foobar-starter'

project(':foobar-system:foobar-system-jpa').projectDir = "$rootDir/foobar-system/foobar-system-jpa" as File
project(':foobar-system:foobar-system-repository').projectDir = "$rootDir/foobar-system/foobar-system-repository" as File
.....
project(':foobar-app').projectDir = "$rootDir/foobar-app" as File
project(':foobar-starter').projectDir = "$rootDir/foobar-starter" as File

rootProject.children.each { project ->
    project.buildFileName = "${project.name}.gradle"
    assert project.projectDir.isDirectory()
    assert project.buildFile.exists()
    assert project.buildFile.isFile()
}

So, foobar-system-PPV.gradle , die NICHT arbeiten (Modul kann nicht kompiliert, Ursache nicht gefunden keine Abhängigkeit)

dependencies {
    compile libs.spring_orm
    compile (libs.spring_data_jpa) {
        exclude(module: 'spring-jdbc')
        exclude(module: 'spring-orm')
    }
    compile libs.hibernate_entitymanager
    compile libs.postgresql
    compile libs.commons_dbcp
    compile project(':foobar-system:foobar-system-tx')
}

Danke für deine Antwort. Für inspiration schauen Sie für dieses Projekt https://github.com/hibernate/hibernate-orm/blob/master/hibernate-entitymanager/hibernate-entitymanager.gradle

UPD: entfernen Sie einige nicht benötigte code

  • Was ist die Fehlermeldung, die du bekommst?
  • es gibt keine Fehler, aber es scheint, dass foobar-system-jpa finde keine Abhängigkeiten, wenn ich es kompilieren.
Schreibe einen Kommentar