How do I use Clojure in Android Studio using Graclj?

戏子无情 提交于 2019-12-23 18:49:00

问题


My ultimate goal is to be able to write Clojure apps for Android, using Android Studio and Cursive. I started with leiningen but found out that it is a build system that is independent of what Andoid Studio uses ie Gradle. So I tried leiningen with Intellij, but couldn't get Android deploys to work except from the command line. Since I wanted to integrate with Android Studio, I decided to try Graclj: https://github.com/graclj/graclj which is a Gradle plugin for Clojure.

I can get the Graclj tutorial running in Android Studio, as per this guide: https://github.com/graclj/learning-graclj/tree/learning-0.1.0

However:

  • Graclj expects the Clojure src and built classes and jars to be in the root project
  • Android Studio expects src and classes to be in the app subproject
  • After the tutorial I end up with separate Gradle build tasks for Graclj and Android Studio but I don't know how to integrate them

So, can anyone suggest a way that I can hook into Andoid Studio's build process?

  • Do I need to change some settings to the Graclj plugin to do this? If so, how?
  • Do I need to change some Android Studio plugin settings?
  • Do I need to add/change something in the Gradle build scripts?
  • Am I heading down a dead end? ;-)

I have looked at the Android Studio build process: http://developer.android.com/tools/building/configuring-gradle.html but I don't know enough about Gradle to know what I'm supposed to be doing here.

If I need to supply any more info, just ask.

Any help appreciated!


回答1:


Unfortuantely, I don't have any Android (let alone Android Studio) experience. However, I'll do my best to answer based on Gradle/Graclj knowledge.

Graclj does not require you to use the root project. You can apply the plugin(s) in any of the projects that you have in your build. However, I don't know how well a model-based plugin like Graclj will work with the "traditional" Android plugin. You could try the "experimental" one that's using the model approach, though there's a decent chance that it won't be compatible unless there's one that works with Gradle 2.12.

Alternatively, you might be able to add a dependency to the Android app project on the JAR produced by Graclj (which you may still want to put in a project besides the root). Not sure if there's a very good way to do this (haven't tried myself).

dependencies {
   // my-other-proj being whichever one you use Graclj in
   compile project(':my-other-proj')
}

Or maybe you would need to add it to a configuration first in the my-other-proj to interop with traditional plugins:

artifacts {
   archives createMainJar
}

It is possible that you're at a dead end (for now). Graclj is very new, so this stuff should all be possible eventually.



来源:https://stackoverflow.com/questions/35965305/how-do-i-use-clojure-in-android-studio-using-graclj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!