Can In Gradle mix .java and .clojure and .scala files. I want to mix few programming languages, just searching best way to do it.
Asked
Active
Viewed 668 times
1 Answers
0
I'm starting with a project with mixed java, scala and clojure. In order to include scala I simply added the scala plugin
apply plugin: 'scala'
and the scala dependency to dependencies section:
compile 'org.scala-lang:scala-library:2.11.7'
To include clojure I followed this answer.
My final build.gradle
file looks like this:
buildscript {
repositories {
maven { url "http://clojars.org/repo" }
mavenCentral()
jcenter()
}
dependencies {
classpath 'clojuresque:clojuresque:1.7.0'
}
}
apply plugin: 'application'
apply plugin: 'scala'
apply plugin: 'clojure'
repositories {
mavenCentral()
maven { url "http://clojars.org/repo" }
}
dependencies {
compile 'org.clojure:clojure:1.7.0'
compile 'org.scala-lang:scala-library:2.11.7'
}
// NOTE: You *must* enable AOT (Ahead-of-Time) compilation in order to use a Clojure class as the main class
clojure.aotCompile = true
clojure.warnOnReflection = true
mainClassName = "foo"
My project structure is this one:
.
├── build.gradle
└── src
└── main
├── clojure
│ └── foo.clj
├── java
│ └── JavaClass.java
└── scala
└── HelloWorld.scala
and after run gradle build
I'm getting this build folder:
build
├── classes
│ └── main
│ ├── HelloWorld$.class
│ ├── HelloWorld.class
│ ├── JavaClass.class
│ ├── foo$_main.class
│ ├── foo$fn__64.class
│ ├── foo$loading__5340__auto____62.class
│ ├── foo.class
│ └── foo__init.class
├── dependency-cache
├── distributions
│ ├── init-proj-1.0.0.tar
│ └── init-proj-1.0.0.zip
├── libs
│ └── init-proj-1.0.0.jar
├── scripts
│ ├── init-proj
│ └── init-proj.bat
└── tmp
├── compileJava
│ └── emptySourcePathRef
├── compileScala
└── jar
└── MANIFEST.MF
I haven't reach the point of interop (calling clojure from scala and viceversa, it is discussed here), but at least it is generating the .class
files.

Community
- 1
- 1

rvazquezglez
- 2,284
- 28
- 40