在gradle多项目中包含其他根项目

时间:2017-12-14 17:41:06

标签: java gradle

我有以下结构:

文件夹'MyProject'

------ Root Project 'MyProject_gradle'                                                                                                      
------ Subproject 'MyProject_library'                                                                                                      
------ Subproject 'MyProject_game'                                                                                                      
------ Sub Root Project 'jme3'                                                                                                      
------ ------ Subproject 'jme3-core'                                                                                                      
------ ------ Subproject 'jme3-lwjgl3'                                                                                                      

根项目正确包含两个子项目。但是,当我包含子根项目'jme3'时,它包含在普通子项目中。换句话说,由于未加载jme3子根项目中的settings.gradle,因此未加载子项目。

我想要什么:包括'jme3'还应包括其子项目,并仅将其设置应用于其子项目。

MyProject_gradle/build.gradle

allprojects {
    project.ext {
        retroFlashyRPG = [
                basicName : 'RetroFlashyRPG_',
                prototypeName : 'RetroFlashyRPG_Prototype_'
        ]
    }
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'idea'

    group = 'com.chevreuilgames'

    sourceCompatibility = 1.9
    targetCompatibility = 1.9

    repositories {
        mavenCentral()
        jcenter()

        maven {
            url "https://dl.bintray.com/stephengold/org.jmonkeyengine/"
        }
    }

    project.ext {
        jme = [
                group : 'org.jmonkeyengine',
                version : '3.1.0-stable'
        ]
    }
} 

MyProject_gradle/settings.gradle

def RetroFlashyRPG = "RetroFlashyRPG_" // This is MyProject in this post's example
def RetroFlashyRPG_Prototype = RetroFlashyRPG + "Prototype_"

include 'prototype-library'
include 'jme3'

project(":prototype-library").projectDir = new File(settingsDir, "../${RetroFlashyRPG_Prototype}Library")
project(":jme3").projectDir = new File(settingsDir, "../${RetroFlashyRPG_Prototype}jmonkeyengine")

MyProject_jme3/settings.gradle

/**
 * This is the global settings file used by all subprojects.
 **/
rootProject.name = 'jmonkeyengine'

// Core classes, should work on all java platforms
include 'jme3-core'
include 'jme3-effects'
include 'jme3-networking'
include 'jme3-plugins'
include 'jme3-terrain'

// Desktop dependent java classes
include 'jme3-desktop'
include 'jme3-blender'
include 'jme3-jogl'
include 'jme3-lwjgl'
include 'jme3-lwjgl3'

// Other external dependencies
include 'jme3-jbullet'
include 'jme3-niftygui'
include 'jme3-jogg'
include 'jme3-android'
include 'jme3-ios'

//native builds
include 'jme3-bullet' //java
include 'jme3-bullet-native' //cpp
include 'jme3-bullet-native-android' //cpp
include 'jme3-android-native' //cpp

// Test Data project
include 'jme3-testdata'

// Example projects
include 'jme3-examples'

if(buildAndroidExamples == "true"){
    include 'jme3-android-examples'
}

1 个答案:

答案 0 :(得分:0)

在当前版本的Gradle(v4.4)中,没有办法做我希望实现的目标。相反,我选择了两个独立的多项目,并使用编译文件在本地挑选所需的罐子。

另一个更简单的选择是执行"安装"来自maven插件的任务。然后,添加mavenLocal()存储库。该任务将jar发布到本地maven存储库,该存储库可以像远程存储库一样访问。

相关问题