How to use Gradle to generate Eclipse and Intellij project files for Android projects(如何使用 Gradle 为 Android 项目生成 Eclipse 和 Intellij 项目文件)
问题描述
Is it possible to generate Eclipse and Intellij project files for Android projects using Gradle?
In maven we would do mvn eclipse:eclipse
and in PlayFramework we would do play eclipsify
. Does Gradle have this feature for Android projects?
I have installed Gradle (1.6) and Android SDK Manager (22.0.1) explained here
This is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.0'
}
}
apply plugin: 'android'
apply plugin: 'eclipse'
sourceCompatibility = 1.7
version = '1.0.2'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
buildToolsVersion "17"
compileSdkVersion 8
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 7
targetSdkVersion 8
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
And then I run the command:
gradle clean build cleanEclipse eclipse
It builds just fine, but when I import the project into Eclipse it looks like a normal java project.
Anyone know how to get Gradle to create Android specific Eclipse project files?
Is this a prioritized feature by Gradle?
-- UPDATE --
I do believe this is an issue. So I have posted it to the Android Tools team issue #57668. Please star it for them to prioritize the issue :)
-- UPDATE --
It does not look like the Android Tools team are looking into this issue. So for now I have converted to Android Studio where I'm able to import my gradle project with dependencies via the IDE.
Gradle itself is a generic build tool, it is not created specifically for Android.
All the functionality is enabled using plug-ins. Traditionally, build plug-ins don't generate project structure. That's the job of project specific tools. The Android plug-in for Gradle follows this.
The problem is that current android
tool in SDK generates old type of project structure (ant builds). The new project structure can only be generated via Android Studio.
There is a concept of archetypes in tools like Maven, which allow using project templates. Gradle does not support that yet (requests have been made for this feature).
Refer to this thread: http://issues.gradle.org/browse/GRADLE-1289 , some users have provided scripts to generate structure.
Build Initialization feature is in progress: https://github.com/gradle/gradle/blob/master/design-docs/build-initialisation.md
Hopefully some one can write a script to do that, refer to this guide for new project structure: http://tools.android.com/tech-docs/new-build-system/user-guide
Update
There is now an official Android IDE: Android Studio . It is based on Intellij and the new build system is Gradle based.
这篇关于如何使用 Gradle 为 Android 项目生成 Eclipse 和 Intellij 项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Gradle 为 Android 项目生成 Eclipse 和 Intellij 项目文件


- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01