【发布时间】:2014-09-05 03:19:33
【问题描述】:
我是使用 Gradle 进行 android 和依赖管理的新手。我是一名 Java 开发人员,通常我使用 Maven 来管理依赖项。
调查发现 Gradle 现在是 Android 上的依赖管理。我通常在服务器端使用图层。我做了一个客户端项目来与客户端进行通信,以防万一是 Android 应用程序。我必须将我的客户端 jar 添加为 Android 项目中的依赖项。
实际上,我在 Archiva 有我的本地存储库。在 pom.xml 中,我通常在 repositories 标签中声明我的本地存储库,这样,我可以将我的项目包含为依赖项。
Gradle 可以做到这一点吗?
我这样做了,但是当我在 android 模拟器中运行项目时,项目失败了。
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
// Build Configuration
buildscript {
// Repositories
repositories {
mavenLocal()
mavenCentral()
}
// Dependencies
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
// Android Plugin
//apply plugin: 'android'
apply plugin: 'android-library'
// Repositories
repositories {
mavenLocal()
mavenCentral()
}
// Dependencies Configuration
dependencies {
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
**compile 'com.project:myproject-client:1.0.0'**
}
// Android Configuration
android {
buildToolsVersion '20.0.0'
compileSdkVersion 20
sourceSets {
main {
manifest {
srcFile 'app/src/main/AndroidManifest.xml'
}
java {
srcDir 'app/src/main/java'
}
res {
srcDir 'app/src/main/res'
}
/*assets {
srcDir 'assets'
}*/
resources {
srcDir 'app/src/main/resources'
}
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
lintOptions {
// simple xml fails lint checks because it references javax.xml.stream
abortOnError false
}
}
【问题讨论】: