我开发了一个小型mvp库,其中包含一些相关的内容,例如,butterknife和glide,但是在将其部署到我的私有工件中之后,所有的依赖关系均未包含在我的库中,因此在使用此库时,我的项目中无法解决所有的依赖关系。我对这种人工制品不熟悉,是否缺少某些东西?
这是我的根build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的build.gradle模块:
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'me.tatarka.retrolambda'
def libraryGroupId = 'com.pixilapps.pixilframework'
def libraryArtifactId = 'mvp'
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://my.lib.web/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
}
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
}
}
repositories {
mavenCentral()
jcenter()
maven { url "https://clojars.org/repo/" }
maven { url "https://jitpack.io" }
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven {
url "http://dl.bintray.com/glomadrian/maven"
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8.toString()
targetCompatibility JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
final PLAY_SERVICES_VERSION = '9.6.1'
final DEXMAKER_VERSION = '1.4'
final HAMCREST_VERSION = '1.3'
final ESPRESSO_VERSION = '2.2.1'
final RUNNER_VERSION = '0.4'
final AUTO_VALUE_VERSION = '1.3'
final AUTO_VALUE_GSON_VERSION = '0.4.2'
final SUPPORT_LIBRARY_VERSION = '25.1.0'
final RETROFIT_VERSION = '2.1.0'
final BUTTERKNIFE_VERSION = '7.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.jakewharton.timber:timber:4.1.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.vistrav:ask:2.4'
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'net.danlew:android.joda:2.9.3.1'
compile 'com.pixplicity.easyprefs:library:1.7'
}
最佳答案
您可以在pom.withXml
块中使用publishing
,如here所述(查找有关pom.withXml here的官方文档)。
我想这看起来像是某种东西:
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version = libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.getByName("_releaseCompile").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleGroup)
dependency.appendNode('artifactId', it.moduleName)
dependency.appendNode('version', it.moduleVersion)
}
}
}
}
}