Skip to content

Commit

Permalink
Added pom, fixed 1.2/1.1 compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoduncan committed Apr 17, 2010
1 parent 380240b commit cd5bc0a
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 7 deletions.
121 changes: 121 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>clj-ssh</groupId>
<artifactId>clj-ssh</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>clj-ssh</name>
<description>ssh from clojure</description>
<scm>
<connection>scm:git:git://github.com/hugoduncan/clj-ssh.git</connection>
<developerConnection>scm:git:ssh://git@github.com/hugoduncan/clj-ssh.git</developerConnection>
<tag>380240ba9bf67fffe69bebdc9aaef711e819063d</tag>
<url>http://github.com/hugoduncan/clj-ssh</url>
</scm>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<sourceDirectories>
<sourceDirectory>src</sourceDirectory>
</sourceDirectories>
<testSourceDirectories>
<testSourceDirectory>test</testSourceDirectory>
</testSourceDirectories>
<clojureOptions>-Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=256m</clojureOptions>
<warnOnReflection>true</warnOnReflection>
<compileDeclaredNamespaceOnly>true</compileDeclaredNamespaceOnly>
<testDeclaredNamespaceOnly>true</testDeclaredNamespaceOnly>
</configuration>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>clojure</id>
<url>http://build.clojure.org/releases</url>
</repository>
<repository>
<id>clojure-snapshots</id>
<url>http://build.clojure.org/snapshots</url>
</repository>
<repository>
<id>clojars</id>
<url>http://clojars.org/repo/</url>
</repository>
</repositories>
<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>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.42</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>clojure-1.2</id>
<dependencies>
<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>
</dependencies>
</profile>
</profiles>
</project>
17 changes: 10 additions & 7 deletions src/clj_ssh/ssh.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Licensed under EPL (http://www.eclipse.org/legal/epl-v10.html)"
;; working towards clojure 1.1/1.2 compat
(try
(use '[clojure.contrib.reflect :only [call-method]])
(use '[clojure.contrib.io :only [as-file]])
(use '[clojure.contrib.io :only [file]])
(catch Exception e
(use '[clojure.contrib.java-utils
:only [file wall-hack-method]
:rename {wall-hack-method call-method file as-file}])))
:rename {wall-hack-method call-method}])))

(defmacro with-default-session-options
"Set the default session options"
Expand All @@ -77,9 +77,10 @@ Licensed under EPL (http://www.eclipse.org/legal/epl-v10.html)"
(. System getProperty "user.name"))

(defn default-identity
[] (if-let [id-file (as-file (. System getProperty "user.home") ".ssh" "id_rsa")]
(if (.canRead id-file)
id-file)))
[]
(if-let [id-file (file (. System getProperty "user.home") ".ssh" "id_rsa")]
(if (.canRead id-file)
id-file)))

(defn add-identity
"Add an identity to the agent."
Expand Down Expand Up @@ -238,7 +239,8 @@ keys. All other option key pairs will be passed as SSH config options."
false)
(.setOutputStream out-stream))
(when (contains? opts :pty)
(call-method com.jcraft.jsch.ChannelSession 'setPty [Boolean/TYPE] shell (boolean (opts :pty))))
(call-method com.jcraft.jsch.ChannelSession 'setPty [Boolean/TYPE]
shell (boolean (opts :pty))))
(with-connection shell
(while (connected? shell)
(Thread/sleep 100))
Expand All @@ -263,7 +265,8 @@ keys. All other option key pairs will be passed as SSH config options."
(.setErrStream err-stream)
(.setCommand cmd))
(when (contains? opts :pty)
(call-method com.jcraft.jsch.ChannelSession 'setPty [Boolean/TYPE] exec (boolean (opts :pty))))
(call-method com.jcraft.jsch.ChannelSession 'setPty [Boolean/TYPE]
exec (boolean (opts :pty))))
(with-connection exec
(while (connected? exec)
(Thread/sleep 100))
Expand Down

0 comments on commit cd5bc0a

Please sign in to comment.