代码之家  ›  专栏  ›  技术社区  ›  Benoît Dubreuil

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

  •  0
  • Benoît Dubreuil  · 技术社区  · 8 年前

    我有以下结构:

    文件夹“MyProject”

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

    根项目正确地包含两个子项目。然而,当我包含子根项目“jme3”时,它将作为普通子项目包含。换言之,子项目不会加载,因为设置。未加载jme3子根项目中的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 回复  |  直到 8 年前
        1
  •  0
  •   Benoît Dubreuil    8 年前

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

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

    推荐文章