gradle无法检测模块

问题描述 投票:0回答:1

我有一个多模块项目。有2个模块: - 服务器模块 - 域模块

在我放的域模块的build.gradle中:

group = 'com.xxx.yyyy.zzz'
version = '1.0.0-SNAPSHOT'

服务器模块导入域模块如下:

dependencies {
compile group: 'com.xxx.yyyy.zzz', name: 'domain', version: '1.0.0-SNAPSHOT'

...
}

但是他无法检测到它! jar发布到maven m2 repo,我能够看到它。我正在使用mavenLocal来获取m2的依赖关系

repositories {
    mavenLocal()
    mavenCentral()
}

我删除了gradle缓存,停止了gradle守护进程没有成功!

任何的想法 ?

服务器模块的build.gradle:

group = 'com.xxx.yyy.zzz'
version = '1.0.0-SNAPSHOT'
repositories {
    mavenLocal()
    mavenCentral()

}

apply plugin: "org.springframework.boot"
apply plugin: "net.ltgt.apt"
apply plugin: "maven"
apply plugin: 'base'
apply plugin: 'maven-publish'

dependencies {
    compile group: 'com.xxx.yyy.zzz', name: 'domaine', version: '1.0.0-SNAPSHOT'
// other dependecies ......
}

域模块的build.gradle:

group = 'com.desjardins.experiencecredit.gestiondemandes'
version = '1.0.0-SNAPSHOT'

repositories {
    mavenLocal()
    mavenCentral()
}

apply plugin: "maven"
apply plugin: 'base'
apply plugin: 'maven-publish'


uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: mavenrepo)
        }
    }
}

jar.finalizedBy uploadArchives

主项目的settings.gradle:

pluginManagement {
    repositories {
        gradlePluginPortal()
    }
}
rootProject.name = 'XXX'
include 'server'
include 'domaine'
java gradle dependencies
1个回答
0
投票

如果同一项目中有多个模块,则应使用project对象声明依赖项:

根项目级别的settings.gradle

rootProject.name = 'my-application'

include 'server'
include 'domain'

然后定义构建文件 - 根项目build.gradle,服务器模块build.gradle和域模块build.gradle。

在服务器模块的build.gradle中,声明依赖项如下:

dependencies {
  compile project(':domain')

  ...
}

参考:https://guides.gradle.org/creating-multi-project-builds/

© www.soinside.com 2019 - 2024. All rights reserved.