【发布时间】:2019-05-18 17:53:08
【问题描述】:
我有 2 个项目,我正在将项目 1 的一些类文件作为 jar 文件发布到 bitbucket。现在我需要以某种方式将该 jar 文件作为依赖项包含在项目 2 中。这是项目 1 build.gradle 中的发布代码(我使用的是 gradle-git-publish 库 gradle 插件):
task myJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'My Jar',
'Implementation-Version': '1.0.0'
}
baseName = "my-project"
from sourceSets.main.output
include 'com/my/project/deep/nested/files/*.class'
eachFile { FileCopyDetails file -> file.setPath('com/my/project/files/' + file.getName()) }
includeEmptyDirs = false
with jar
}
gitPublish {
repoUri = 'git@bitbucket.org:myusername/my-repo.git'
branch = 'master'
contents {
from 'build/libs'
}
commitMessage = 'Latest commit'
}
gitPublishPush.dependsOn myJar
这是迄今为止我在项目 2 中尝试将 jar 添加为依赖项的一些方法。
repositories {
mavenCentral()
maven {
url 'https://bitbucket.org/myusername/my-project/src/master/'
artifactUrls 'https://bitbucket.org/myusername/my-project/src/master/'
}
ivy {
url "https://bitbucket.org/myusername/my-project/src/master"
layout 'pattern' , {
artifact 'my-project-0.0.1-SNAPSHOT.jar'
}
}
}
dependencies {
implementation 'com.my.project:my-project:0.0.1-SNAPSHOT'
}
Gradle build 报告它正在下载 jar 文件,但在 build 之后它仍然是“无法解析 com.my.project:my-project:0.0.1-SNAPSHOT”。您对如何解决此问题有任何想法,还是我用错误的解决方案来解决整个问题?
【问题讨论】:
标签: git maven gradle dependencies ivy