Home > front end >  clojure project build using gradle clojurephant plugin "namespace not found after loading "
clojure project build using gradle clojurephant plugin "namespace not found after loading "

Time:12-10

I'm trying to build clojure project with gradle build tool using clojurephant plugin.

The project is on github here

My build file is -

    plugins {
        id 'dev.clojurephant.clojure' version '0.6.0'
        id 'application'
    }

    group 'org.example'
    version '0.0.1-SNAPSHOT'
    repositories {
        maven {
            name = 'Clojars'
            url = 'https://repo.clojars.org'
        }
        mavenCentral()
    }


    dependencies {
        implementation 'org.clojure:clojure:1.10.3'

        testRuntimeOnly 'org.ajoberstar:jovial:0.3.0'

        devImplementation 'org.clojure:tools.namespace:1.1.0'
    }

    tasks.withType(Test) {
        useJUnitPlatform()
    }

Below is the calc.clj file at dir src/main/clojure/math dir

(ns math.calc)
(defn add [x y] (  x y))
(defn demo [x y] (* 2 x y))

Below is the calc_test.clj at dir src/test/clojure/math dir

(ns math.calc)
(defn add [x y] (  x y))
(defn demo [x y] (* 2 x y))

when I run gradle test, I get below error -

$ gradle test

Task :compileTestClojure FAILED Syntax error compiling at (REPL:2:1). namespace 'math.calc-test' not found after loading '/math/calc_test'

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileTestClojure'.

Compilation failed. See output above.

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s 2 actionable tasks: 1 executed, 1 up-to-date

What is wrong with my project setup? How can I solve this error?

CodePudding user response:

You are using the wrong ns in your test. I must be (ns math.calc-test)

  • Related