我有一个多模块项目。有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'
如果同一项目中有多个模块,则应使用project
对象声明依赖项:
根项目级别的settings.gradle
rootProject.name = 'my-application'
include 'server'
include 'domain'
然后定义构建文件 - 根项目build.gradle,服务器模块build.gradle和域模块build.gradle。
在服务器模块的build.gradle中,声明依赖项如下:
dependencies {
compile project(':domain')
...
}