Frequently Asked Questions

How do I get dependencies from Clojars?

To get dependencies from anywhere you need to list it in your project’s repositories block.

// plugins, etc.

repositories {
  maven {
    name = 'Clojars'
    url = ''

// dependencies, etc.

How do I publish to Clojars?

You’ll want to set your Clojars credentials in environment variables (in this example, CLOJARS_USER and CLOJARS_PASSWORD).

plugins {
  id 'maven-publish'

// other stuff

publishing {
  publications {
    main(MavenPublication) {
  repositories {
    maven {
      name = 'clojars'
      url = ''
      credentials {
        username = System.env['CLOJARS_USER']
        password = System.env['CLOJARS_PASSWORD']

Then run the publish task.

How do I create an uberjar?

Use the Gradle Shadow plugin.


To create an executable uberjar:

plugins {
  id 'dev.clojurephant.clojure' version '0.7.0'
  // this tells Gradle you're generating an application with a main class
  id 'application'
  // Pulls in the shadow plugin which produces the uberjar
  id 'com.github.johnrengelman.shadow' version '6.1.0'

mainClassName = ''

// normal repositories and deps blocks

Ensure your main namespace has (:gen-class) in the ns declaration:

(ns sample.core
  (:require [clojure.string :as string]
            [java-time :as time])

(defn -main [& args]
  (println (str (time/local-date))))


  • ./gradlew shadowJar will produce the uberjar (look in build/libs)

  • ./gradlew runShadow will run the main class of your uberjar

  • ./gradlew distShadowZip or ./gradlew distShadowTar will produce a distribution with OS-specific start scripts to run your uberjar. (look in build/distributions)

More information

Read the Shadow Plugin User Guide. for full details on their other features.

How do I build Clojure code that depends on Java code?

You can compile Clojure code that depends on Java out of the box. Just put your Java code in the same source set as the Clojure code:



How do I build Java code that depends on Clojure code?

This requires changing the classpaths for the Clojure build and the Java compile.

// plugins, etc...

clojure.builds {
  main {
    // reset Clojure classpath to only include dependencies
    classpath.from = sourceSets.main.compileClasspath

    // or if you also need the sources on the classpath
    // classpath.from = sourceSets.main.compileClasspath + tasks.named(sourceSets.main.processResourcesTaskName)

    // makes sure you AOT at least the namespace that produces the class(es) Java uses

tasks.named('compileJava') {
  // add clojure's compiled output onto the Java compiler output
  classpath += files(sourceSets.main.clojure.classesDirectory)

// dependencies, etc...
Similar approaches should apply for other JVM languages (e.g. Groovy or Kotlin).