I am using IntelliJ IDEA in a Clojure project, I just started I get the message "File core.clj is not under a source root", the project has 2 folders: .idea
and src
, inside src
I got the core.clj
file in which showing the structure of the project. This is the photo containing the structure of the project.
I have no source root, I just created the core.clj
and the deps.edn
file and the Deps_project.iml
file, nothing else, how can I solve this? Do I need to write another file?
CodePudding user response:
You need just two files for your project:
In file deps.edn
{:paths ["src"]
:deps {org.clojure/spec.alpha {:mvn/version "0.3.218"}}}
In file src/spec_tutorial/core.clj
(ns spec-tutorial.core
(:require [clojure.spec.alpha :as s]))
Note there is a correspondence between the Clojure namespace and the source file path, but beware that hyphens -
in namespaces are translated to underscores _
in path names.
CodePudding user response:
Your directory tree should look like so:
./deps.edn
./src/spec_tutorial/core.clj
where the ./
prefix is unix-style shorthand for the project directory.
So, the ./src
part is determined by the :paths
line in deps.edn
. The spec_tutorial/core.clj
part is from the namespace spec-tutorial/core
, and the .clj
suffix is the "file-type".
Also, note that hyphens in the namespace become underscores in the file/directory names.
Another observation: Do not include :test-paths
in the file core.clj
as seen in your screenshot.