我在AndroidStudio上工作,我有一个结构项目:
MyProject1
我想将ModuleCommon和ModuleDemo上传到我的本地nexus服务,我将在其他项目中使用ModuleCommon或(和)ModuleSocket,即我的gradle脚本(片段):
apply plugin: 'maven'
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}
def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
pom.groupId = GROUP
pom.artifactId = "ModuleCommon"
pom.version = "0.0.1"
repository(url: RELEASE_REPOSITORY_URL) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: SNAPSHOT_REPOSITORY_URL) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
}
}
}
task androidJavadocs(type: Javadoc) {
options.encoding = "UTF-8"
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('xmrk:rkandroid:0.0.1')
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
repositories {
maven {url "http://192.168.1.34:8081/nexus/content/repositories/releases"}
maven {url "http://192.168.1.34:8081/nexus/content/repositories/snapshots"}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
repositories {
maven {url "http://localhost:8081/nexus/content/repositories/releases"}
maven {url "http://localhost:8081/nexus/content/repositories/snapshots"}
}
}
}
GROUP=xmrk
SNAPSHOT_REPOSITORY_URL=http://localhost:8081/nexus/content/repositories/snapshots/
RELEASE_REPOSITORY_URL=http://localhost:8081/nexus/content/repositories/releases/
NEXUS_USERNAME=myname
NEXUS_PASSWORD=mypassword
通过上面的脚本,我将我的库ModuleCommon和ModuleSocket上传到我的nexus服务器成功,但是当我使用ModuleSocket时,我得到一个错误:
错误:无法解决:xmrk:ModuleCommon:未指定 打开文件
在“项目结构”对话框中显示
有人救了我吗?我觉得我的情况类似Android Gradle library dependency with library dependency using Nexus,但有点差异,并且有差异。
答案 0 :(得分:3)
我通过删除C:\ Users [MyUsername] .gradle \ caches中的缓存解决了这个问题。
想想@Gabriele