如何使用摇篮生成针对Android项目的Eclipse和IntelliJ项目文件 [英] How to use Gradle to generate Eclipse and Intellij project files for Android projects

查看:117
本文介绍了如何使用摇篮生成针对Android项目的Eclipse和IntelliJ项目文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能产生,使用Android的摇篮项目的Eclipse和IntelliJ项目文件?

Is it possible to generate Eclipse and Intellij project files for Android projects using Gradle?

在行家,我们会做 MVN蚀:日食和PlayFramework我们会做播放eclipsify 。难道摇篮有此功能对于Android项目?

In maven we would do mvn eclipse:eclipse and in PlayFramework we would do play eclipsify. Does Gradle have this feature for Android projects?

我已经安装了摇篮(1.6)和Android SDK管理器(22.0.1)解释<一个href="http://stackoverflow.com/questions/16619773/failed-to-import-new-gradle-project-failed-to-find-build-tools-revision-17-0-0/17447972#17447972">here

I have installed Gradle (1.6) and Android SDK Manager (22.0.1) explained here

这是我的build.gradle文件:

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

它建立得很好,但是当我将项目导入到Eclipse中,它看起来像一个普通的Java项目。

It builds just fine, but when I import the project into Eclipse it looks like a normal java project.

任何人都知道怎么弄的摇篮创建机器人具体的的Eclipse 项目文件?

Anyone know how to get Gradle to create Android specific Eclipse project files?

这是由摇篮的优先功能?

Is this a prioritized feature by Gradle?

- 更新 -

我不认为这是一个问题。所以我把它贴到了Android工具团队问题#57668 。请明星为他们优先考虑的问题:)

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 :)

- 更新 -

它看起来并不像Android的工具团队正在调查这个问题。所以现在我已经转换为机器人工作室在那里我可以通过与依赖进口我的摇篮项目IDE中。

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.

推荐答案

摇篮本身是一个通用的构建工具,它不是专门为Android创建。

Gradle itself is a generic build tool, it is not created specifically for Android.

所有的功能可通过插件启用。传统上,构建插件不生成项目结构。这就是项目的具体工具的工作。而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.

现在的问题是,目前的机器人工具SDK生成旧型的项目结构(Ant构建)。新的项目结构只能通过Android的Studio生成。

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.

还有就是原型的工具,比如Maven的,它允许使用项目模板的概念。摇篮不支持,但(请求已作出此功能)。

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).

请参阅此主题: http://issues.gradle.org/browse/GRADLE-1289 ,有些用户提供的脚本生成的结构。

Refer to this thread: http://issues.gradle.org/browse/GRADLE-1289 , some users have provided scripts to generate structure.

建立初始化功能正在进行中:的https://github.com/gradle/gradle/blob/master/design-docs/build-initialisation.md

Build Initialization feature is in progress: https://github.com/gradle/gradle/blob/master/design-docs/build-initialisation.md

希望有一个人可以写一个脚本来做到这一点,请参阅本指南对新项目结构:的 http://tool​​s.android.com/tech-docs/new-build-system/user-guide

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

更新

现在有一个官方Android IDE:机器人工作室。它基于的IntelliJ和新的编译系统是基于摇篮。

There is now an official android IDE : Android Studio . It is based on Intellij and the new build system is Gradle based.

这篇关于如何使用摇篮生成针对Android项目的Eclipse和IntelliJ项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆