我有一个多项目问题,Gradle的文档没有任何信息(也无法在stackoverflow上找到)。任何帮助/指导将不胜感激。
以下是我的项目布局:
war
文件当我在 AllArms 项目中运行'gradle build uploadArchives'时,它会构建 LeftArm 和 RightArm 项目,但它不会上传{ {1}}文件(由 LeftArm 和 RightArm 项目生成)到本地Maven仓库。
以下是我的jar
文件:
build.gradle
...
project LeftArm:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
ext.artifactId = 'LeftArm'
archivesBaseName = ext.artifactId // sets filename of warfile/jarfile output
group = 'mygroup'
version = '1.0'
buildscript
{
repositories
{
mavenLocal()
}
}
jar
{
from(sourceSets['main'].allJava)
}
dependencies
{
compile group: 'javax.validation', name:'validation-api', version:'1.0.0.GA'
compile group: 'javax.validation', name:'validation-api-sources', version:'1.0.0.GA'
}
def localRepoURL = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
// NOTE: this project will publish to the local Maven repo.
uploadArchives
{
repositories
{
mavenDeployer
{
repository(url: localRepoURL)
addFilter('jar')
{
artifact, file -> artifact.ext == 'jar'
}
}
}
}
...
project RightArm:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
ext.artifactId = 'RightArm'
archivesBaseName = ext.artifactId // sets filename of warfile/jarfile output
group = 'mygroup'
version = '1.0'
buildscript
{
repositories
{
mavenLocal()
}
}
jar
{
from(sourceSets['main'].allJava)
}
dependencies
{
compile group: 'javax.validation', name:'validation-api', version:'1.0.0.GA'
compile group: 'javax.validation', name:'validation-api-sources', version:'1.0.0.GA'
}
def localRepoURL = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
// NOTE: this project will publish to the local Maven repo.
uploadArchives
{
repositories
{
mavenDeployer
{
repository(url: localRepoURL)
addFilter('jar')
{
artifact, file -> artifact.ext == 'jar'
}
}
}
}
答案 0 :(得分:5)
uploadArchives
并不意味着用于安装到本地Maven存储库。相反,请使用install
任务。