为了在我们的Android团队中共享我们的库,我尝试设置JFrog Artifactory OSS。一切正常,除了我的队友无法通过我们的本地网络访问存储库。
要部署存储库,请将此行添加到我的库的gradle中
在我的图书馆 build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.1"
}
在我的模块 build.gradle
中apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
def libraryGroupId = 'com.mycomp.mylib'
def libraryArtifactId = 'mylib'
def libraryVersion = '1.0.0'
...
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
}
}
}
artifactory {
contextUrl = 'http://10.220.2.2:8081/artifactory'
publish {
repository {
repoKey = 'libs-release-local'
username = artifactory_username
password = artifactory_password
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
publishPom = true
}
}
和执行任务'assembleRelease artifactoryPublish'... 成功:
Deploying artifact: http://10.220.2.2:8081/artifactory/libs-release-local/com/mycomp/mylib/mylib/1.0.0/mylib-1.0.0.aar
Deploying artifact: http://10.220.2.2:8081/artifactory/libs-release-local/com/mycomp/mylib/mylib/1.0.0/mylib-1.0.0.pom
但是当我们尝试获取库时,它将失败
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.mycomp.mylib:mylib:1.0.0.
Show Details
Affected Modules: app
在我的项目 build.gradle
allprojects {
repositories {
google()
jcenter()
maven {
url "http://10.220.2.2:8081/artifactory/libs-release-local"
credentials {
username = "${artifactory_username}"
password = "${artifactory_password}"
}
}
}
}
在我的模块 build.gradle
中implementation "com.mycomp.mylib:mylib:1.0.0"
如果我将IP更改为 localhost ,则可以正常使用,但问题仍然存在!
更新:
Artifactory Web UI屏幕快照上的存储库:
libs-release-local
library
答案 0 :(得分:0)
您的队友可以访问此IP吗?尝试从他们的机器上运行
ping 10.220.2.2
然后尝试从其计算机访问用户界面,请转到http://10.220.2.2:8081/artifactory
如果他们无法访问它,那么这是一个内部网络问题。也许您不在同一台机器上? 也有可能您的计算机上装有不允许访问端口8081的防火墙。
您在什么操作系统上运行?