将 AndroidAnnotations Maven 设置适配到 Gradle
Posted
技术标签:
【中文标题】将 AndroidAnnotations Maven 设置适配到 Gradle【英文标题】:Adapt AndroidAnnotations Maven settings to Gradle 【发布时间】:2011-11-12 16:49:29 【问题描述】:是否可以 中?
http://code.google.com/p/androidannotations/wiki/MavenEclipse
我似乎无法让它工作我不断收到com.sun.codemodel#codemodel;2.5-FROZEN-AA: not found
到目前为止我有这个
description = "App"
abbreviation = "App"
version = '1.0.0.BUILD-SNAPSHOT'
buildscript
repositories
mavenRepo name: 'gradle-android-plugin', urls: 'http://jvoegele.com/maven2/'
mavenRepo name: 'androidannotations', urls: 'http://repository.excilys.com/content/repositories/releases/'
def gradleAndroidPluginVersion = '1.0.0'
dependencies
classpath "com.jvoegele.gradle.plugins:android-plugin:$gradleAndroidPluginVersion"
apply plugin: 'android'
apply plugin: 'eclipse'
apply plugin: 'idea'
def compatibilityVersion = 1.6
sourceCompatability = compatibilityVersion
targetCompatibility = compatibilityVersion
repositories
mavenCentral()
mavenRepo urls: 'http://maven.springframework.org/snapshot'
mavenRepo urls: 'http://maven.springframework.org/milestone'
def roboguiceVersion = '1.1.1'
def guiceVersion = '2.0-no_aop'
def springAndroidVersion = '1.0.0.M4'
def commonsHttpClientVersion = '3.1'
def jacksonMapperVersion = '1.8.5'
def androidAnnotationsVersion = '2.1'
dependencies
compile "org.roboguice:roboguice:$roboguiceVersion"
compile "com.google.inject:guice:$guiceVersion"
compile "org.springframework.android:spring-android-rest-template:$springAndroidVersion"
compile "commons-httpclient:commons-httpclient:$commonsHttpClientVersion"
compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonMapperVersion"
compile "com.googlecode.androidannotations:androidannotations:$androidAnnotationsVersion"
compile group: 'com.googlecode.androidannotations', name: 'androidannotations', version: '2.1', classifier: 'api'
runtime files('lib/server-standalone.jar')
sourceSets
main
java
srcDir 'src'
clean
delete 'gen'
idea
module
downloadJavadoc = true
project
javaVersion = 'Android 2.2 Platform'
androidProcessResources.dependsOn(clean)
eclipse.dependsOn(cleanEclipse)
idea.dependsOn(cleanIdea)
defaultTasks 'assemble'
【问题讨论】:
【参考方案1】:作为第一个指针,我看不到托管 androidannotations 库的 maven 存储库的声明。
您应该将http://repository.excilys.com/content/repositories/releases 添加为 maven Repo:
...
repositories
mavenCentral()
mavenRepo urls: 'http://maven.springframework.org/snapshot'
mavenRepo urls: 'http://maven.springframework.org/milestone'
mavenRepo urls: 'http://repository.excilys.com/content/repositories/releases'
...
问候
【讨论】:
【参考方案2】:好的,我设法解决了它
我必须添加
repositories
mavenCentral()
mavenRepo urls: 'http://maven.springframework.org/snapshot'
mavenRepo urls: 'http://maven.springframework.org/milestone'
mavenRepo urls: 'http://repository.excilys.com/content/repositories/releases'
mavenRepo urls: 'http://repository.excilys.com/content/repositories/thirdparty'
springAndroidVersion = '1.0.0.M4'
commonsHttpClientVersion = '3.1'
jacksonVersion = '1.8.5'
androidAnnotationsVersion = '2.1.1'
dependencies
compile "org.springframework.android:spring-android-rest-template:$springAndroidVersion"
compile "commons-httpclient:commons-httpclient:$commonsHttpClientVersion"
compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
compile "com.googlecode.androidannotations:androidannotations:$androidAnnotationsVersion"
compile "com.googlecode.androidannotations:androidannotations:$androidAnnotationsVersion:api"
【讨论】:
您知道,AndroidAnnotations 2.2-RC2 在 Maven Central 上,您不再需要自定义 repo!看来您设法使用 Gradle 构建了一个 Android + AndroidAnnotations 项目,这非常好。如果您有几分钟的时间,您可以发送邮件至 androidannotations@googlegroups.com 并描述使用 Gradle 构建 AA 项目的步骤。无论如何都做得很好!以上是关于将 AndroidAnnotations Maven 设置适配到 Gradle的主要内容,如果未能解决你的问题,请参考以下文章
由于 androidannotations 插件,Gradle 构建失败
[AndroidAnnotations框架]AndroidAnnotations的配置
androidannotations的background和UiThread配合使用參考