How to use Gradle to generate Eclipse and Intellij project files for Android projects

前端 未结 6 1778
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 13:30

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 PlayFra

6条回答
  •  北海茫月
    2020-12-02 13:47

    The following worked for me

    eclipse.classpath.plusConfigurations += configurations.compile
    
    eclipse.classpath.file {
        beforeMerged { classpath ->
        classpath.entries.removeAll() { c -> 
            c.kind == 'src'
        }
    }
    
    withXml {
        def node = it.asNode()
    
        node.appendNode('classpathentry kind="src" path="src/main/java"')
        node.appendNode('classpathentry kind="src" path="src/debug/java"')
        node.appendNode('classpathentry kind="src" path="gen"')
    
        node.children().removeAll() { c ->
            def path = c.attribute('path')
            path != null && (
                    path.contains('/com.android.support/support-v4')
                    )
        }
      }
    }
    
    eclipse.project {
       name = 'AndroidGradleBasic'
    
       natures 'com.android.ide.eclipse.adt.AndroidNature'
       buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder'
       buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder'
       buildCommand 'com.android.ide.eclipse.adt.ApkBuilder'
    }
    

    Source - http://blog.gouline.net/2013/11/02/new-build-system-for-android-with-eclipse/

    Sample - https://github.com/krishnaraj/oneclipboard

提交回复
热议问题