Start Clojure programming.
Os:ubuntu 14.10
Idea 14.0.3 Ultimate
Installing Leiningen
Follow http://leiningen.org/'s Guide to install the Lein.
Installing La Clojure
Install the idea plugin La Clojure. Start idea, click File-----Settings----and Plugins "Clojure" in the top left corner, then locate the La Clojure and install.
New Project
Establish Clojure project under the workspace. Input mode: Lein new Groupid/artifactid. GroupID and Artifactid in the same concept as Maven.
For example, if you enter Lein new Hs.clojure/clojure_sample, you will build a Clojure project according to the template.
Import idea
This project directly into idea will not be recognized correctly, so you need to execute the Lein pom in the Learn directory and generate the corresponding POM.
The contents of the Pom.xml file are as follows:
<?xml version= "1.0" encoding= "UTF-8"? ><project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http ://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/POM/4.0.0/http Maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion>4.0.0</modelVersion> <groupId> Hs.clojure</groupid> <artifactId>clojure_sample</artifactId> <packaging>jar</ Packaging> <version>0.1.0-SNAPSHOT</version> <name>clojure_sample</name> < Description>fixme:write description</description> <url>http://example.com/FIXME</url> < licenses> <license> <name>eclipse Public license</name> <url>http://www.eclipse.or g/legal/epl-v10.html</url> </license> </licenses> <build> <sourcedirectory>src</s ourcedirectory> <testSourceDirectory>test</testSourceDirectory> <resources> ≪resource> <directory>resources</directory> </resource> </resources> <tes tresources> <testResource> <directory>dev-resources</directory> </testresource> ; <testResource> <directory>resources</directory> </testResource> </testresources& Gt <directory>target</directory> <outputDirectory>target/classes</outputDirectory> < plugins/> </build> <repositories> <repository> <id>central</id> <url> ;https://repo1.maven.org/maven2/</url> <snapshots> <enabled>false</enabled> </ snapshots> <releases> <enabled>true</enabled> </releases> </REPOSITORY&G T <repository> <id>clojars</id> <url>https://clojars.org/repo/</url> <snapsh Ots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enable d> </releases> </repository> </repositories> <dependencies> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> <VERSION>1.6.0&L t;/version> </dependency> <dependency> <groupId>org.clojure</groupId> <artif actid>tools.nrepl</artifactid> <version>0.2.6</version> <exclusions> <exclu Sion> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> </exclusion> </exclusions> <scope>test</scope> </dependency> <dependency& Gt <groupId>clojure-complete</groupId> <artifactId>clojure-complete</artifactId> <versio n>0.2.3</version> <exclusions> <exclusion> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> </exclusion> </exclusions> <scope>test< /scope> </dependency> </dependencies></project><!--This file is autogenerated by Leiningen. Please don't edit it directly; Instead edit PROJECT.CLJ and regenerate it. It should not being considered canonical data. For more information see Https://github.com/technomancy/leiningen--
Then import project in idea, select Import project from external model, and then point to Maven, all the way down.
Configure the main function
In the open Idea Project, open the SRC directory with the Clojure_sample.clj file in the Hs.clojure package.
There is no main function in this Clojure file, so run is executed in idea and nothing is output.
Change the contents of this file.
(NS hs.clojure.clojure_sample) (Defn-main [& args] (println "Hello, world!"))
Then click Run in the top menu of idea, select Edit configurations, select Run main function in the script namespace, click OK.
Execute run "Learn" in the Run menu and the program will print "Hello, world!".
At this point, if you execute Lein run, you will say "No:main namespace specified in Project.clj".
Need to modify PROJECT.CLJ
(Defproject hs.clojure/clojure_sample "0.1.0-snapshot"
:d escription "Fixme:write description"
: Main Hs.clojure.clojure_sample
: url "Http://example.com/FIXME"
: License {: Name "Eclipse Public License"
: url "http://www.eclipse.org/legal/epl-v10.html"}
:d ependencies [[Org.clojure/clojure "1.6.0"]])
After saving, execute Lein run, output "Hello, world!"
Perfect!!!
Build clojure development environment-using INTELLIJ idea and Leiningen