Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Clojure Documentation
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
Colour
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Undo
Redo
Keyboard Shortcuts Help
<p>WARNING: When this was copied over from assembla, I couldn't find a way to make pieces of the code bold. Some of this may not make sense.</p> <h1>Creating a Project</h1> <p>Create a new project directory structure like this:</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> myproject myproject/src myproject/src/main myproject/src/main/clojure myproject/src/test myproject/src/test/clojure </pre></td></tr></table> <p>In the top-level myproject directory, create a file named pom.xml, and copy the template below. Replace the bold-face parts with your own domain name, project name, URL, and description.</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <?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/maven-v4_0_0.xsd"> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>myproject</artifactId> <version>1.0.0-SNAPSHOT</version> <url>http://example.com/</url> <description>My new project</description> <name>${artifactId}</name> <licenses> <license> <name>Eclipse Public License 1.0</name> <url>http://opensource.org/licenses/eclipse-1.0.php</url> <distribution>repo</distribution> </license> </licenses> <dependencies> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure-contrib</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>swank-clojure</groupId> <artifactId>swank-clojure</artifactId> <version>1.2.1</version> </dependency> </dependencies> <repositories> <repository> <id>clojars</id> <url>http://clojars.org/repo</url> </repository> <repository> <id>clojure-snapshots</id> <url>http://build.clojure.org/snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>clojure-releases</id> <url>http://build.clojure.org/releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <build> <plugins> <plugin> <groupId>com.theoryinpractise</groupId> <artifactId>clojure-maven-plugin</artifactId> <version>1.3.2</version> <executions> <execution> <id>compile-clojure</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-clojure</id> <phase>test</phase> <goals> <goal>test</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> </pre></td></tr></table> <p>You can also replace the license name/url with a different license if you wish.</p> <h2>Running Clojure</h2> <p>To start a Clojure REPL (read-eval-print-loop) in your new project, type:</p> <p><code>mvn clojure:repl</code></p> <p>To start a SWANK server (for connecting to Emacs SLIME), type:</p> <p><code>mvn clojure:swank</code></p> <p>Then run M-x slime-connect from within Emacs</p> <h2>Adding Your Own Code</h2> <p>Add your .clj source files under src/main/clojure. When creating file names from namespace names, periods become directory separators and hyphens become underscores. So a namespace like</p> <p><code>(ns com.example.foo-library)</code></p> <p>Would go in the file src/main/clojure/com/example/foo_library.clj</p> <p>Follow the same convention for test source code (using clojure.test), adding files under src/test/clojure.</p> <h2>Adding Dependencies</h2> <p>Open-source Java libraries can be found on search engines such as MVNrepository and Jarvana. Many Clojure libraries can be found on Clojars.</p> <p>Once you have found a dependency, add its group/artifact/version information to the <dependencies> section of pom.xml.</p> <p>For example, to add a dependency on Compojure, add the following code to pom.xml:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependencies> <!-- ... other dependencies ... --> <dependency> <groupId>compojure</groupId> <artifactId>compojure</artifactId> <version>0.4.0-SNAPSHOT</version> </dependency> <!-- ... --> </dependencies> </pre></td></tr></table> <p>Note: Be aware that different libraries may be written for different version of Clojure. Check the library documentation to make sure you have the right version.</p> <h2>Using Different Clojure Versions</h2> <p>To use the 1.2.0 development snapshots of Clojure and clojure-contrib, change this block in pom.xml:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure-contrib</artifactId> <version>1.1.0</version> </dependency> </pre></td></tr></table> <p>To this:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> <version>1.2.0-master-SNAPSHOT</version> </dependency> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure-contrib</artifactId> <version>1.2.0-SNAPSHOT</version> </dependency> </pre></td></tr></table>
Attachments
Labels
Location
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced