Reputation: 163
I work on AndroidStudio,and I have a project that structure:
MyProject1
I want upload ModuleCommon and ModuleDemo to my local nexus service, I will use ModuleCommon or(and) ModuleSocket in other project, that my gradle script(fragment):
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
Via above script, I upload my library ModuleCommon and ModuleSocket to my nexus server success, but when I use ModuleSocket, I obtain a error:
Error:Failed to resolve: xmrk:ModuleCommon:unspecified Open File
Show in Project Structure dialog
Anybody save me? I feel my case like Android Gradle library dependency with library dependency using Nexus, but have a bit diff, and have diff error.
Upvotes: 2
Views: 2077
Reputation: 163
I resolve this question by delete cache in C:\Users[MyUsername].gradle\caches.
Thinks @Gabriele
Upvotes: 5